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.

42 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
  5. 以簡單的行為愉悅他人的心靈,勝過千人低頭禱告........................................

    SvaraRadera
  6. 如果相遇.你會感到相知.那麼.有一種習慣叫做陪伴;如果陪伴.你會感到珍惜.那麼.有一種甜蜜叫做存在!........................................

    SvaraRadera
  7. 時間的銳齒能吃盡一切,唯獨對真理無能為力。........................................

    SvaraRadera
  8. 你所貫徹的形象,你喜愛它有多少百分比,你就幸福多少百分比..............................

    SvaraRadera
  9. 要保持更新呦,加油!!!期待你的新文章!!!.................................................................                           

    SvaraRadera
  10. You may be only one person in the world, but you may also be the world to one person.............................................................

    SvaraRadera
  11. 人生有些波折,才能有些成長,所以不論順逆,凡是成長、成功的助緣,都應該心存感激。.................................................

    SvaraRadera
  12. 當一個人內心能容納兩樣相互衝突的東西,這個人便開始變得有價值了。............................................................

    SvaraRadera