View Single Post
Old 19 August 2015, 12:18   #245
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
Originally Posted by idrougge View Post
I certainly think it is, especially put in the context of its time of invention, or compared to mainstream languages used since then. It contains a minimum of syntactic clutter and pandering to a preprocessor. People who like curly-braces may not agree about the syntactic clutter bit, but curly-braces are syntactic clutter, and so is end-of-statement markers. For teaching a beginner programming, it's better to get to "hello world" straight away instead of having to explain declarations, prototypes, arguments and return values, as one must do in any language inspired by C.
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.

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.

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.

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:
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:
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".

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:
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:
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).

And then there's the ascii-garbage equals sign, '='
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. 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:
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...
Let A="Hello world!" : REM Type inference!
For I in A:
   Print I
Result: each character of the string on its own line...

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.

"It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration" - Edsgar Dijkstra

The benefits you mention are common to pretty much any interpreted language, and there are a lot to choose from.
Mrs Beanbag is offline  
Page generated in 0.09783 seconds with 9 queries