Project #37

Saturday, March 27th, 2004

What would I be doing…

Tuesday, March 23rd, 2004

…if the personal computer never happened? What if silicon chips cost tens of thousands of dollars to produce, thereby restricting computer ownership to governments and the stinkin’ rich?

To be honest, I have no idea what I would be doing. When I left high-school in 1990, I wanted to be a graphic designer [more specifically, an illustrator]. I studied Visual Communications for about 3 months before dropping out. I didn’t drop out so I could concentrate on working with computers, I just dropped out [I didn’t even have a computer at that time]. I guess I was bored. And my charcoal sketches were really quite crappy.

My best guess at my parallel universe vocation is that I would be an aspiring writer, since I’m almost that now. If it wasn’t for this log I would probably be writing a tortured few pages every 6 months or so, in either screenplay or novel form, and hating it. The pages would sit in my drawer, and reading them a few weeks later I would really really really want to throw them away.

So it’s probably lucky for me that the PC took off, and the internet too. Programming provides pretty much all the creative outlet I seem to need.

For example, if I feel like making music, I can do one of two things:

  1. sit down at a piano and wish I’d had a lesson, or
  2. sit down at a computer and write software that creates abstract and utterly unique melodies based on algorithms which I just make up.

Even if I’d had a few lessons, I doubt that I could come up with anything particularly interesting on a piano. But after just a few hours of messing about with computerized composition, I guarantee that something interesting [if not particularly pleasant] would emerge.

Review: Hyundai ImageQuest Q17 DVI LCD 17″ Monitor

Sunday, March 21st, 2004

I really liked the look of this monitor [with no curvy bulgy bits to speak of] and I was especially impressed that the DVI version appeared to cost only slightly more than the analogue version (AUD$680 for DVI version, $670 for Analog). This seemed like a pretty good deal, since other manufacturers seemed to be charging around 20% more for their DVI models.

Read the rest of this entry »

The Joy of Debugging

Tuesday, March 16th, 2004

Debugging software can be a bit like looking for your keys: More often than not, after hours of cursing and overturning furniture, you’ll find them in a really obvious place, where you could have sworn you had already looked.

There are no prizes for spotting the problem with the following code [especially if I tell you that the main symptom was incomplete or broken lines being drawn]:

void DrawPolyline(int nPoints, const Point* p)
{
for (int i = 0; i < nPoints-1; i++)
DrawLine(p[0], p[1]);
}

Finding this bleeding obvious error took me a whole day! That’s a day of my life, which I will never get back.

[for the non-programmers, the error is that even though I create a loop to draw each segment of a polyline, I simply redraw the first segment over and over again… an easy error to make, but normally it would be detected almost immediately]

Sunday, March 14th, 2004

Must read/view/see:

  • Life After the Video Games Crash - a surprisingly credible assessment of the state and future of video games. It’s funny because it’s probably true!
  • Teen Girl Squad - an ongoing animation series, detailing the everyday experiences of four teenage friends. It will make you laugh and cry!
  • Robert Rodriguez’s incredible commentary on the … an inspiration to 30-something would-be artists everywhere [to get off their fat asses and actually create something, without agonizing about finding the perfect idea/form]

I try to avoid doing too much "Check this out!" style linking from this blog, simply because my readership is small and usually my links are from other sites anyway (like BoingBoing or SlashDot). But sometimes there are things which I really think need to be seen by everybody, for their entertainment value or insight.

Google is your friend…

Friday, March 12th, 2004

Ask Google, Stupid!

And if you are a developer, so is . Too often I forget this, and spend hours tearing my hair out trying to sort out some astoundingly irritating link error, only to find that a solution is waiting for me online, if only I would enter the error text into Google.

Seriously, it is worth sticking a post-it on your monitor which reads: Ask Google first!

Whose dumb idea was this?

Saturday, March 6th, 2004

Since getting my new machine I have managed to inadvertantly power it down twice and send it to sleep once, all because some bonehead decided that the PrintScreen, ScrollLock, and Pause keys should be replaced by Power, Sleep, and WakeUp keys. I mean, it’s not like anyone was using those keys anyway…

