Subject-only emails – I’ve been doing that for years

I have a friend who used to make fun of me for writing him email messages with a long subject. He claimed that the subject line already contained the entire content of the email. He, on the other hand, used to write me emails with a one-word subject, almost always “hi”. When I complained to him about this (not being able to locate his email by the subject) he started enumerating them (e.g. “hi1”, “hi2” and so on).

Now it turns out the subject-only emails can be an effective way to send a quick message without all the hassle of filling out a proper message body. (via Lifehacker)

Videos and XHTML Strict (or: a rant about Google Video and YouTube)

Recently I posted a video of Ace, my cat, playing around. The video was uploaded to Google Videos, as I knew I could later embed the video in the post.

When I validated my home page a few days later, as I do from time to time to see that it still conforms to the XHTML Strict standard, I was surprised to realize that it does not conform to the standard because of the video code I inserted into the post. I tried looking for a solution, but the truth is that I didn’t want to be looking a solution. I expected Google to provide me with standard-conforming code.

You may (or may not) know that Google supports standards and encourages website owners to make their code standard-conforming. It is a common belief that the more a website is standard-conforming the more it is likely to be indexed correctly by search engine, like Google’s.

So, following my disappointment with Google, I uploaded the video to YouTube, hoping that their code would be standard conforming. I was upset to see that it wasn’t, but at least with YouTube I found a quick fix and now my website has the video and is standard-conforming to XHTML Strict.

Writing Software – Part 1

Ever since I started programming for Linux I’ve been thinking about writing about the differences between writing software for Windows and writing software for Linux. In the process of thinking about it many other programming-related thoughts started coming up and I couldn’t quite categorize them into sections (like Windows, Object Oriented Programming, etc…). This is why I decided to write this series, in which I will share some of my thoughts about and experiences with aspects of writing software.

Let me tell you about my first experience with programming, as a kid. When I was about 6 or 7 years old, my older brother got an Apple compatible computer. These kind of computers only existed for a little while, as Apple sued compatible Apple computers manufacturers and the rest of the story is well known (IBM compatibles outsell Apple’s computers to the point of near extinction).

The programming language available for me back then was the BASIC programming language and so my first program was:

10 PRINT "amit"
20 GOTO 10

Then, the uber-hacker version of this piece of code replaced the first line with:

10 ? "amit"

Looking back at this I wonder why it was decided that “?” can be used instead of “PRINT”. It doesn’t make too much sense from the write-clear-code point of view. I mean, they could have gone all the way, like Brainf*ck (or Linguine) did.

Ah, the good old, misunderstood and now forbidden GOTO. Where have you gone to? Today merely mentioning goto in a job interview is sure to get you another one of those we’re-sorry-but-you’re-over-qualified letters. GOTO is such a nasty word that, in the beginning of an introductory C course in the Technion, the teacher said that he will not teach us what goto is and a student who will use it in a homework assignment will automatically get a zero grade for that assignment. And by the way, if the interview is already going bad, make sure you say something like “when goto isn’t enough, I simply use longjmp()“.

In Java, goto is a reserved word, but it is not implemented. That’s the zombie land of language keywords. The reason for the deprecation of goto started with the famous article “Go To Statement Considered Harmful” by Edsger W. Dijkstra. The misuse of this statement was just too much to bear. The thing is that goto was still useful, for example in the case where you wanted to do some cleanup at the end of the function, or maybe some common error handling code. Many uses of goto use can be found in libraries (A.K.A the place where you can do stuff that is generally not allowed as long as it works) which is an indication that it is still useful. Actually, there’s a thumb rule I learned once that prevents the spaghetti code which usually results from using goto: always “go to” in one direction. It’s a simple and effective rule, which means that if you use goto in a function, always make sure that the goto target is, for example, below the current line.

Alas, goto is already doomed. Modern languages offer “structured” ways for doing cleanup. In Java and in C# (I will use C# as the representative for .NET languages) you can use the try-finally combo, which is part of exception-handling. And if we’re already on the subject of exception handling, let me tell you about my “real world” experience with C++ and exceptions.

Exceptions in “real world” C++ are rarely used. Most of the reasons I heard were the usual FUD – exceptions are unexpectable, exception handling is slow, exceptions are too complicated. This is true for three out of three C++-using companies I worked for. Ultimately this means that the code has the call-check-trace-return pattern, which is something like this:

STATUS FunctionA()
{
  STATUS ret = STATUS_ERROR;
  ret = FunctionB();
  if (STATUS_OK != ret)
  {
    TRACE_ERROR(ret, "I called FunctionB and it failed. Boo hoo");
    return ret;
  }
  
  ... // repeated for evey call inside FunctionA
  
  return STATUS_OK;
}

Those of you who use exceptions can see the irony. Naturally, it means that constructors are not allowed to do any work (so there’s always a Construct() function for a class, immediately following the constructor), which apparently is one of the five habits of “highly profitable developers”. In an environement that embraces that kind of attitude there’s no room even for mentioning RAII, pimpl, Loki or even boost. Sometimes I wonder if the C++ I read in books will ever come useful to me at a workplace.

Mentioning Loki and boost brings me to the subject of templates, which is very similar to exceptions, but I’ll talk about that some other time. Oh, and I have to continue the story about how I started programming.

Ace plays with the water tap

Some of you already know that I have a 5 months old cat. Now it’s time to show her to you, while also testing what it’s like to put a video in the blog. So here it is: Ace plays with the water tap.

Description: After noticing Ace’s interest in the sink, I put her up on it and let the water run just a little to see how she would react.

All Your Snakes Are Belong To Us Video

OK, so how many times can I use the “all your [blank] are belong to us”? I guess as long as this joke lasts (in geek land – probably forever). Anyway, the story about the movie “Snakes On A Plane” is that it created a lot of Internet hype before anyone saw it, which is truly amazing. But when the movie came out (it’s still running) it pretty much flopped. So now someone went through the trouble of making an “All Your Snakes Are Belong To Us” video, which is pretty funny.