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, vb.net 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.

4 kommentarer:

  1. Hi!

    yeah, I had a few baby steps with go, and I must say, it feels pretty good! Of course it is very much systems oriented at the time, so you can do command line apps and daemons, haven't seen any GUI things yet.

    So who's the first to implement the MySQl wire protocol (with support for asynchronous queries and all :) in go?

    SvaraRadera
  2. Thing is, C++ originally looked pretty good too. It wasn't till much later that the system-level stuff bit you in the behind, with inconsistent implementations and libraries, no constant ABI at all, and a dozen other problems.

    Go's a nice idea, but it's way too early to judge yet!

    SvaraRadera
  3. The D Programming language is another alternative if you're looking at non-functional languages. I've done some stuff in it and I love it! I can't wait for the 2.0 version to become stable...and more compiler support.

    SvaraRadera
  4. Google actually says Exceptions are great ... for new code. Their code base doesn't have support for excpetions, so they don't allow it as any new code will have to interface with the old. They do recommend their usage for windows programming.

    So, its not some general rule against exceptions. I don't know why they aren't in go.

    SvaraRadera