Category Archives: Uncategorized

First Impressions of the Go Language

On the weekend while I was stuck in traffic trying to take my son to his (and my) first monster truck jam, I listened to this podcast about the Go language. It helped me understand why Google would invent a new language. Then I looked at the language spec a bit.

Here are some first impressions. I’ve only read lightly about the language so please correct me if anything is factually incorrect.

I’m not super-pumped about using Go, but if I were still using C/C++ every day I probably would be. I now think of Go as C (runs about as fast as C, strongly typed, compiled, pointers) but with a few especially nice enhancements:

  • garbage collected (yay!)
  • memory-safe – the pointers can’t go out of bounds and I think arrays also can’t go out of bounds if you use “slices”
  • extremely fast compiles.

It is missing some of the things I like about C++. E.g.,

  • You can’t use integers or pointers as Boolean expressions
  • I don’t think it has a convenient syntax for getters+setters with a default backing variable, like Property in C# or attr_accessor in Ruby. (It bugs me how verbose Java is when creating simple bean properties. I hope Go will avoid this problem.)
  • I don’t yet see a way to do automatic cleanup when a variable goes out of scope–a feature of C++, C#, and Ruby that I love because it helps reduce code duplication and add robustness

It appears not to be OO, at least not in the way we’re used to. It doesn’t have classes but it does have interfaces. It seems like if you want to make a class you define an interface and then create an instance of it. It doesn’t have traditional inheritance but it does have “embedding,” which is a nice alternative. If you embed someone else’s implementation of an interface into your type, your type now exposes that implementation without having to delegate all the methods one by one.

Lately I’ve been into Ruby, which has different strengths than Go. But if I were to start doing systems-level programming again and needed a good mix of raw performance and garbage collection I would definitely give Go a close look.

hello, world

I am Brian Morearty. Welcome to my blog.

I’m a software engineer living with my wife and three kids in the San Francisco Bay Area.

I plan to blog about stuff like software development, things that strike me as funny, etc. The technology that currently has my interest is Ruby on Rails and Flex but that may change over time. For most of my career in software I’ve been working on Windows, and I’m also a fan of most Microsoft developer technology (WPF, ASP.NET, and so on.)