Posts tagged with despair

Find The Bug – Short Review

February 22nd, 2010

The book “Find the Bug” by Adam Barr, to quote the author, “[...] contains 50 programs, in one of five languages (C, Java, Python, Perl, and x86 assembly language). Each program contains a single, hard-to-detect but realistic bug—no tricky gotchas.”. The idea is to train your ability to find bugs. The examples claim to be something you might be asked to do in a job interview. “Write me an algorithm to do $x!” and you move up to a whiteboard, write a few dozen lines in a language of your choosing (thus the 5 languages in the book) and now you must be able to defend it or critize it (depending on whether you are the interviewer or not). You don’t have test cases, you can’t compile it, you only have your brain.

This is a really neat idea in principle, but unfortunetaly, the execution is rather lacking. The enforced simplicity (every programm has to fit on one page) ignores many realistic kinds of bugs. None of the examples require much background knowledge, which at first looks like a good idea, but again is rather unrealistic. If I’m writing a level generator for a game and my random number generator has a bug, then I’ll probably only see it in some cases and finding it may require a bit of statistical knowledge. Just because I dislike statistics doesn’t mean I get to ignore them.

Especially bad is the fact that there are no performance optimizations. The code is always as clean and simple as it can be to solve the problem, but that’s not what real code looks like. In some cases, this is alright, but there are plenty of low-level function like memory allocation, string parsing or sorting and those normally have the hell optimized out of them. A “clever trick” is exactly the kind of thing that is widespread, evil and buggy.

Also, the examples sometimes aren’t really typical. The Python and Perl code in particular looks nothing like normal code.
The Python code is way too low-level, uses no list comprehension and barely anything of the extensive library. In short, it’s rather unpythonic and looks a lot more like quickly converted C code.
The Perl code has multiple comments and meaningful variable names, something no self-respecting Perl hacker would ever use. :>

It’s a bit hard to avoid because you can’t throw around all the neat little features everyone familiar with the language would use while still assuming that the reader has at best a passing knowledge themselves. It would have been a lot better to either stick with a common and small language (like C) or use pseudo code instead. Most bugs aren’t language specific anyway, so this wouldn’t have hurt the book.

Finally, some of the example code is just… strange. There is one Java example that wants to find out whether a year is a leap year or not. The relevant logic is this:

// A leap year is a multiple of 4, unless it is
// a multiple of 100, unless it is a multiple of
// 400.
//
// We calculate the three values, then make a
// 3-bit binary value out of them and look it up
// in results.
//
final boolean results[] =
    { false, false, false, false,
     true, false, false, true };
if (results[
    ((((yearAsLong % 4) == 0) ? 1 : 0) << 2) +
    ((((yearAsLong % 100) == 0) ? 1 : 0) << 1) +
    ((((yearAsLong % 400) == 0) ? 1 : 0) << 0)]) {
    throw new LeapYearException();
} else {
    throw new NotLeapYearException();
}

If I ever meet anyone who uses something like this, then all my promises of non-violence will be void. However, it is a rather typical example of the twisted and mad code a Java programmer would write, so kudos to the author. It’s still an abomination, though.

Anyway, a lot of wasted potential. *sigh*

Anti-Buddhism

December 12th, 2009

Today, I’m an anti-buddhist. You know, like an anti-christ, i.e. someone who perverts all christian ideals? Specifically, I have perverted the 4 Noble Truths and broken all 8 principles of the Noble Eightfold Path. How so?

The 4 Noble Truths teach us about suffering and how to overcome it. In short, suffering is caused by our attachement to the world. By wanting things, we suffer because it is fundamentally impossible to fulfill this desire. I have perverted this, for I craved for a bigger desktop. I have assembled 3 monitors where I previously had only 1. I suffered for this, so much is true. (I have suffered a lot. Linux is my own personal hell. I am repenting for very grave sins, it seems.) But, I have overcome this suffering without letting go. I have achieved my goal – I have 3 working monitors. But to do this, I had to break everything on the Noble Eightfold Path.

All my sins are:

  1. Right View – I have forsaken the path of the Console and The One True Display. I have merged 2 monitors into one (via TwinView) and added a third one to watch blasphemous movies while working.
  2. Right Intention – I wanted more screen and more windows. I did not want a simpler, easier display, but visual bloat instead.
  3. Right Speech – I have cursed, of course, but I have also lied. I still lie, for every single application I start is a lie – a lie to my xorg-server. It still thinks the monstrosity, the 2-monitors-into-1 is just one screen, but I run a hacked libXinerama instead that tells every application the truth. The server doesn’t know this, it is completely unaware. Only my conspiring GUIs do. [0]
  4. Right Action – I have broken the holiest of rules – I have downgraded. (I now run X.org 1.6 instead of 1.7.3.)
  5. Right Livelihood – I am a slave in the worst of professions – I maintain my own libraries, ignoring all advice from my package manager.
  6. Right Energy – I have spent a whole 3 days setting this up. Do I need to say more?
  7. Right Mindfulness – I have forgotten the pain of changing my xorg.conf and ignored the past. I will forget today’s lesson and, at some point, patch again.
  8. Right Concentration – I have drunken caffeine a-plenty and spent 2 days fiddling with emacs. I was never focused on my ultimate goal, only ever jumping from idea to idea.

