Showing posts with label basic interpreter. Show all posts
Showing posts with label basic interpreter. Show all posts

Monday, September 17, 2018

Home Computers and Line Numbered BASIC Interpreters

If you're like me, you started using computers back in the early days when a computer was something you could hook up to your television set.  Turn it on and immediately it would greet you with something like:

Super Duper BASIC v2.02
28467 bytes free
Ready
_

This was the most typical way a computer would start up.  You are then in BASIC, ready to explore programming more or less instantly.  There was nothing to download or install.  There was no antivirus software to harass you before you could proceed, and you did not need to boot your computer from a hard disk, log in, and then use a menu system to launch your programming language.

Your computer came with a book (yes, really) that started you on your programming journey in friendly terms, and happy looking cartoons.

In a few minutes you could have a simple example program from the book typed in and then typed RUN to see it in action.  A couple of hours into the book and you were a budding programmer.

There was no need to learn large volumes of functions just to put anything on the screen.  Was it primitive?  You bet.  The good thing about it was that mastery was attainable without going to school.

With computers today?  Forget all that.  I guess you could say that only the most determined people will learn to program now because they have to go exploring into the expanses of the Internet to figure out how to start.

Home computers.  Yup, we called them that before the term personal computer became popular.

The built in BASIC language in these machines is like clay in your hands.
  • Turn on the computer and start coding in seconds.
  • Execute code without a program.  Just type some code by itself and press Enter.
  • Add code to your program one line at a time and just type RUN to try it.
  • Stop and restart a running program.  Change it and resume running.
  • Type a program in from one of many popular magazines.  Learn to program by changing the program to make it your own.  Copying and pasting code from the Internet is just not the same.
People like to say unkind things about that era and all the messy looking code that BASIC encouraged.  I say that interpreted BASIC was a natural fit for that time.  It probably would have been hard to do it any other way.

I think that there are lessons to be learned from all this.  The kinds of computer literacy that we have today is only enough to use the computer to consume.  We only think that we know how to use the computer, but we really only know enough to run apps.

How do we make the real power of computers accessible again?  How can we restore the immediacy and interactivity of a BASIC interpreter to the end user?

You know what?  You can go on ebay and just buy one of these computers.  Prepare to be charmed.  :-)

Sunday, September 16, 2018

Python - The Emperor's New Clothes

I recently posted a couple of examples of a starfield simulation written in BASIC.  One of these was written in Commodore BASIC for the VIC-20.  The other was written in Liberty BASIC for Windows.

BASIC gets a lot of flack from people with a certain kind of snob factor (yes, you know who you are).  And there is the infamous comment by Edsger Dijkstra, and BASIC has never lived it down.  Nowadays when you see people discussing what is the best first language I probably see Python mentioned most.  In these forum discussions someone always seems to snidely denounce BASIC as that old thing with the GOTO and the unreadable spaghetti code.  They don't seem to have a good reason to recommend Python, except that it isn't BASIC.

People also recommend C and it's derivatives such as C++ which also has GOTO.  So go figure.

Wait, here is something scandalous!  On the Python Software Foundation website, in their design and history FAQ page, they actually answer the question about why there is no GOTO in Python by encouraging people to use exception handling as a hack to simulate something like GOTO!  Ummmm.   See for yourself.  https://docs.python.org/3/faq/design.html#why-is-there-no-goto

Okay, getting back to the starfield simulation example.  If you look at the version of the starfield simulation written in Liberty BASIC, it addresses some of the things that BASIC is frowned on about.
  • GOTO - Uh oh, not really.  There is one GOTO, but in this case I'm not sure a WHILE/WEND forever loop is really better, so...  The Commodore BASIC version has three GOTOs.
  • Structure - The Liberty BASIC version uses control structures properly the way modern languages do.
  • Line numbers - Liberty BASIC programs do not require numbers.  You can give your routines meaningful names instead of numbers.
Okay, let's be frank.  Liberty BASIC was not the first version of BASIC to solve these problems.  There are many BASICs with modern features, and so it isn't fair to criticize BASIC as being a bad language for beginners.  BASIC has been a proper language for teaching good programming practices for a very long time now.

What do you think?  Comments welcome.  :-)