torsdag 3 december 2009

A replacement for C at last?

Wow, those Google guys sure keep spitting out new products. Barely had I finished my first shaky \/\/ave message when to my surprise I found out they have done what I have secretely dreamt of for the past five years - without getting round to it, obviously - they have created a new low-level language. For us poor souls stuck in C/C++ drudgery, this is amazing news. I'ts been over 20 years since something on this magnitude happened on the "system languages" frontier. Not counting Ada 95, nothing has happened as far as low-level languages are concerned.

Now, while you "web" guys might not hold a new language high in esteem - after all you are very badly spoiled - you get a new language complete with a framework and an IDE every other year: Ruby on Rails, PHP, Rebol, or what have you. But a new language that tackles the actual machine, now that's something you don't see every day. Where you can write stuff that ... wait for it ... behaves differently depending on the computer architecture. Where bit-shift operations give different outcomes. Now that's hardcore.

Of course I just had to dive right in and have a look at Google Go. I was scrolling through the FAQ and Tutorials, trembling with enthusiasm to see all the hideous 80's constructs that this language just about might pass on to history's scrapheap. And I can say that it definitetly looks better than C, even better than C++. (Well, honestly, how hard could it be to beat those langugages?). Built-in strings and maps. Good. Garbage collection. About time. Away with the preprocessor. Even better - even C# failed somewhat at this. But for some strange reason they abolished exceptions. Which is something that has puzzled me for a long time. Apparently Google resent exceptions. In their C/C++ style guide they supply a long list of reasons why exceptions suck. But they all seem to be either very subjective, biased or plain-out "duh" moments. Most notably the last one:

"The availability of exceptions may encourage developers to throw them when they are not appropriate or recover from them when it's not safe to do so"

Duh! You could say the same about any other "advanced" languge construct. Inheritance, anyone? I've seen OO challenged developers screw up simple type hierarchies and creating a mess 100 times worse than you could ever screw up a catch-throw. It seems the bottom line is Google just don't feel comfortable with exceptions, period. So we probably will not see them in Go any time soon. It's a pity, I find programming without exceptions an arduous task and a code cluttering no matter how you do it. Let's hope they find a way to implement exceptions to their liking.