View Single Post
Old 24 August 2015, 03:52   #301
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,070
Quote:
Originally Posted by Mrs Beanbag View Post
why do you keep bringing up C even after i've said i'm not advocating C. There are loads of things wrong with C but curly braces are the least of it: they may be butt ugly but they're nothing complex or difficult. I wouldn't advocate C for a beginner mostly because of the pointer arithmetic, rather than the syntax. JavaScript, however, is perfectly viable as a beginner's language, for all its quirks.
Once you get used to curly braces (and learn to type it if you have a non-English keyboard), they may seem simple enough, but they also take some effort for the brain to decode.

Quote:
Originally Posted by Mrs Beanbag
But let's think about what curly braces actually do in C. They delineate code blocks. That is a necessary thing because a loop or a conditional statement (or whatever else) has to have a body. Other languages do it in different ways. Python does it just by indentation, which forces the programmer to write in a neat way, and one can immediately see the structure of the code without having to read any of the keywords.
I had my doubts about trying to teach a beginner programmer the art of Python indentation, but I think I've come to the conclusion that it makes sense. C programmers tend to indent their blocks as well, even though they have their braces, so why do both when one will do?

Quote:
Originally Posted by Mrs Beanbag
BASIC, on the other hand, has no consistent way to delineate a code block at all. There is no way to tell that a pair of statements encloses a block other than by knowing about those statements already, thus intertwining syntax and semantics. Bad enough that there are umpteen different ways to start a code block, each one has a special way to end it as well, so you have to learn symbols in pairs... IF...END IF, FOR...NEXT, WHILE...WEND &c.. the human brain might be able to cope with this, but if it requires a complex parser it is not a simple language.
That is much preferable to { ... } if you ask me. You start a block, and then you finish it with a matching terminator. It removes some of the confusion when sorting out the end of a long program block, which in C might end with }}}}} but in BASIC might end in ENDIF : NEXT B : WEND : ENDIF : UNTIL X>10

Of course, the exact names of these statements may be haphazard, and I think it took me fifteen years to understand what WEND meant. COMAL tries to sort this out by unifying the format of the block terminators – e.g. FOR…ENDFOR, IF…ENDIF, WHILE…ENDWHILE and so forth.

Quote:
Originally Posted by Mrs Beanbag
Megol already mentioned some of the other things i was going to say, but in addition to that, there is even more "ascii garbage" that BASIC syntax typically uses. For instance, arithmetic operators and parenthesis. For instance, one can write:
Code:
Let A = (B+C)*2
That seems nice and clear to me, despite containing non-alphanumeric characters, but maybe you would prefer something like this:
Code:
Let A equal calculate B plus C first times 2
I jest, but, this is more-or-less how Smalltalk works. Or if you really like parenthesis, you might like Lisp, which is about the simplest programming language there is aside from Rule 110. I didn't say "easiest".
There is a difference between the symbols taught in the first years of primary school maths, and those that only mean something to the parser. I'm not suggesting COBOL expressions like MULTIPLY A BY 3 GIVING B in order to avoid the use of non-alphabetic characters. That's why C-inspired languages use a=2+3 when the proper C way should be a=add(2,3).

Lisp may not be so bad, though. When I took a programming course in school at 17, the first teaching language was Scheme.

Quote:
Originally Posted by Mrs Beanbag
But that's not even the worst of it. I think the worst of it is that you can't really talk of "BASIC syntax" at all. Every BASIC statement has its own syntax. Let's just look at a simple print statement:
Code:
Print "There are ";n;" sheep"
Let's just accept that a semicolon is a fine thing to have in a statement, but what does it MEAN? The answer is that it doesn't mean anything outside of a Print statement. One cannot do:
Code:
Let A$="There are ";n;" sheep"
because a ';' is not a string concatenation operator that works on the argument passed to Print. It is only part of Print's special and unique syntax. Well you could define it as a string operator, and that would be nice... but you'd have a job trying to work out what putting a semicolon on the END of a string means (although we all know what it does on the end of a Print statement).
Let's face it, PRINT statements will always be a bit special, because they are a bit special. Everyone, from "hello world" to a senior programmer's debug output, uses it. It can afford to be a bit special. Even "printf" is a special case, because usually functions don't take varying numbers of arguments.

One could wish for a much better string handling in BASIC, but then again one can wish for that in any language that doesn't play on the same level as ARexx.

Quote:
Originally Posted by Mrs Beanbag
And then there's the ascii-garbage equals sign, '='
Code:
10 Let A=5
20 If A=5 Then Print "A is 5"
30 For I=0 To 10 Step 2
...
The equals sign means something different in every one of these statements. The meaning of = on line 20 is responsible for so many errors made by people who learnt to program in BASIC and then graduated onto a more sensible language.
I don't see what's so sensible about using "=" as an assignment operator in the first place, or what's so sensible about using infix notation when every other part of the language puts arguments at the end.

Quote:
Originally Posted by Mrs Beanbag
But on the 30th line it is difficult to know what it means at all. I know what it does, but it is literal nonsense. In any case, one cannot do:
Code:
Let A=0 To 10 Step 2
For I in A ...
Which is a shame, because that would be hella cool. One could it imagine it working also on arrays and strings...
Code:
Let A="Hello world!" : REM Type inference!
For I in A:
   Print I
Result: each character of the string on its own line...
That's nice, but what you're suggesting is one of Meagol's beloved BASIC offspring. It's still got the same basic accessibility of BASIC, or Python if you wish.

Quote:
Originally Posted by Mrs Beanbag
But alas, it was never meant to be, because BASIC was invented in 1964 when "real" programming was only done in assembly language and none of the staple concepts of modern programming had been invented.
Depends on what you mean by modern. Structured programming was invented around 1959-60 with ALGOL, and there was at least some kind of Lisp.
idrougge is offline  
AdSense AdSense  
 
Page generated in 0.08929 seconds with 9 queries