Thursday, September 20, 2007

My First 3 Lines of Code

When I was really young, my life ambition was to be a magician, followed by being a chef (which I did become briefly, as I mentioned in 'about me'). It was only in my early teens that I had my first hand experience with a computer which has piqued my interest in wanting to become a software hacker, ultimately which is now my career.

The trigger of it all, started from my first experience with a computer, during a school excursion I had to the Singapore Science Centre when I was 11. I remembered that it was an IBM PC computer, running a text-based graphical application with colours on a CGA display, which was probably quite an expensive model those days, given that computers usually came with green tinted monochrome monitors.

There was already an application running on the computer, which I only vaguely recalled that it had something to do with elevators. It was some sort of application teaching about some mathematical concept, using elevators as an example. How boring was that?!

Being the mischievous kid I was, rather than using the application 'correctly', the first thing I instinctively did was to start sweeping my palms across the keyboard, seeing if I could cause the application to do something that deviated from standard behaviour. By deviated, gee, I probably considered crashing the application as satisfying my criteria!

(Microsoft's GW-BASIC, the closest screenshot to what I remembered. Courtesy of Wikipedia)

But I got more than what I bargained for, as my random sweepings invoked the BASIC interpreter, which was built into the PC. That was a curious sight for me, given that the only thing that was visible was a flashing cursor, and a function menu at the bottom of the screen. I kept banging on the keyboard (rather violently), which really didn't do any much more, besides producing random gibberish on the screen.

It happened that there was a young man with his girlfriend, both probably in their mid-20's, who saw what I was doing, and walked towards me. I gave the guy a sheepish smile, thinking that he was going to give me an admonishment. Instead, he took over to the keyboard and typed the following:
10 INPUT "What is your name ?"; A$
20 PRINT "Hello "; A$
30 GOTO 10
Finishing that, he executed the application, and asked me to type in my name:
What is your name ? Vincent
Hello Vincent
What is your name ?
That was the first time I saw code and I was immediately hooked. The guy gave me a smile and walked off with his girlfriend, leaving me to tinkering around the with application.

While there's really not terribly much that I could code without any more knowledge, but even with that limitation, I did try writing my own variation of the application based on the only 3 instructions I knew and wrote a really lousy version of a text adventure game that I got bored real quick.

It'll be a few more years before I got to learn more programming, but that was how I've learnt my first 3 lines of code.

So what's your story with your first coding experience?

2 comments:

Anonymous said...

I think my first coding "project" was writing a "Wheel of Fortune" game on Mac using Hypercard in high school...

Mmmmmmemories....

x said...

Hypercard? You lucky bastard, to start off with a graphical GUI programming interface.

I can see why you grew up to be a Mac Fanboy now :P

Post a Comment