Hacker News new | ask | show | jobs
by rbanffy 3512 days ago
BASIC on an 8-bit computer is a bit closer to the underlying hardware than C and it's a worthy educational experience. You have to be clever to work with all global variables and subroutines instead of functions and you'll have to invent your own stack to express recursion.
2 comments

In old 8-bit Basic it was, many times, a kind of battle between interpreter and assembly. I would write things in Basic, then see if it was fast enough. If it was not it usually was pretty obvious where the issue was; if the code was complex I would rewrite it to a version that more or less would convert to assembly naturally and then test again. You would have to lose basic pretty quickly especially for games, so in the end (of the 80s basically) I started straight in assembly. And that is what I missed and found again now in limited resource embedded chip programming; doing almost all the actual work in your head and on paper instead of trial and error everything.
> BASIC on an 8-bit computer is a bit closer to the underlying hardware than C ...

Well, that's wrong. There's nothing about BASIC that has anything to do with hardware. If anything it made the computer feel like a rubber mallet when inside that hardware was some real power, if only you had the knowledge to unlock it. I always felt cheated, that no matter how well I knew BASIC my programs would be stupidly slow compared to someone who knew assembly.

C wasn't an option on something like the C64 since there was no C compiler. It was BASIC or, if you were bold, hand-written machine code. The tools were very primitive, very expensive, or both.

BASIC is junk. Get rid of it. Teach proper programming. If you really need to squeeze a lot out of your hardware, and on the C64 you absolutely need to, then it's assembly or machine language.

The point is not being fast, but easy. BASIC has GOTO and GOSUB, IFs (which take the place of conditional jumps), no stack (that you can use yourself), no named functions (except branchless one liners) and a meager set of primitive types which are handier than the 6502 registers. Ever tried floating point on a 6502? Even with the routines in ROM, it was all pain and suffering.

I am sorry you had such a bad experience with BASIC, but, for teaching the very basics of programming, it was a useful tool. In order to teach assembly you'd need a text editor, an assembler and a floppy disk. BASIC came up when you powered your machine on.

I used Aztec C on the Apple II and, while it was painfully slow, it was a reasonable C for the time and, IIRC, it had a C64 version.

To be specific, I'm talking about today and how BASIC is an anachronism, not unlike making your own natural pigments just to learn how to paint.

BASIC was nothing but bullshit, it taught me nothing other than computers are obnoxious and difficult to use. I spent several years "learning" how to program in BASIC, later QuickBASIC, and the stuff I cranked out was atrociously bad. The only excuse I have is that I was coding like they did in the magazines I bought, their code was a disaster as well, and I had no way of knowing there was a better way.

It was only when I switched to Pascal (via TurboPascal) that I realized how to program. At that point things started to make sense, and no longer was I feeling like a third class citizen: Programs in TurboPascal would run very quickly compared to BASIC. They were compiled. While the performance wasn't on par with C, it wasn't nearly as hard to get right as C was.

I wouldn't recommend Pascal today, but there's other languages that are as good or better.

Today there's absolutely no reason to teach BASIC as an introduction to programming. You're only going to hurt people.

Would you have realized how Pascal is better without struggling with BASIC first?
Would you have realized how C is better without struggling with machine opcodes first? Would you have realized how x86 is better without struggling with a 6502 first? Would you have realized how DRAM is better than struggling with drum memory first?

You can start anywhere if you like what you see and feel motivated to learn more.