Go

From Mark Weiman's Wiki
Revision as of 19:03, 15 January 2020 by Markzz (talk | contribs) (→‎Complaints)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Overview

As I've had to enter the world of the Go programming language, I've noticed a few things about it that are annoying to the point where just this would prevent me from using it in my own projects.

Complaints

The Go Tool Is Not Verbose Enough

Take this example, say I want to grab some code with go get. I create a directory, change into that directory, then run say, go get github.com/google/gopacket. This is what you get in your terminal:

markzz@mun ~ % mkdir gotest
markzz@mun ~ % cd gotest 
markzz@mun gotest % go get github.com/google/gopacket 
markzz@mun gotest % ls

Notice how the go tool is completely silent. Okay fine, but on that ls, you find that it did not, in fact, download the files in the current directory, but instead downloaded it in a possibly unknown location (in this case, it downloaded it into ~/go, but didn't tell me this). Sure, you can set a GOPATH, but the issue is that it doesn't say anything at all. It didn't tell me how much it downloaded, where, or how. This is something I find rather annoying.

Unused Imports And/Or Variables

Go is rather forceful about the fact that every single import and variable must be used. Not just assigned, used. This makes development a major pain in the ass because I may just want to write out some imports or variables I know I'm going to use later, I just want to run the damn code I have written to check something. This forces me to constantly either remove lines in my code or comment them.

Also, during development, I find myself often commenting blocks of code and this also may cause a variable to be unused.

A better approach would have been to throw a compiler warning that there's an unused import or variable, but still not refuse to run. I understand that in production code, it's much less preferable to allow these unused things, but I think compilers like GCC have already solved this problem by a parameter that will cause the compiler to quit compilation when a warning is encountered.

Go, quit treating the developer like he/she is too stupid to run code.

Dependencies Can Get You In Trouble, Fast

When you use go get and it's code from GitHub, it defaults to grabbing whatever is in the master branch and just installs it in $GOPATH (which is garbage, more on that later). This is unbelievably silly as there is no guarantee that you are getting code that doesn't change something fundamental.

Other languages do this right, let me just point out a few:

  • C: Just install *libsomething* from your package manager or just make install some version of the library you wanted. Then just link!
  • Python: Run pip and you get the version you want and it's managed by a package manager. Or you could just use your system's package manager!
  • Ruby: bundler
  • Perl: Install from CPAN
  • PHP: Install from PECL/system package manager.
  • R: Install from CRAN

This reason alone is enough to never use Go. You cannot manage library dependencies effectively nor can you trust what you are getting from GitHub.