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.

Is Writing Code a Career Limiting Move?

From time to time I think about my future in the computer industry. What I do best, without a doubt, is computer programming. I’m not sure I’m management material, but I really have no idea. I’m considered pretty good at what I do, which is directly related to the following traits:

  • I take interest in the computer science world in general and programming in particular.
  • I care about the code that I write.

However, I never see myself advancing up the company ladder, because writing code seems to be a career limiting move, especially if you’re good at it. For example, if you care about what you’re doing you might get into arguments with management over some design decision that you think is wrong. In turn, it would make you look like you’re not a team player. It might even just look to everyone else that you’re not such a nice guy. I’m not the only one thinking about it… Tom Ball of Sun Microsystems talks a little about why writing code could be a career limiting move. (via Artima)

Coding Horror

Coding Horror is a relatively new blog on my RSS feed list, but I like it very much already. Jeff Atwood, the writer, talks mostly about programming and software related issues and subjects in a thought-provoking way.

Guruza – yet another UQAN implementation

Following Illumio, another implementation of my own UQAN idea has surfaced lately. This time – Guruza – where you ask a question and state how much you’re willing to pay for a good answer. Then you enter a chat and when you’re satisfied with the answer, you pay the “expert” who answered it. Seems to work with a kind of honour system… I hope it’ll work.