Skip to content

Instantly share code, notes, and snippets.

@English3000
Last active February 3, 2018 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save English3000/faa6b57facebce4172d752646e89a00b to your computer and use it in GitHub Desktop.
Save English3000/faa6b57facebce4172d752646e89a00b to your computer and use it in GitHub Desktop.
Beginner's Go

I discovered Go during my job search. Some companies had listed it in their stacks, and I heard back from one of them, so I did my due diligence. In a nutshell, Go was built to (1) mimic C++ functionality with cleaner syntax, and (2) leverage modern multi-core processors in computers. For the latter, this means that because processors are multi-core, they can perform operations on parallel threads (known in Go as concurrency). Combined with performance optimizations possible when using a static-typed language, Go can perform 10 times more efficiently than a dynamically-typed language like Ruby on Rails.

My Review

Go, at first, seems really appealing to learn as a first statically-typed language. The tour provides a clear introduction to the syntax and Go's special equals operator := makes coding in it feel like a dynamically-typed language. Add in an amazing linter in go-plus and at first Go seems really exciting and educational. Furthermore, after finishing the tour, there is a guided project for you to build your own server.

Doing some online research on frameworks, I settled on Iris. After setup, I coded along with the first few MVC examples. Actually, I first referred to the Express docs (for NodeJS) as a point of reference! However, when I got to the Login example, I realized Go wasn't quite what I was looking for.

My issue with Ruby on Rails is it makes building a backend too easy--i.e. you miss some of the understanding that comes along with setting up a backend with a more minimalist framework like Express. As a result, I find myself having to produce the backend more slowly in order to remember each thing I do. Put another way, Rails has so many preset folders and files that it's easy to forget you added something to one.

Ideally, I'd like a framework that encourages disfluency. But a quote from the linked article also rings true: "But, of course, if we push them too hard toward disfluency, we may end up discouraging them and shutting off their learning altogether." That ended up being my experience with Go/Iris.

The thing with Go and some other programming languages is they do certain things well but not the basics. Whereas in Ruby there are a slew of methods you can call on datatypes, in Go some of the more basic methods are--at the very least--unintuitive to find within the documentation.

Further, as a statically-typed language, Go suffers from what I'll call "package hell". Given that you must identify the types of arguments and outputs, you'll sometimes see something from a package as the type. When you check the package's documentation, however, that type consists of other types documented elsewhere. So understanding exactly what you're coding from the package is a big hassle. And these other types aren't necessarily complex; they just have their own names.

That seems like the pattern with Go: a lot of packages and types to memorize in order to get basic functionality. This gives the language a top-down feel for more sophisticated use: it feels like you need to read the entire documentation for a couple of packages in order to know (rather than memorize) what to code.

And when building an MVC backend, you need to build out everything, including SQL queries and actions, in Go. Because Go lacks class functions, functions must defined for each type and functions are also declared within an interface, the experience comes off as verbose, more disorganized than Ruby or JavaScript and tedious where the two provide syntactic sugar or pre-bundled methods. If these exist for Go, Iris doesn't use them...

In all, Go has some cool features and concepts that are worth introducing oneself to. However, the actual coding process seems inefficient, memorization-heavy, and hard-to-read compared with dynamically-typed languages. Go may be performant (although achieving peak performance is a task in and of itself) but it isn't as productive to code in as some dynamically-typed languages. Compared with C++, it may achieve its goal but it doesn't seem like a language for more junior developers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment