![]() ![]() The complaint that BASIC leads to spaghetti code is real. I've had the recent fun of transcribing programs from a bunch of different early BASIC languages. The end result is a mess of jumps where the programmer is "emulating" real blocks with GOTOs. The IFs often don't have the concept of an ELSE, and often the only thing you can do from an IF is a GOTO. ![]() In Python where blocks are indented statements, or Pascal where you can make a block of statements with a BEGIN/END.īut many microcomputer BASICs don't have that at all. For example, in C you can replace any statement with a list of statements enclosed in. Us modern programmers are so used to block oriented languages that we assume every language just had them. However, the microcomputer BASICs had big usability problems. The current trend where there's a seemingly bazillion steps before you can write a trivial utility is unfortunate. I love the idea of a language that has the absolute fewest number of decisions between "I need a little program" and being able to share the program with a friend. There are enough variants of BASIC that there's a really nifty handbook with the differences at. (This example is from the BASIC embedded in the Tektronix 4050 terminal). This not-really-a-function, though, simply has no justification whatsoever. Nowadays "weird" syntax has some solid foundational reason why it's useful or important. You can't just PRINT the result directly, because then how would REP know what the string to change is? It's kind of like a function, only with a weird implied variable that only works in an assignment. ![]() So the REP function looks at the statement it's part of, finds the variable that is being assigned to, and uses that as the starting string (!). The result is ABC123DEF - at position 4 (strings start at 1), replace 0 characters with "123". Mind-blowing BASIC example from the 1970's: New versions of BASIC are surprisingly common (heck, I even have one that's gotten some super-nice comments). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |