jonwear.com

jon wear's personal website

I'm going to learn Go

20 September 2013

I'm going to give it a shot anyway. I've read enough about Go to find it really interesting. I want to learn something outside of the .Net world so I can actually call myself a polyglot programmer. I'm sure I'm going to get lost at times, but I'll start small and see where this takes me. I do think it's important to learn to think about code differently and Go seems different enough to help with that.

So for the first several Go posts, I'll just write some C# code and the equivalent Go code. I'm sure I'll be "doing it wrong" since the languages are so different, but it's frustrating to start working in a new language and get stuck on, "how do I this simple..."? I want to know how to build types, make function calls, do loops and if/else type things. I'm sure it'll be obvious that I'm using Go with a C# mindset, but that will change with time.

I have several posts in the hopper that I was going to do with C# code, but I'm going to push those back and re-write them in Go. This will help drive the "C to Go" posts and help me to learn more about the language. I imagine I'll get in over my head pretty quickly.

Three things I like about Go already.

  • If you bring a package from one go library into another, it's included so you don't have to have access to the source package once you compile to an .exe. I remember way back when I was getting started with .Net, I was frustrated that in order to have an object that inherited from a base object, my final program had to have access to both the base object and the new object. Now, Go doesn't have inheritance like C#/VB but it does have dependencies and it's nice how those dependencies are brought into the final .exe. You can take that .exe, deploy and not worry about bringing all the dependencies with you.
  • You can take your final .exe and copy it to another computer with the same OS and it just runs. You don't have to have any Go stuff installed. I know this is a "duh" for lots of programmers but for .Net developers, it means there is no need for the right .Net Framework or any .Net framework for that matter. No Java run time stuff. Again, I know this is a no brainer for lots of developers but for me, it was a reminder that there are ways of writing code that don't require pre-installed frameworks. Other than an operating system.
  • My favorite thing is that, the entire Go spec is fifty printed pages. You can read all there is to know about Go in an afternoon. That gives me the hope that I can understand and really use Go. This podcast goes over the reasoning behind Go and specifically mentions that you can become productive in Go in a weekend and get really good in a few months. This is one of those opportunities to get in on the ground floor with a language. As it grows and changes it'll be much easier to understand what those changes bring since it's possible to hold the entire language in your head. Well, possible for some, we will see if it's possible for me.

Next up, Go FizzBuzz.

By Jon Wear

Related articles