My Perspective on Go
zhen.org
zhen.org
I've seen this complaint a lot and don't agree with it. Go just want everything to be accessible through $GOPATH, it doesn't have to _be_ there. Here's how I organize my code:
- I have all my dev in ~/dev. Anything goes here, whether it's go, ruby,... it's my workspace
- I put $GOPATH where it should be, in ~/.local/share/go
- Whenever I need to go get something, it ends up in ~/.local/share/go/src/domain.com/author/package, as expected
- When I need my package to be in $GOPATH, I just symlink ~/dev/project to ~/.local/share/go/src/github.com/rakoo/project, so it is visible in $GOPATH
After that everything works as expected (modulo some minor quirks I have to do at go install time), and you don't have to have a specific workspace just for go. It's also minimal enough (once per new project) that I'm not too bothered by it.
For a working example, have a look at the logstash-forwarder code structure, it's how they do it, and you can build that from any directory you want.
And if you really want to set up go path in your current directory, use a make file and set up a target with 'env GOPATH=$(pwd) go install'
- libraries are duplicated left and right. If I want to use the same library in multiple projects, it will be in each project's lib (note that this is how you'd vendor, but it's something else)
- resetting env for each command you run sounds heavier, and the day will come when you will forget to do it and you'll run into problems.
Resetting the env isn't my preferred choice, but if you put it in a make file, it becomes hard to forget. Especially if you are in the habit of reusing make files between projects with a few customizations, which is my preferred setup.
It's a pity though the $GOPATH system doesn't fit in with this style of working.
The criticism is well-grounded: it's rather tiring to see endless "performance benchmarks" that test little more than printing to the console[0], or create artificial programs that are direct line-for-line translations of another language, and don't represent what an actual developer would generally write.
Think of it as a from of premature optimization - literally.
[0] Not in Go, but I can't count the number of times I've seen people use these comparisons for languages like Python and Ruby. It's incredibly ironic, because these languages really just farm out to the same underlying C libraries for this functionality, so it's testing something, but not really the performance of the actual language features.
It's important to understand how new users are using the language, but new users of the language should not be focusing on performance before they learn the language well enough to know what is idiomatic and what is not, ...
See, that's a chicken-and-egg problem. This was my original point. How do you come to understand how new users are using your language and where they're taking performance hits if you keep telling them not to try to write performant code?It's very common for new users (in any language, not just Go) to try to jump right to the end, but focusing on performance before understanding basic language building blocks is a recipe for frustration, both for the new users and for the language designers.
>I just could not get my non-functional mind to wrap around the functional Scala. And since I really didn’t need to code (nor the developers want me to), I gave up on learning Scala.
>I’ve barely heard of generics, communicating sequential processes, and other “cool” and “advanced” concepts.
Emphasis added
Sounds an awful lot like http://c2.com/cgi/wiki?BlubParadox
[1]in the sense of being self-contained, not architecture-independent.
Ah, the famous integer compression library modifying non-programmer :)