Friday, February 20, 2015

Today’s BASIC Is Not Your Father’s BASIC

A post at Doug Peterson’s blog (A Different Time) sent me to a site that has a collection of old BASIC programs. And by old I mean the 1970s. I remember many of these programs as I was starting my programming career back then. One could take these programs and type them into their computer and run them. It was fun and we learned a lot. But I’ll tell you the language has changed a lot since then.

image

For example back then a comment was a REM statement. Short for REMARK of course. Today most version of Basic use a single quote to flag a comment. Today variable names can be of any length while back then one was limited to a single letter followed by a number or numbers. Variables were declared using a Dim statement as they are today but the type was specific by a $ for string, a % for integers and floating point numbers had neither of those special symbols. One can’t use them in variable names today of course.

Originally BASIC did not have subroutines as we know them today. We had the GOSUB statement which branched code to a line number (we don’t use line numbers at all any more) and a return statement brought the flow of execution back to the line after the GOSUB. There was no parameter passing and variables were basically global. There were functions of a sort. Those were defined in a single line like this:

180 DEF FNM(X)=X-8*INT((X-1)/8)

The functions were all named FN followed by some letter. Return values were loosely typed. It sure was easy to use though.

I’m looking though these old projects for ideas for updated versions to use with my current students. Some I will use with Visual Basic and some with C#. And just maybe some with TouchDevelep. Some things never get old.

Today’s versions of BASIC are both much more powerful and much more complicated than those early versions were. Stronger types, more powerful functions and subroutines,  lots more flexibility in identifier names and real error handling.  Small Basic is an attempt, and a good one, at returning in part to those simpler days.  It still has more power and complexity but many things are much easier. Visual Basic is a very powerful professional level language and development environment. It too makes some things much easier than they were “back in the day” but in other ways the complexity can be intimidating and even frustrating for beginner.  It seems to work well with my high school freshmen though as long as I stick to the basics.

I wonder how many people judge the idea of BASIC based on thirty (or forty) year old versions of the language? Today’s versions, especially Visual Basic are every bit as powerful and modern as Java or many other popular languages. And still easier to learn. I still like them.

4 comments:

Mike Zamansky said...

10 print "I haven't played with small basic"
20 print "but the simplicity is one"
25 print "of the reasons I love Scheme"
30 print "and C for that matter"
40 print "although C has all the memory nastiness"

Hey -- doesn't an old basic program remind you of a tweet storm.

We do have to be careful of our biases with the easy to learn thing.

So many times, I have a student say of another student's work "there's an easier way to do it."

I have to point out, that if the "easier way" were apparent to the student at the time, he or she would probably have done it that way. What's easy and sensible for me isn't for someone else.

At first glance, I don't think small basic is for me but that doesn't mean it isn't great for someone else.

Alfred C Thompson II said...

I struggle with Scheme. I could probably get it after a while but haven't been motivated to find the time.

Mike Zamansky said...

Maybe we can all agree to the following:

We should design a DnD version of Whitespace and teach that in all of our intro classes :-)

Garth said...

Basic is sort of a timeless language. Its variations will be around for years. It is an easy language and easy is the key to the future of programming.
I love languages that can get a kid programming something quickly and can then keep them interested with fun projects that will teach them the basic concepts of programming. Small Basic is such a language. No overhead, intellisense, turtle and lots of simple examples. It has a real flat learning curve. Kids can be drawing turtle graphics in 15 minutes. And having some fun doing it. It runs on pretty much anything and a 10 year old can install it. VB is good except for all the file management stuff that goes with it and there is lot of magic code for a beginner.