Wednesday, April 30, 2014

Homage to Basic

It's been a while...it has a sense of the old. You see it, but when you see the Beginner's All Purpose Symbolic Instruction Code, it transforms everything around it. The letters become big and blocky, the monitor becomes concave, and all computers are grey. The keyboard feels heavy and has a personality, oh how I yearn for the times that Basic brings.

Like your first fling, you can't never forget it. I would say it hasn't aged as well as I would've liked it to, but it will forever a memory on most developers. Ah these younglings who have never experience such an era. It's not even the language but what it meant to program back in the 80 and 90s.

...You could really understand a computer...

There was so little code between you and the metal. A single-task OS (sometimes not even that), a bunch of interrupts, a CPU that could only process an instruction at a time, back when 640k was too much. You could actually directly interface with the serial port and send bits (I still remember being ecstatic when I managed to turn on a single LED using one of the bits for the Parallel port by "printing" from basic to LPT1. It was a time of discovery, of wonderment and amazement. Of course that's still happening, but let me indulge in the old-curmudgeon "Back-in-my-day..."

... You really really understood a computer...

Fat32, bootloaders, sectors, all of it. Today is very very hard to know what happens on the CPU. I work on an area where understanding the complexities and intricancies of the hardware pays large dividends. I'm talking about CPU L2 cache lining, evictions, branch predictions, concurrency, Main memory access semantics vs GPUs. And I claim that I don't know today's architecture like I knew the 8086 (or the Apple II c) for that matter. And don't even let me get started with USB vs Serials and all the billions lines of code between me and those pesky transistors.

...You really really manipulated a computer with BASIC...

And it was great! You didn't have to learn assembly to make a computer sing. I remember installing the Speech Synthesis card for the Apple 2 and making it read aloud what I typed. What a thrill that was. There was no software for it. You had to program it yourself, the manual came with instructions on what were the commands to send to what memory addresses.

I was untrained and unrefined and plain when I started programming BASIC. If anyone would looked at that code today, they would scream. It would have been the perfect example of many things that shouldn't be done.

I was 9. and I was a Deity

In the christening that all developers go to, I still remember writing

10 print "hello world"

and then I added my first hack

20 goto 10

I was hooked

My flavor was the apple II c basic, and how I was so excited. Only 5 1/4 floppies, no hard drive. Terminal green screen, and not a care in the world. I would create silly things, a birthday card maker that printed text in those never-ending paper reams. The tick-tack of the dot matrix printer head still lodged in my memory. I remember creating my first bootable program...it was a matter of renaming a .bas a certain way, Android still does the same thing today ;) and making it list the content of the current floppy drive at boot up.

I remember discovering how to center things on the screen...there was no internet back then, and books about programming in my neck of the woods were hard to get. How excited I was when I discover you needed to take the length of what you wanted to print, divide it by two, and then subtract it from the (halved) number of characters that you could fit in a line. Then you printed that # of spaces, and tagged what text you wanted. It was my first empirical algorithm.

I remember how I tried in that tight REPL until I got it.

Ah, those days.

When I moved to the x86, what a change. It had color, it had a better basic, it had peek and poke, and bload and bsave, and a hard drive. It has a shell, and TSR programs. Oh the days. I remember how I started creating more and more unrefined, crufty, yet cool as hell programs. The first one was simply just changing the Video Mode, oh lusty CGA, and then putting pixels on the screen. I finally learned about GOSUB.

My biggest memories were from when I decided to take my first consulting gig. I created a BASIC program that would show the different maps of my native country (Ecuador). I remember mapping every single line on the screen with line commands and point commands. I didn't looked far ahead as to use files or image formats. It was all raw hand-coded BASIC.

I was 14

I remember how I panicked because the original basic could only hold so much memory, and my subroutine to draw one last map put it over the top. I couldn't save nor load it. There was no github, no svn, nothing. I freaked out for twenty minutes until I realized that I had made a copy for a demo the day before in a 3 1/2 inch floppy. I lost a day's worth of work, but I was so relieved it didn't matter.

I remember learning empirically how to create sprites. I have so much flicker since I didn't know nor understood about double buffering, yet it was my first video game. A sprite moved, and you have to shoot it down. Spacebar fired the missile, and the pattern of the enemy was so predictable. Yet I showed to anyone who would peek in my room. Those days I would eat lunch next to my computer while I tinkered in basic. It took a very persistent mom to drag me to the outside world and get sunlight.

I also remember creating what could be the predecessor of music-typing. I remember learning the piano and sometimes not feeling the pattern the music sheet was telling me to play. So I created an actual graphic music sheet composer that would play on that single-tone speaker, it even have legattos, and ":" and tempo. It was the most complex piece of code I created... Once I typed the last command I didn't save, went for lunch, and then got distracted. When I came back my sister has rebooted the computer (ok it wasn't mine, it was a shared computer for the whole family), and I lost it all...

Those are the experiences that shape you...

I was so angry, for the whole of two hours. Fuming, thinking this is impossible, I can't do it again. But then remembering the end-result that I achieved once. It was still there, hinting at the greatness that I enjoyed for 20 minutes. it was possible to do it again.

And I did.

 It took almost 6 hours of continuous programming (my first hack-a-thon I guess). But it was greater than my original one...how couldn't it be, I discovered what I was doing wrong in the first one, how to make things simpler. And I immediately saved three copies, and learned the one shortcut that I will always from then on take the time to learn. F5, Alt-F-S, and today Ctrl-S. I typed the longest song that I needed to play for my piano class. I showed to anyone with a pair of ears that would listen. How proud I was. It was me, it was the computer playing for me, what I told it to. I made it do that.


Is so different than today. I stayed next to my computer to create video games, while today most kids stay next to their computer to play them (I know, I'm about to say 'getoffmylawn').

Basic was my first love. The reason that I became a Computer Scientist, there was just no other way. Before that day I remember saying "I want to be an Architect", or a "Mechanical Engineer", a Business Owner, I played with Legos, played with the Atari, played the piano...but that Apple II C and Basic sealed my fate. I felt like a deity. A Puppet Master that could do anything I wanted. I can change things, and I learned how to change things. It was so intoxicating, so simple back then. There was no object orientation, no dependency inversion, no unit tests, no databases and ODBC drivers, no IDE, no shell, no design patterns, no mouse, no Path (or classpaths) no installers or configuration settings, nor registries, there was nothing but you and the pureness of the machine in front of you...


It's been 26 years since my first line of code was written, and when I close my eyes I do miss Basic. A clueless girlfriend, always meaning well, but get tangled so quickly in those goto statements, and really didn't have too much to work with. I remember when I dumped her for C++. Such a sleazy, sexy and screwed-up language. I guess a guy is always interested in bad (language) girls...


I find it funny how I settled for the down-to-earth Java spouse, C++ was really wrecking my life. Still my first love will always be there and be special to me.

Happy 50th Birthday BASIC.

Freddy

No comments:

Post a Comment