238 points · by tptacek · 10y ago · 53 comments
https://twitter.com/chewxy/status/433807908875145216
https://twitter.com/chewxy/status/433811541373116416
This is from an old JITting Javascript engine I wrote in Go... a simple program like this:
function clamp(x, min, max) {
y = 2
if (x < min) {
x = min
} else if (x > max) {
x = max
}
return x
}
can generate pngs that are thousands of pixels wide and high (depending on what the nodesep and ranksep were set).I wish I did think of the visualization that Go uses. That's fantastic compared to graphs
The blocks and red edges represent the control flow graph and I can easily see the two if structures.
It lets you zoom. Mouseover nodes to get more details.
Unfortunately, our yComp tool is not Free Software. http://pp.ipd.kit.edu/firm/yComp
For other languages I have a `code` folder which has individual language folders and it contains project. Go has it by default.
We had a small benchmark tool written in Go. And people simply couldn't build it, they always came to me after banging their head trying.
This is basically what all of them did:
$ cd <folder with all their projects and code>
$ git clone <repo>
$ cd <repo>
$ go build
And obviously it failed because it wasn't in a "src" folder (it was in a git, projects or code folder) nor had the $GOPATH environment variable set. But worst was probably the missing import path structure, i.e. "github.com/<company>/<repo>" that people simply just didn't get.They just want to clone anywhere and run "go build".
You see this for Java projects where the whole source code is nested half a dozen folders deep (src/com/foo/bar/baz/myproject/...) so i don't think it's unfamiliar.
I understand it'd be a pain to have Go setup, but once it is setup, it is great, When I write Go programs
I do
`$ cd /go/src/github.com/thewhitetulip/Tasks` `$ Tasks go build -o tasks` `$ Tasks ./tasks`
You can feel free to have any repo path you want :D
You obviously didn't vendor your dependencies in your project's vendor directory.
It would be better if Go just downloaded all `go get` packages to some default fixed directory (%appdata%/go or whatever), and then the code the people manually download/write could live anywhere.
Otherwise you can write the other language code in the $GOPATH itself.
This is incompatible with path dependencies. When I was working on the YCM goto support for Go I had to rewrite all the imports in godef to be path imports because you can't go build packages with github deps outside of gopath. This rewriting had to be done in each file (and forced us to fork the package).
We wanted to use godef as a local folder because YCM wants to be able to pin to a version, usually via a submodule. `go get <github>` will be affected by silent updates.
Having everything in $GOPATH has the advantage that all your go code is in one place, but it's not much of an advantage because it's not flat -- you have to `cd github.com/<someusername>/<reponame>` whereas my regular `code` folder has a flat structure, with subfolders only for special cases (e.g. projects with multiple linked repos or whatever).
There are tons of disadvantages, which totally overshadow the minor advantage of automatically giving you a `code` folder -- something which is super easy to do without the "help" of GOPATH.
Fortunately a lot of these things get solved by vendoring, glide, and friends. Bare GOPATH is still terrible.
Aside from that, I do enjoy the language a fair amount.
Something like `projects/go`
I have multiple GOPATH for personal reasons and use long running tmux sessions which exports the different GOPATH.
[0]: https://github.com/lloeki/dotfiles/blob/master/shell/go
I just set GOPATH=$HOME, and then all my source (Go & otherwise) is in ~/src, all my binaries (Go & otherwise) are in ~/bin, &c. It works really well for me. So some of the subdirectories of ~/src are a bit funkily-named: no big deal.
My only problem now is that I have so many projects checked out that it's hard to remember which ones I am contributing to vs which ones were checked out as a dependency. I think I can address that by setting GOPATH to ~/thirdparty:$GOPATH or something, but it hasn't bothered me enough yet.
We can already create multiple ones.
C++ is a great example of a model to avoid (pkg-config handles dependencies, except use autoconf for crossplatform, except cmake is newer and supports windows, except then you should use cmake modules instead of p-c, not to mention qt having its own qmake, ...).
Chaining GOPATHs with : can be very useful (just like PATH).
You can use `gb` if you want a "typical" one-folder-per-project workflow.
> The fact is that every language has these problems
Other languages solve them with proper module or library systems.
Rubygems + Bundler is still the standout in this field. Based on my day job, bundler still better at the basic job of "get the stuff I need" and "keep the stuff I need" than any of Pip, NPM, Godep, Composer, Conda and I forget the rest.
> whereas in other languages, you would run into and make a different ad-hoc solution for every project.
It depends on the language. Ruby and NodeJS have clearly dominant single systems. Rust has one by design. Python is a bit of a mess but Pip seems dominant, with Conda for scientific packages. PHP has Composer, which makes a lot of things tolerable, but not great. Go package managers are not really settled, between Godep, Go vendoring and Glide.
Yes, being able to `go get` is great. Except `GOPATH` doesn't make it any more or less possible, especially now that `godep` is widely used. And that breaks down completely when you actually need to build something that consists of more than just go source. Protos, multi-language projects, etc.