Archive of March 2008

On writing skills

Posted on 2008-03-26 18:04:25

A year ago around this time of the year, I just started writing my master’s thesis. One of the frequent comments I got from my supervisors was that my writing was too terse, that I was not explaining things well enough, and that the average (CompSci master student) reader would not be able to understand my writing. I was forced to rewrite chapter 4 about half a dozen times before it was at an acceptable level.

Now, a year later, I’m writing a tutorial for Caesar IV’s (quite complex) scenario editor. After having written 18 pages covering the easier parts of scenario editing, I wrote the last set of pages on the advanced topic of scripting events using C#. In the few days since its publication, multiple people have complimented me on my ability to explain things clearly and in an easily understandable way.

I wonder, have my writing skills improved so much over the past year, or am I just not made for writing academic stuff? Or perhaps my main writing strength is in explaining complex technical concepts to non-technical people?

On the usage of & and &&

Posted on 2008-03-21 23:27:51

A few weeks ago, I had a discussion with two colleagues about the use of “&” and “&&” in C#.

The first colleague asked the second whether the second argument of a boolean expression “a && b” would be evaluated if “a” was false. The second replied that “b” would not be evaluated if you used “&&”, but would if you used “&”.

My immediate reaction was: “eh? ‘&’ is a bitwise AND, and should not be used for booleans”. The second colleague reacted to that like: “eh? what’s a bitwise AND?”

After a short discussion in which MSDN was consulted, the second colleague proved to be right. If you think about it, a boolean is (conceptually) just an int of length 1, and if you do a bitwise AND between two ints of length 1, you get the desired result: true & true = true; false & true (or vice versa) = false; false & false = false.

Still, I think it’s corrupting the purpose of the bitwise AND to use it in exchange for the boolean AND: both arguments always need to be evaluated, while this is not the case for a boolean AND operation where the first operand is false. Still, one can wonder what would be faster…

After running both ways through the compiler and disassembler, the “&” compiles to shorter (IL) code, though that says nothing about speed. However, if one frequently has cases where the condition is of the following type, it’s not wise to use “&”:

if (false & some_really_long_computation()) {

Also, the same principle works for the “|” and “||” operators: bitwise OR and boolean OR. In checks for null, using the bitwise version wouldn’t even work as expected:

if (obj == null | obj.method() == value) {
// Throws a null pointer exception if obj is null

To prevent confusion and special cases, just use the boolean, lazy operators: && and ||.

Even then, more worrying is that the second colleague didn’t even know about bitwise ANDs. In my opinion, every programmer worth his salt should know at least a more “low-level” programming language than C#, preferably plain C, to really understand what s/he is doing. Today, it seems, there are more high level “scripters” than real programmers. Scripters who don’t have a clue about performance, just because what they throw together works fine on today’s powerful computers.

Posted in: Work

First open source contribution

Posted on 2008-03-12 21:17:17

Last week, I made my first “real” contribution to open source software. I put “real” in quotes because I’ve been releasing my own little programs as open source for the past year, but I don’t count that as “contributing”.

This contribution I’m talking of consisted of writing a new image coder for ImageMagick, so that ImageMagick can now also read DDS images. This format is quite popular for storing graphics for (primarily) Windows games, so I’m surprised that it wasn’t supported already, considering there are over 100 formats supported, most of which I haven’t heard of.

Anyway, my patch was accepted, and my piece of code is now included in the latest ImageMagick releases, yay!

(by the way, yes, I also finished The Incredible Machine last weekend!)

Posted in: Open Source, Projects

The Incredible Machine update

Posted on 2008-03-08 14:48:59

I’m addicted all-right: after three more days of playing I finished all hard puzzles and I only need to complete four very hard puzzles. I say “only” but those are probably going to take me a long time: I remember “Enchanted Kingdom” (#24) being particularly hard…

Posted in: Games

Rediscovering an old friend

Posted on 2008-03-05 22:15:34

One of the very first games I ever played was The Incredible Machine (version 3): an incredibly addicting puzzle game in which you have to build wicked contraptions to reach goals like “brew coffee” or “put the ball in the basket” or “get Newton Mouse home”.

A few days ago at work, we had a small conversation about it, and when I got home I wanted to play the game badly. After hunting the ‘net I finally found a copy for download, and have been playing it ever since: it plays fine under Cedega 4, even though I had to do some work to get the progress save to work properly.

And it’s still addicting… I’ve so far completed all easy and medium puzzles, and have completed 17 hard puzzles. Only 14 hard puzzles and 29 very hard puzzles to go!

Posted in: Games