Phaneendra Chiruvella's bloghttp://pcx.io/2015-06-14T19:46:27+05:30My experience with Golang2015-06-14T19:46:27+05:30Phaneendra Chiruvellatag:pcx.io,2015-06-14:my-golang-experience.html<p>Lately Go has become one of the preferred languages to write systems applications, especially in the container world. My overall experience with the language has been great, albeit with hiccups.</p>
<h3>Stuff I liked</h3>
<ul>
<li><strong>Speed!</strong>: Perfomance is one of the priorities for Go. It providies very efficient abstractions. You will love Go for the speed, especially if you are coming from say Python or Ruby. </li>
<li><strong>Easy to get started</strong>: Go comes with a small set of features. If you already have some programming experience, then <a href="http://tour.golang.org/">A Tour of Go</a> is great place to get acquainted to the language quickly.</li>
<li><strong>Easy to read</strong>: Readability is very important since developers spend more time reading code than writing it. This has always been the best thing about Python. Go fairs very well in this regard. All Go code is expected to be formatted using the bundled <em>gofmt</em> tool, which reformats your code very nicely. Also, Go avoids sigils in syntax, giving it a clean Python-ic feel.</li>
<li><strong>Fast compile times</strong>: Quick compilation was one of the priorities from Go's early days. This helps a lot while using <em>go run</em>, which compiles and runs your code. It's so fast, it sometimes feels like using an interpreted language. If you come from a Java world, you will definitely notice the difference.</li>
<li><strong>Static compilation</strong>: Go builds all your code into a single binary. This removes any hassles of dependency management for binary distributions. For source distribution though, it's a totally different story!</li>
<li><strong>Concurrency</strong>: This is hands down the best thing about Go. Go provides semantics - goroutines and channels, that make it a lot easier to write concurrent code. This style of concurrency is put into words aptly through one of the mottos of Golang - share by communicating. I've personally felt that the Go's channels are an easier to gawk abstraction for concurrency than the usual threads/pools.</li>
</ul>
<h3>The frustrating things</h3>
<ul>
<li><strong>Lacking goodies</strong>: Coming from Python, you will immediately notice the lack of rich semantics(and to some extent Python's awesome data structures) you are used to. This seems to be a deliberate choice mostly and can be dealt with some extra effort. But I really, really miss Python's <em>in</em> operator!</li>
<li><strong>Where is my debugger?</strong>: It's surprising that Go does not yet have an official debugger. In this day there is no good reason to not have a debugger!</li>
<li><strong>No generics</strong>: A static lanugage with no generics is certainly cumbersome. There are ways to get around this constraint, but hey, just gimme some generics yo!</li>
<li><strong>Imports, Dependencies &amp; Build</strong>: The very, very frustrating thing about Go is certainly how dependencies and packages are handled. It's pretty bad! It made me seriously consider writing code in Go! Checkout this <a href="http://go-talks.appspot.com/github.com/davecheney/presentations/reproducible-builds.slide#1">excellent presentation</a> by <a href="https://twitter.com/davecheney">@davecheney</a>, where he goes into a lot more detail and also discusses his attempt to solve this problem using <a href="http://getgb.io/">gb</a> - the build tool he has created.</li>
</ul>