Anti-rust programming language

T

ToM_tOm

I've been programming in C++ for a few years now. At one stage, I had a
great deal of it very fresh in my mind.

About two weeks ago, I started back programming in C++ having not been at it
for maybe a year. I opened a few of my old source files and was... well...
unfamiliar!

Looking at "p_k = &k" and the like left me staring blankly at the screen
trying to think exactly what that meant... ?

A day later I was grand, I had the syntax down.

But... I realised something about the C++ programming language. I'll try to
keep this objective, as I'm sure a few of you here would object to any
suggestion that this is a "flaw" in the language, but here goes:

C++ is not at all "anti-rust". By that, I mean that it's very easy to become
rusty at it, and once you do, you're perplexed looking at all the strange
syntax!

Compare this to Visual Basic. If you could do something like "p_k = &k" in
VB, then it'd probably look like:

SetPointer p_k = AddressOf( k )

, which we English speaking humans can understand very easily!

I'm not all suggesting that the language should be dumbed-downed or
deficienized (as is the case with VB), but I think it would be helpful if
actual English words were used in the place of symbols.

Don't get me wrong though -- I'm a fairly intelligent person and I've no
problem at all reading through a source file looking at all the different
symbols; I can interpret them swiftly on-the-fly, but if I go twelve months
without seeing them, then they're just unfamiliar alien language.

The whole "alien language" aspect is what makes C++ so daunting for
beginners. To a person who doesn't know C++, or who is rusty, a C++ source
code file looks like horribly complex gobledygook! Little do they know
though that we C++ programmers read through it as easy as our native
language... just so long as we're not rusty!

Anyway, I've said enough. I'm summarise:

Because we use symbols in C++, if we go a good deal of time without using
it, we become horribly rusty.

If we were to use actual English words instead of symbols (as does Visual
Basic), then the language would be learned more quickly, and also we
wouldn't spend as much time digging into the back of our brain once we
become rusty.

Maybe someone out there has made a parser to change symbols into words and
vice versa?

ToM_tOm
 
I

Ian

Compare this to Visual Basic. If you could do something like "p_k = &k" in
VB, then it'd probably look like:

SetPointer p_k = AddressOf( k )
#define SetPointer
#define AddressOf( n ) &##n;

Ian
 
O

Old Wolf

Ian said:
#define SetPointer
#define AddressOf( n ) &##n;

Should be:
#define AddressOf(n) &(n)

We aren't making a new token here; the address-of operator and the
thing that we're taking the address of, are separate tokens.

Note that the OP is hoist by his own petard. He could easily
have written:
pointer_to_k = &k;

and then even a non-C++ programmer (who did know what a pointer was)
would be able to guess that & means address-of.
 
O

Old Wolf

ToM_tOm said:
C++ is not at all "anti-rust". By that, I mean that it's very easy
to become rusty at it, and once you do, you're perplexed looking at
all the strange syntax!

The technical term would be that C++ is not "memorable".
But memorability means different things to different people...
SetPointer p_k = AddressOf( k )

which we English speaking humans can understand very easily!

And what about non-English-speaking humans? English is only
the first language of 9% of the world's population, and that
is declining.
Would you really have had any better luck with:

FijeLaDireccion p_k = IndicadorDe( k )

or perhaps even

设置尖 p_k = 地å€( k )

which is about as sensible as your code would look to a Chinaman.
I'm not all suggesting that the language should be dumbed-downed
or deficienized

It would be helpful if you used actual English words ;)
(as is the case with VB), but I think it would be helpful if
actual English words were used in the place of symbols.

Why then did you not suggest:

SetPointer p_k Equals AddressOf OpenBracket k CloseBracket

Or is it only certain symbols that are not very memorable?
I, for one, find "&" more memorable than "k" and "p_k".

My opinion: usability is more important than memorability, for
a programming language. Once I've learned C (or once you have
applied rust-killer to your brain), it is more productive to
work with short symbols than with long words.
The whole "alien language" aspect is what makes C++ so daunting
for beginners. To a person who doesn't know C++, or who is rusty,
a C++ source code file looks like horribly complex gobledygook!

Be glad you've never tried to learn Perl.
Little do they know though that we C++ programmers read through it
as easy as our native language... just so long as we're not rusty!

Nobody ever gets rusty at their native language.
Because we use symbols in C++, if we go a good deal of time without
using it, we become horribly rusty.

I don't. Buy a C++ book and learn it a bit better!
Maybe someone out there has made a parser to change symbols into
words and vice versa?

#define is your friend. (But don't expect anybody else to
want to work on your code).
 
D

Dave Rahardja

Why then did you not suggest:

SetPointer p_k Equals AddressOf OpenBracket k CloseBracket

I've just had a COBOL flashback. Cold sweats!

Be glad you've never tried to learn Perl.
;^D



I don't. Buy a C++ book and learn it a bit better!

To the OP: I think the secret is to think of the symbols as _part_ of the
language, just like words. If it helps, you can pronounce the symbols as
though they were words, just like you might do with mathematics symbols.

The use of symbols is important because they concisely express relatively
complicated ideas. The challenge is to find a balance between readability and
conciseness.

Compare Python to Perl, for example: Python is readable but tend to be more
verbose, while Perl is concise but can be a challenge to decipher; and both
languages are somewhat similar in capability.

-dr
 
?

=?ISO-8859-15?Q?Juli=E1n?= Albo

ToM_tOm said:
Compare this to Visual Basic. If you could do something like "p_k = &k" in
VB, then it'd probably look like:

SetPointer p_k = AddressOf( k )

, which we English speaking humans can understand very easily!

I'm not all suggesting that the language should be dumbed-downed or
deficienized (as is the case with VB), but I think it would be helpful if
actual English words were used in the place of symbols.

You can do it easily:

template <typename T>
inline T & AddresOf (T & t)
{
return & t;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top