Thinking About Programming

Do you ever think about programming? Rather, do you ever think about how you think about programming?

You have to start somewhere
Indeed, the whole reason I got into computer programming in the first place was because I wanted to program games. It was circa 1991-1992 when I got heavily interested in programming computers. 286 CPUs running MS-DOS represented the platform I had access to. I was trying to transcend GW-BASIC and learn Turbo Pascal and Turbo Assembler. A little game called Test Drive III was one of the most remarkable titles I had seen running on this type of hardware at the time. Not only did the game do polygonal 3D graphics but it had sound support through various sound cards or the PC speaker.



At the time I was trying to understand how to do decent 2D graphics programming as well as audio programming (background music, sound effects). I had access to a friend’s Sound Blaster and after lots of research (solid, useful programming data was notoriously scarce) and plenty of trial and error hacking assembly language, I finally got the Sound Blaster to make a few blips. I probably still have the code in my archive somewhere.



I didn’t write this post just for my own sentimental programming nostalgia; there’s a punchline here: I remember feeling briefly elated when I got those first sounds out of the speaker. Then my mind quickly turned to more practical matters, like how could I parlay this prototype into a sequencer that played a musical track in the background of a game? The only solution I could think of at the time was that it would be necessary to cleverly time the game engine so that, in between processing user events, rendering graphics, and dealing with other game logic matters, it would be necessary to periodically update the correct sound registers to play the next note of the song. I.e., in modern parlance, handle everything from a single program thread.

I never got around to writing an engine which could do that. Then, somewhere along the line, I learned about interrupts, a mechanism which would provide a much better way to manage music playback on such a platform. But the aspect that haunts me now is the fact that, given enough time coupled with “just enough knowledge to be dangerous” with which I was equipped, I probably could have made it work. It would have been ugly and fragile, but I wager I could have put something together.

The FATE Connection
The reason I bring this up is that my programming history is repeating itself with the FATE system. All told, I’m generally satisfied with the architecture of the parts that build and test on the client and ferry the data over to the server, though I could always stand to learn more about SQL. The weakest part of FATE is the front end, the web interface (although the process runner is a close second). This is most unfortunate because this is what represents FATE to the public.

For many, many years, my concept of web programming has been typified by this CGI script pseudocode:

if GET_CGI_VAR("HeyIsThisThingOn")
  parse_some_more_input_vars()
  query_database_with_vars()
  print_basic_html_table()
else if GET_CGI_VAR("YouSuckGetOffTheStage")
  parse_some_other_input_vars()
  query_database_with_vars()
  start_seeing_a_pattern_here()
else if GET_CGI_VAR...
[...]

Seriously, that’s what the main index.php script for FATE looks like, and it hurts, yet I still made it work. For a long time, the thought of a web app even on the scale of, say WordPress (running this blog) or, for crying out loud, Wikipedia, absolutely blew my mind. How on earth do multiple people collaborate on projects like that, and carefully test them, and make them just generally work for so many people? This wonder was predicated on the notion that web app code generally looked like the filth above.

The connection with the first part of the post is this: Given enough time, I could probably make a webapp on the scale of WordPress using the code as seen above. But somewhere along the line, I realized that there has got to be an easier way to do this stuff. Over the past year, I have slowly realized that there are better ways of doing things (beginning with forming the faintest idea of what CSS is and how it relates to websites and understanding a tiny amount of JavaScript).