318 points · by crawshaw · 11y ago · 167 comments
m := map[Point]string{
Point{29.935523, 52.891566}: "Persepolis",
Point{-25.352594, 131.034361}: "Uluru",
Point{37.422455, -122.084306}: "Googleplex",
}
may now be written as: m := map[Point]string{
{29.935523, 52.891566}: "Persepolis",
{-25.352594, 131.034361}: "Uluru",
{37.422455, -122.084306}: "Googleplex",
} map[Point]string
as opposed to something more symmetrical? func doSomething(input string) string { ... }
The go map declaration syntax is analogous to the function declaration syntax: the keyword (map, analogous to the func keyword) followed by the type of the keys in brackets (analogous to the argument type in parentheses) followed by the type of the values (analogous to the return type).Now I wish I had 1 million dollars and a better brain to work full time on a proper language that would fix go's issues. What a missed opportunity to create something everybody would be comfortable with. It could have been the biggest language of the next 20 years in webdev, CSP is a great concurrency model. At least it will inspire some people in the future I hope. Rust is cool but doesn't have CSP builtin.
Not possible.
Still, 4ad's comment above mine changed my mind. I didn't consider that you can do this with structs already (in spite of the fact that I already do that in my code), and I prefer the consistency to the lack of verbosity.
I'm really a go tinkerer, but I like the langauge.
I didn't realize Garbage Collection was so expensive that the goal is to only have it run 20% of the time. But its a good goal.
"Run Go application code for at least 40ms out of every 50ms."
How does this work? As far as I understand Go is moving to a copying collector, so any pointers passed to C may become wild pointers when garbage collection is performed.
On go-nuts, Go's developers have been warning that passing arrays to C by getting the address of the first element of the slice will be unsafe for this reason.
it's hard. mixing manual and automatic memory management is tricky.
I wonder, does this make stuff like this unsafe:
var thing C.thing; C.somefunc(&thing)
i.e. can stack address change now?
After all, a go executable can be 2x - 8x slower than a C one (which is still good enough for many uses).
Since a large project like Golang has so many auto-build tools and test OSes, how hard is it to provide a binary download for e.g. Ubuntu 14.04 LTS? You know, not tarballs, but actual static binaries as deb packages installable via apt-get.
Good examples:
https://www.percona.com/doc/percona-server/5.6/installation/...
I root for open source movement, but to install something on a popular arch/OS by compiling from source everytime is just meaningless power consumption and adding CO2 emissions.
If you really want to install Go via your package manager, you can install the golang package from the Ubuntu repositories. However, this package is naturally on an outdated version of Go. Also worth mentioning is godeb[1] which can generate and install a .deb of any version of Go for you.
[1]: http://blog.labix.org/2013/06/15/in-flight-deb-packages-of-g...
That's exactly the problems package would solve, well, plus easy update capabilities.
Don't most people want to install X via their package manager?
> However, this package is naturally on an outdated version of Go
I can't tell if you're being sarcastic or not here - why would a package such as this be outdated?
Because of the way software is packaged in most Linux distributions. The upstream version is frozen in that particular release.
To be fair, they follow a slide about general performance, 4 slides after the GC slides.
And from the concurrent GC slide it looks (as one would expect) that the GC burns significantly more resources overall (it's not just longer wallclock), though it rarely completely stops the world anymore: on the right-hand side, where the old GC would burn 1 unit of CPU for 240ms (3 * 80ms), the new one burns half a unit of CPU for 900ms (plus a unit for 2ms), which mean it's using 452ms of CPU, close to twice as much as the old one. Though the application pauses significantly less (which is good for responsivity), that's CPU time it doesn't get to use anymore. The concurrent GC also "leaves off" more work for later, the left-hand side graphs show relatively low CGC use for the first 7s, followed by a spike and then much, much longer GC runs (though at progressively lower CPU%).
I don't know about others, but it was my expectation that overall performance would take quite a hit for GC-heavy applications in 1.5.
It's not really suspect. The benchmarks reflect execution speed. The new GC trades a little raw throughput for lower GC latency. So you would expect a GC-heavy benchmark to show the greatest speed loss. What matters for go users, though, is the behaviour of real programs. Real programs benefit from the reduced latency of the GC and other compiler optimisations we have made since 1.4. The outcome, in our measurements, is roughly equivalent performance for most programs but with significantly shorter GC pauses.
Interop with existing libraries is certainly a worthy enough feature to add to the Go toolchain, and it's an optional feature, so ease of deployment is still a primary concern, but if you need DLLs, this is available.
Personally, I find that kind of thinking to be a relic of the past when memory and disk space were expensive and compilation took a long time.
Sure, if you're running on a raspberry pi, a few megs here and there might actually matter... but even my phone has 2gigs of RAM and 32gigs of disk space.
The nature of the modern computer is that cpu speed has increased more than memory speed, so if your data doesn't fit into cache your cpu will be do nothing quickly.
Even with shared libraries, this phenomena has such an impact that the Linux kernel now has a memory de-duplication feature (mostly for VMs):
The size of the binary is completely irrelevant when considering if the code fits in the CPU cache. What's important is the size of code that actually executes. Dynamic linking changes nothing.
That's not at all surprising considering that with static linking, each package is also built only once.
OTOH, it does well with the culture of making a lot of small, specialized executables rather than a single, monolithic application.
My point was rather that a 3MB executable used to be "large" and now it's not, even if you have 100 of them.
I don't know the background on this choice, but I've spoken to a few Go shops that have complained about memory usage when running a bunch of different Go binaries on the same machine, so hopefully this will help there.
However, this will probably deprecate or diminish the RPC and code generation techniques for implementing plugin architectures.
I thought this day would never come.
What the Go team is doing is providing the same level of access that C and C++ enjoy.
Which means that outside developing games or writing pure business logic, is all about JNI fun.
In fact, I really like using Go on iOS - the ease with which it can be done was astonishing!
It can be done, thus:
#cgo LDFLAGS: -Wl,-U,_iosmain,-U,_PopUpDialogBox
Any developer who wants to do this needs only to create these #cgo statements for whatever Cocoa API they want to use, and they become available from the Go context ..IIRC, Go can call any Objective-C code through cgo.
I read in then news that iOS9 will use Swift in some internal apps/libraries too (major internal rewrites?).
> to support Go packages that want to use plugins, a new package will be added to the standard library: plugin. It will define a function and a type.
https://docs.google.com/document/d/1nr-TQHw_er6GOQRsF6T43GGh...
[EDIT] I looked at the commits and it looks like it's not in the works, at least on the main repo.
GoCon - Tokyo, Japan - June 21 http://gocon.connpass.com/event/14063/
GopherCon - Denver, Colorado - July 7-10 http://www.gophercon.com/
GolangUK - London, UK - August 21 http://www.golanguk.com/
GothamGo - New York, NY - October 2 http://gothamgo.com/
dotGo - Paris, France - November 9 http://www.dotgo.eu/
I know it's an open topic, and there's no true "one way", but I'm wondering how people here would handle this situation. And perhaps it's my Python-addled brain that's the problem, since GOPATH is kinda sorta like PYTHONPATH, maybe enough to confuse me.
I have a repo at github.com/user/repo. It consists of independent but related applications, most in Python, one in Go. The Go project would be rooted in a "service" subdirectory.
I feel like I'm really missing some critical piece of a Go workflow, because I could never get that to build reliably when I started adding external libraries as a dependancy. It seems like I'd have to put the project in github.com/user/repo/service/src/github.com/repo/service, which is what makes me think I don't understand what I'm talking about!
To bring this rambling lazyweb back on topic, I guess I was a little disappointed that vendoring/packaging wasn't mentioned in this state-of-Go talk. I was really hoping I could easily give Go another shot, but in the absence of that, anyone have a suggestion for my setup above?
Your Go "project" goes in $GOPATH/src, i.e. your git repo would be in $GOPATH/src/github.com/user/repo
If you have your main pkg in $REPO/service, then you can build like so: go build github.com/user/repo/service (this can be ran from anywhere as it uses $GOPATH)
If you need to add a dependency, use: go get github.com/.... and go get will add it to $GOPATH/src/ which you can then import.
Thanks!
Tell me more ...
As you know, generics won't appear before 2.0, if ever. It's fine if that's a nonstarter for you. Perhaps you'll like Rust instead. It needs a big community too.
I guess people compare Rust and Go because they were released in similar timeframes and people like to view things in competition.
Rust is especially attractive when you can't afford a garbage collector, need deterministic destruction, and full compatibility with C. It's what C++ would be if it could start from scratch.
I think your point needs to be re-iterated more often: if garbage collection and ~2-3x the running time of C is not a problem, OCaml, Haskell, Scala, F#, etc. are the competition of Go. They integrate modern (read: mostly 70ies/80ies) language design insights, while providing approximately the same performance as Go.
People get bent around the wheel all the time with the tiny niches but both seem well equipped for writing user land applications and are designed to be safer than C and it's cousins. Both have some legitimate interest in them which is what really differentiates them from like D or Ada. Neither is going to be used for kernels (maybe I should say 'serious kernels') and drivers any time really soon. They have a lot of similarity in those regards.
Seems like a golden era to have 2 competing languages that are aiming at C and C++ and have legitimate community interest.
Whenever Go is mentioned, Rust has to be mentioned somewhere in that same thread. And vice versa. It's practically law.
Perhaps a good indication that the debates tend to be more fashion-driven then about technical points (when the discussion is about new languages itself, that is of course reasonable though).