I am also now constantly hitting PrintScreen and ScrollLock in their new locations (where Insert and Home used to be), which is very annoying as well [though not quite as bad as shutting down your computer without meaning to].

The Hobbyist

Saturday, March 6th, 2004

As someone who believes that it is important to give people an accessible path to programmin, I am sympathetic to Kathleen Dollard’s article: Save the Hobbyist Programmer [to which there are also some interesting responses on Rory’s blog]

At this point I should mention:

  1. I am not formally trained.
  2. I started writing software because I found it interesting.
  3. I am somewhat bothered by the modern notion of programming as a sort of glue, continuously integrating 3rd party modules and APIs.

You see, even though I have worked as a programmer for more than 10 years, I still very much identify with the hobbyist mindset. Having access to inbuilt languages like BASIC on the old 8-bit machines, and then later having QBasic bundled with MS-DOS meant that I, a lowly user, could take my ordinary computer and make it do something it didn’t already know how to do. I could make geometric shapes bounce around the screen, or pseudo-random notes play through the tinny PC speaker.

So why can’t you sit down with a fresh XP install and do the same?

Javascript fun Well, you sort of can. If you know where to look, you can still write code and execute it, either in JavaScript to be run in a browser [click thumbnail on right] or perhaps as a VB file to run under Windows Scripting Host [I’m not 100% sure you can do this with a fresh install], but there is no IDE, and no useful debugger. Install MSOffice and you will get an editor for your VBA macros at least, but MSOffice is not exactly cheap, and [IMHO] it’s a lot less fun writing a macro than a program. The first feels like tweaking, the second… creation!

A final word to the hobbyists: don’t be put off by professional killjoys who may have never bothered to make a ball bounce or a speaker beep… Programming can still be fun.

Multithreading — avoid if possible!

Wednesday, March 3rd, 2004

Discovered yesterday the cause of an extremely intermittent bug in JujuScript was not in my code but in my project settings: I had neglected to link using the Multi-threading CRT libraries. In English this means that even though I was running multiple threads which each were doing lots of small memory allocations, these threads were calling functions written for single threading only. The result is that periodically there would be a clash resulting in a very confusing exception which I was going mad trying to trace. So developers, watch out for that one.

Interestingly, now that I have corrected the oversight and got script execution running in its own thread, I am wondering if I even want to do it this way anyway. There are so many ‘gotchas’ with multithreading that it should really be avoided if humanly possible. A few things which make multithreading less attractive:

  • Multithreading can be a lot more work, and has the potential to transform your orderly program from a logical state machine into a horrible non-deterministic exception generating machine.
  • Sometimes a low level function needs to access global or static data, and it’s a bit frustrating having to talk to what I would consider "high" level functions [ie Win32 functions] to handle the threading.

    2 intensive tasks run sequentially on my machine take just over 7 seconds, with CPU load rated at 50%. The same tasks run concurrently take 8.5 seconds, with CPU load rated at 100%. It seems that the overhead of context switching still far outweighs the performance benefits of HyperThreading ;)

  • Even on a "Hyper-Threading" processor, you will suffer a performance hit for doing 2 intensive tasks concurrently instead of sequentially. When I run a single-threaded task on my P4-HT processor, the task manager rates my CPU usage at approx 50% (because an HT processor looks to the system like 2 separate processors, and since a single thread can only run on one, only 50% of CPU power is being utilized). If I run 2 such tasks concurrently then the processing is spread across the 2 CPUs, utilizing 100%… BUT… the whole thing still takes more than twice as long!

Ticky-Tacky-Toe

Wednesday, March 3rd, 2004

Click here to download an EXE which plays tic-tac-toe automatically fullscreen. By default the thing will play itself. Pressing X or O will select a side and begin manual play, with moves being selected using numeric keypad. It is in fact possible to beat this program, since I didn’t get around to programming an intelligent computer player. Quit the program by hitting Escape, Enter or Alt-F4. There is no install, it’s just a single exe and you can run it from anywhere.

Remember, this is an executable file, which means you are trusting me to not put nasties in there, and I can only assure you that to my knowledge this program will be safe for you to run. Even though it is a JujuScript program, I am posting it as an exe because JujuScript is not yet mature enough to post interpreter and script separately, although sometime down the track that is what I plan to do.