231 points · by astdb · 9y ago · 154 comments
Hooray!
No more Makefile spaghetti like this (well a bit less anyway!)
GO_FILES := $(shell go list ./... | grep -v /vendor/ )
go test $(GO_FILES)
go tool vet . 2>&1 | grep -E -v vendor/ ; test $$? -eq 1
errcheck $(GO_FILES)
find . -name \*.go | grep -v /vendor/ | xargs goimports -d | grep . ; test $$? -eq 1
go list ./... | grep -v /vendor/ | xargs -i golint {} | grep . ; test $$? -eq 1
should become go test ./...
go tool vet ./...
errcheck ./...
goimports -d .
golint ./...
I assume the `./...` changes will just work in `errcheck` and `golint` but I suspect `goimports` might need a bit of work.[1]: https://github.com/ipfs/go-ipfs/blob/master/coverage/Rules.m...
[2]: same file as [1], we compile unit test using `go test -c -cover` that runs our main function and saves the return value to file ([3] and [4]), but it works. If someone considers doing that, run everything in ramfs (tmpfs).
[3]: https://github.com/ipfs/go-ipfs/blob/master/coverage/main/ma... [4]: https://github.com/ipfs/go-ipfs/blob/master/cmd/ipfs/runmain...
I believe Go at Google does not have same relationship as Java at Oracle or Swift at Apple.
That's correct - GopherCon is a community effort. It originated when a community member expressed surprised that there wasn't already a Go conference, and then, upon encouragement from others, decided to organize one themselves. They remain the organizers of the event, and they do not work for Google.
Google has been a diamond-level sponsor for the last three "main" GopherCon conferences[0], but no different from any other sponsor of the conference in that regard. And that's by design - the Go project aims to be a community effort, not solely the work of Google employees, although Google does hire a small number of people who work on it full-time.
This isn't inherently better or worse than the model that (for example) Oracle uses with Java. It's just a different philosophy - and in the case of Go specifically, one that everyone involved seems to be happy with. The Go project contributors (including those employed by Google) want it to be a community-driven project, and the Go community members are by and large happy carrying the mantle themselves as well.
[0] GopherCon happens every year in Denver, but there are tons of other conferences around the world that carry the GopherCon name - for example, GopherCon Singapore is happening a week from today[1]
[1] And, similarly, traces its origins to a single tweet from a community member expressing interest in a conference.
Could you tell me more about it, please?
Swift: "Swift and the Swift logo are trademarks of Apple Inc."
OpenJDK: "© 2017 Oracle Corporation and/or its affiliates "
Go: "Except as noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and code is licensed under a BSD license."
Google never cared for Go.
It wasn't created as a strategic project or investment. It's a language created by a small team on Google doing their thing.
It does keep paying them to work on Go though (and probably devoted some more people to it), so there's that, but Google neither hired them specifically for Go, nor requested that they work on such a project from the onset.
It was also never made THE official language for Google development by some decree, nor was getting it to Android any priority (they favored Kotlin for that in the end). Neither was it ever strongly marketed by Google to outside developers.
Dart/Angular got more of an official "sponsoring" from Google (including devoting a top notch compiler guy like Lars Bak to work for the former) than Golang. From what I've heard, it has seen adoption inside Google, but nothing game changing.
Compare golang.org with dartlang.org: the former does not mention Google in the front page at all, where the latter does.
Genuine question as they have more in common than just curly braces it seems.
I know they are _different_ but the question is: is it possible (not completely stupid...) that the future of those languages is going to be a merge (kord, darlin? ;)
It'll be interesting to see how Go will cope with Kotlin/Native (in technology preview stage right now)
Kotlin has no unsigned types (JVM language). In embedded / IoT applications that's a downside. It seems that unsigned types are the only major advantage Go has over Kotlin/Native.
What is there to cope? Go is winning in market pretty aggressively. Kotlin native has nothing to offer over languages which were designed free of JVM / Java baggage like Go/Rust/Swift.
Also Java 9+ itself is going to offer AOT compilation for those who have to use Java and want native too.
Kotlin may be fine language and Google added a low effort support to Android. It may get more popular on Android but it is about as old as Go but here is trend for the two in general:
https://trends.google.com/trends/explore?q=%2Fm%2F09gbxjr,Ko...
Kotlin also lacks value types necessary for efficient memory layout and high perf/low latency GC. Build system as gradle/maven might cut for Java but Go user are used to fast/inbuilt tools like go build/run/install etc.
On HN maybe, but in the wider world, and the enterprise, not so much (if at all).
>Kotlin native has nothing to offer over languages which were designed free of JVM / Java baggage like Go/Rust/Swift.
How about less complex than Rust, less associated with Apple than Swift, and better designed than Go? And with serious compatibility with Kotlin for the JVM -- which boosted by Android adoption will get quite big soon.
This form of AOT doesn't free you from the JVM though. It's cached machine code but it still needs the VM to run.
https://blogs.oracle.com/darcy/unsigned-integer-arithmetic-a...
The reason why Java didn't got unsigned types was because Gosling went around Sun R&D offices asking about unsigned arithmetic and almost everyone got it wrong.
I miss them when in Java though.
Maybe R&D would be busy making cool demos of futuristic technology which could beat Microsoft's cool demos.
I switched my current project from Dart to TypeScript. I think Dart is the better language, with a decent standard library, but getting interop working for various JavaScript languages was just sucking up too much time.
I'd love to have used Scala.js, especially since the rest of the project is written in Scala, but again, interop issues.
"Prototyping to Production: Bridging the Gap with a Common Tool"
"Single Codebase, Two Apps with Flutter and Firebase"
There are also codelabs for Flutter.
I mean Kotlin is the baby of JetBrains, the creator of the IDEA IDE that is used for Android Studio.
Pandoc is pretty similar, just as powerful, and supports multiple output formats. That way you can statically host random files without depending on a go binary running 24/7.
Also be careful with present, it by default runs a sandbox to allow execution of code/examples that I wouldn't trust open to the internet... at least without good justification.
That is being sad, Go is still not as mature as other language such as Ruby, Java, Python,...etc in term of eco system around web application.
Take database for example. Any web app needs to interact with MySQL, MongoDB etc. But the performance of those drivers are somehow lack behind when I compare them with other driver. MongoDB/MySQL drivers are both seems come from individual works of excellent/talented developer than official support from those database.
Go shines in system/devops stuff though.
Especially considering that sync.Map just uses a mutex under the hood: https://github.com/golang/go/blob/master/src/sync/map.go#L19
edit: although reading the comments, apparently there are conditions where the mutex does not always need to be held. This would be an improvement over sync.RWMutex wrapping.
I really gave Go a good shot, built a project of decent size with it and used it as my go-to first choice for a few others, but every time these little nitpicks come back and make it feel like Go is smacking my hands away from the keyboard. "Bad programmer! You didn't do it the way I wanted you to!"
I would love to use a hypothetical "Go++" that's built from the same roots of Go but forgoes its opinionated nature, even if it's at the cost of messier code. Someone somewhere has to be working on that... maybe I should give it a try.
Absolutely not. Have you never worked with anyone who just can't adhere to any standards? Go forces that guy at my office to at least get spacing and braces right, even if the rest of his code is lacking.
It's generally expected that all commits to code are in the gofmt standard, and there's not even the option to change the format.
I suspect if you analyzed all the code on github that go would have much higher compliance with the gofmt standard that you'd find to any other single standard for java or c++.
Gofmt is pretty nice, I wouldn't make the same decisions myself, but it's pretty valuable to have all code I see with exactly the same formatting. Additional gofmt uses the same parse as the language and can even parse, modify, and invert to produce a new source file. Similarly it's much easier to write a golang aware editor than most other languages.
also, having all code use the same style means you can safely search for semantics just using a syntactic pattern.
And frankly, there are more important issues with writing code than which line an opening brace should land on.
My point is everyone will have their own personal preferences about style guidelines and argue that theirs is the most readable but frankly the most readable is just whatever you spend the most time reading. So you quickly get good at reading other language style guides when you spend time coding in their respective languages
[^1]: https://github.com/openssl/openssl/blob/7a71af86ce75751f3cb2...
my personal style would be more condensed than gofmt, but it doesn't make any choices i think are really stupid.
what bugs you out of curiosity?
Because a semicolon is inserted whenever the parser encounters an identifer or a token that's not in a special restricted set that includes ( and {, you end up with a semicolon inserted between a control flow statement and the bracket.
I suppose the grammar could have been modified to require that control statements include parens, or that the bracket become part of the control statement, but that's also kind of ugly ...
I genuinely can't tell if they're joking or not.
It should be:
> http.Get
> http.Please
> http.Thanks
With Go, they will keep adding special case after special case.
Eh, in most languages you'd still need language support if you want quaternion literals.
Go doesn't have any form of customized operator overloading. If something needs to look like a number, it has to be in the base language. Stuff that isn't, is second-class even if it's in the standard library.
Ironically, this is the case for big integer / floating-point numbers - you have to write things like x.Add(y, z): https://golang.org/pkg/math/big/
https://insights.stackoverflow.com/trends?tags=go%2Ctypescri...
But it's dwarfed by c, c++, and javascript. Graph when you add a bunch of other languages:
https://insights.stackoverflow.com/trends?tags=go%2Ctypescri...
https://insights.stackoverflow.com/trends?tags=python%2Cjava...
Bottom line: he proposes that one should never take away a function/API (particularly when you are a library or programming language).
https://www.youtube.com/watch?v=oyLBGkS5ICk
edit: superficial word choice
c) is speed essential? d) are you doing systems programming as opposed to CRUD webapps?[1] These might lead you to Go.
[1] I know you can do the latter in Go, but it's unclear that it's as easy/productive as in other langs currently (nor have I directly compared, say, Revel to other frameworks, so someone else is probably better qualified to answer this question.)
https://www.techempower.com/benchmarks/
As you can see the top frameworks are all C++ or Java. A Java servlet based framework clocks in 3rd with 178k/sec. Go's first entry is at 10th place with 141k/sec.
The next time go appears it's the "kami" framework with just 58k/sec - slower than nodejs!
Why do you need a whole "layer" for this? I recently wrote a microservice in Go with a JSON-emitting RESTy API, and my JSON serialization layer is two functions for a total of 20 limes: https://github.com/sapcc/limes/blob/0735bd6de4e49f900ab8d97a... (ignore the unrelated function inbetween; I cannot select non-contiguous areas in GitHub source code listings)
Java (and kotlin) are faster than Go in almost all cases (except for startup time) (and even there difference is shrinking, plus you get a lot back for that startup time). C, if you must, is faster still, and C++ can be faster as well.
As a quick (and inaccurate) rule, any program that runs longer than 10-20 seconds will be faster in Java than in Go.
https://benchmarksgame.alioth.debian.org/u64q/go.html
However, perhaps as you indicate these are including JVM startup time and thus tainting the results. For some reason I had gotten it into my head that Go was faster than Java, but it's been a couple of years since I've used either one, so I definitely may be off on that point.
"faster than Go" could mean any compiler
That said, I'm not convinced that Go's place on that scale is useful in general. It feels like, if raw performance is desirable, then something like Rust - with stronger static typing (and so no overhead on boxing values as interfaces, for example) and no GC is going to be better. And if higher-level, more powerful abstractions are required, then something like Kotlin is going to be better. Go is in that awkward spot where it makes you give up enough of the latter to be painful, but doesn't really make up for it with more of the former.
Of course, this is a subjective opinion. YMMV.
And if course, if you have even remote plans of doing anything on Android...It now makes much more sense than ever
How does Kotlin handles concurrency? Now I've heard that Kotlin has a "Kotlin native" version. I didn't try it yet, but if that's the case and it has good concurrency support then Yes, in theory it could compete with Go, more than Scala native would, Scala is too complicated for the kind of audience attracted by Go.
People coding in go for real world projects usualy know that go fits the tradeoffs they're looking for.
A: 1970