Yet, everything works. (Well, except the actual window manager, but this requires patches that are trivial in comparison.) This whole endeavour must have gotten me massive amounts of negative karma.

[0] http://ktown.kde.org/~seli/fakexinerama/ pure awesome-sauce (my modified version: Xinerama.c)

I Am Cursed

October 9th, 2009

No, seriously. I mean it. I am the Manifestation of Indifference. The Avatar of Doesn’t-Give-A-Shit. Wherever I go, all motivation ceases to be. Hopelessness follows me. My future will not be a bright one.

You want proof? I have proof.

1. Karlsruhe

I started noticing it here, about one year ago. I’m studying computer science in Karlsruhe since 2007 and my year is, by far, the laziest, as far as students are concerned. The year[0] of 2004 has[1] an internet forum, www.unika04.de/forum, with:

year of 2004

35,222 posts. When I’m looking for information, that’s where I go. The year of 2005 has one, too -  www.info.sptotal.de. They have:

year of 2005

15,270 posts. Still alright. The next one, year of 2006, of course has another forum. It’s at info.php-4.info. They have:

year of 2006

15,866 posts. My year, year of 2007, well… it was at www.uka07.de, but right now, it:

year of 2007.

It had maybe a hundred posts, top, before it closed down. But this is not a case of general dumbing-down. The next year, 2008, has a forum again - info08.de. They already have:

year of 2008

3,605 posts, and the hard courses, the ones in need of discussion, are only just beginning for them.

2. Berlin

Before going to Karlsruhe, I lived and studied in Berlin for a year, namely religious studies and quite a bit of archaeology. The whole field is pretty well represented there, having its own buildings all over the place and quite a bit of money to spend, considering how little attention it generally gets. When I moved there, religious studies and several branches of archaeology had just gotten their own degrees and were not considered something you only minor in. However, students of my year were so disinterested that it was canceled just a year later and got demoted to a minor course again. But only religious study. Egyptian archaeology, for example, is still doing fine.[2]

There was never any organization and nothing got done. Ever.

3. School

But it even goes back to school. My family moved quite a bit and I went to a total of 5 different schools, but my curse becomes most evident at my last school, the OHG in Landau. (Don’t google it.) I got there in grade 8 and basically, what happened is, the teachers had the brilliant! idea of taking all the problematic kids and putting them in the same class. My class. It became quite a bit of a legend, though, and we drove at least two teachers out of school and into therapy[3]. This class was the anti-thesis of learning. To demonstrate this, we decided to tape every test a student had failed with a 6, i.e. the worst possible grade, to a wall. After 3 days, the wall was entirely covered in tests. A week later, we took it down again so that the teachers wouldn’t get too demotivated. Yeah, it was pretty bad, but at least no-one annoyed you and you could just talk or read all day and not get interrupted by those stupid things called “classes”. And the ability to focus and try to write down lyrics from memory while people around you are playing soccer during history class is pretty useful, I have to admit. Nobody can possibly distract you after this.

4. Further Proof

If you’re still not convinced that I’m Procrastination Personified, let me list a few other facts. The first national election I was allowed to vote in got the lowest level of participation since the state got founded. As did the second. I wonder if anyone is even bothering to show up in 4 years. Maybe I shouldn’t so that the Pirate Party can actually win this time [shameless political plug].

My year of birth is mostly remembered for Chernobyl, an act of extreme negligence and the explosion of Challenger. Probably the only good thing to happen in 1986 is the release of Watchmen, a story about powerless and disillusioned superheroes.

The one forum of which I was a regular member, one of the largest in Germany actually, got raided by the police and was never rebooted out of laziness of everyone involved.[4]

Oh, and remember the 5 schools I mentioned earlier? 3 of those closed down because they couldn’t get find enough new students. 1 of them was just completely redone right before I went there and everyone was very optimistic that it would have a bright future. It didn’t last another 2 years.
It gets worse. Two of the towns I lived in don’t exist anymore because nobody cared about living there. Both of them were industrial centers before I was born and played important historical roles. The most awesome coat-of-arms, featuring a bear wielding a pair of axes, didn’t help in the end. Detroit, I feel your pain.
In fact, the whole nation I was born in,  the German Democratic Republic, doesn’t exist anymore because, well, you know why.

Any questions?

Notes

[0] This is first year, not year of graduation.
[1] Everything as of this writing, of course.
[2] No, I’m not bitter.
[3] Seriously.
[4] No names. It’s better this way.