Wednesday, April 30, 2014

Happy Birthday, BASIC!

Happy Birthday 
to the 
Beginner's All-purpose Symbolic Instruction Code

Today is the 50th birthday of the BASIC programming language. As promised, I'm celebrating the event by releasing a handful of programs I've written in a dialect of BASIC.

I've chosen to write these in Gambas 3, a dialect that's only available on Linux[*]. But rest assured, you're not missing much. These are prepared for the occasion on short notice, and all are short of having earned a 1.0 release number, though I'd say all but Tablut are pretty feature-complete.

First up is "Tablut" (Tablut.tar.gz) a Tafl game. Tafle is a genre of boardgames popular among the Vikings, which eventually died out and is now enjoying a bit of a renaissance using re-created rules, as best as the archaeologists have figured them out. This version of Tablut provides a working two-player board, enforces three scholars' interpretations of the rules, and has the world's absolute worst AI (which really is only there to test turn-based play... I haven't had time to actually write a "real" AI).

Next is TimeTool (TimeTool.tar.gz), which I've previously had as an open-source offering on other platforms. It was previously written in Delphi (Pascal). People have asked me when I would update it and fix some bugs. I suppose I just did, so I may wind up back-porting these changes to for the Windows crowd. TimeTool is a very odd sort of duck. It keeps track of the projects you're working on, and very pointedly does NOT track multi-tasking. It helps you determine where you've been spending your attention. It keeps accruing time to tasks even when it's not in memory, so it's great for tracking tasks that require re-boots.

So Long Sam
Then there's So Long Sam (SoLongSam.tar.gz), which is in fond remembrance of an old 8-bit game I once typed in from an issue of Compute! magazine. After re-writing it for this event, I went back and dug up the original. It seems I remember the game as having been much better than it was, and as this version aligns with my memory, it's more than a little bit better than the original. I did sort of mis-remember the premise of the original, so we'll call this one "inspired by" instead of a re-write. Your goal is to simply cross a spooky graveyard in the dead of night without bumping into a tombstone and awakening a ghost or zombie.

Lastly, there's ZenerCards (ZenerCards.tar.gz). This is a little time-waster for people who think they are psychic. It will either definitively prove you ARE or completely convince you that you're NOT. There are three challenges: a PREDICTIVE test, to see if you can foresee the future; a CLAIRVOYANCE test, to see if you can determine that which is hidden in the present; and a TELEPATHY test, so see if you can read (or broadcast) thoughts. My prediction is that whoever you are, and no matter the test, you'll wind up with a score of around 20%... random chance.

I have work and real life and stuff, so I'm a little behind. I've put up quick links. Right now it's just tarballs, but as I have the time I'll put up.rpm or .deb installation packages. As it is you can run off the source once you've got Gambas installed, and executable files are contained in the tarballs.

It's Open Source, of course, of course.

[*] Sorry, Windows users. Gambas 3 only runs in Linux. However, this is a great time to try out Linux for yourself. You can install VirtualBox. Then download an "ISO" image of a Linux install DVD and install it in the virtual machine.

Wednesday, April 09, 2014

BASIC Turns 50

The BASIC programming language is turning 50 years old on April 30, 2014. Dartmouth is preparing to celebrate the day with a series of events on campus. If I lived in the area I'd certainly attend. BASIC has impacted my life in ways more positive than I can relate.
BASIC (Beginners All-purpose Symbolic Instruction Code) is the programming language developed by John Kemeny and Thomas Kurtz that later built Microsoft a programming empire. Versions of the language were included in lieu of operating systems in nearly every microcomputer in the 1980s. The language was later expanded, expounded upon, and otherwise improved to add the ability to use objects and events and structured syntax while retaining its simplistic roots.

I've written BASIC programs on and for the following machines: 
  • a timeshare system which I only knew by its terminal 
  • the TRS-80 Model I, II, and III
  • the TRS-80 Color Computer
  • the TI-99/4 and TI-99/4a Home Computers
  • the Commodore VIC-20, Commodore 64, Commodore Plus 4, and Commodore 128 computers 
  • the Atari 400 and Atari 800XL
  • the Apple II family
  • the IBM PC, in the following dialects:
    • Asic ("almost BASIC", a really awesome little DOS native compiler)
    • QuickBASIC and QBASIC
    • Visual Basic
    • Visual Basic for Applications (VBA)
    • VB.NET
    • LotusScript (Yes, the primary language of Lotus Notes is a BASIC dialect)
  • for Linux in the following dialects:
    • FreeBASIC
    • Gambas
  • I've also had a few calculators (Casio and TI) that used BASIC as their programming language.
Gambas! (click)
Of the modern variants, I do like Gambas best, and make a decent living writing in LotusScript, and the various Visual Basics.

Haters Gonna Hate

BASIC is a language that it's very fashionable to hate.

Edsger W. Dijkstra famously said, "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." Meh. That's a snobbish attitude of the sort that would deride Captain Kirk for splitting his infinitives.

Besides, the criticism is largely obsolete. It's completely possible to write "good" code as defined by computer science snobs. Keep in mind, though, that "good" code isn't always defined by how elegant it is, or how "supportable", or how it conforms to one man's idea of mathematical purity and logical rigor. Often a task needs to be done, quickly, with a minimum of fuss and effort. A "good" program is one that does the job. Often, a few lines of procedural code will suffice to replace a rather complicated object-oriented affair, most of which exists to do nothing but frame the procedure that never required an object in the first place. A good modern Basic (like Gambas) does both, and you get to choose.

In truth, just as the freedom of English produces better poetry than the strictures of Latin, there is chaotic beauty in BASIC that isn't appreciated by coding purists who walk around as if they had punch cards up their butts that they're not allowed to fold, spindle, or mutilate. So beat up on BASIC all you like. Then we can talk about how fat your momma is, just to raise the maturity level of the conversation. ;)

Presents for All!

I think a really good idea for BASIC's birthday is to give away some free programs, written in BASIC. So I'll be doing that. On April 30 I'll release a program written in Gambas. Don't expect too much... it'll just be a nice little program that'll keep you clicking for a little while. You'll be able to tear it apart, look at the source code, see how an event-driven Gambas program works, etc.

Happy Birthday, BASIC!