I don't know much about Go (I use .net mostly), but would be curious to hear some reasons to choose it over JVM/CLR.
I don't know much about Go (I use .net mostly), but would be curious to hear some reasons to choose it over JVM/CLR.
The Good:
* Performance. Java and the JVM are certainly performant once things get going, but Go and other compiled languages are at peak performance out of the box. Go should generally be a bit faster or equal speed to Java and should use a fraction of the memory. Here's some microbenchmarks that look good for Go vs Java: https://benchmarksgame.alioth.debian.org/u64q/go.html
* Concurrency. Go makes it simple to communicate and synchronize with other threads, and the co-routine model allows for expressiveness in async without running into callback hell.
* First-class Functions. Some JVM languages have this, but even Java 8 doesn't have the ability to set a variable equal to a function definition. Coming from Node, Python, C, C++, etc. Making functions first class citizens helps a lot.
* Interfaces. Go has auto-fulfilled interfaces that you opt-in to by writing the functions they require. The compiler figures out which types match an interface for you, instead of you specifying it. This is probably my favorite feature of Go. It feels like duck-typing with type-safety.
* Unicode support. Go has excellent unicode support, which I don't think any JVM language has. Javascript also has great unicode support. This is probably a big one for someone doing a lot of web-based application deployments.
* "Batteries included". Go's standard library is amazing. All the basics you'd expect like string manipulation and math functions are there. They also have a dead-simple http server/client that supports http2 and SSL. Full crypto libraries with key-management. Encoding/Decoding for csv, json, and xml built into the standard library, even compression formats. The standard library feels really good to use compared to C++ and Java for me. C# I believe is on-par with Go as far as built-in libraries go.
* Compiled and statically linked. Go only does static linking for Go code, and does interoperate with C (but it's awkward). This means you compile the Go program and then run it, the runtime is in the binary. There's no worrying about versions of your JVM and ensuring that class paths are set up correctly. A single binary executable is all you need and what you get out.
* The tool chain. Go comes built in with documentation generation (really nice stuff, everything on golang.org/pkg is automatically generated from the source and comments), testing facilities (including coverage tools and benchmarking), and dependency gathering (like pip without the versioning). The dependency gathering uses VCS, so you can point it at any mercurial, svn, or git repo and Go will go download and put it in the right spot for you. The compiler can do cross-platform compilation from your local machine (on windows machine, compile for linux) with some playing with the settings. There's a race detector, code formatter, and version upgrade tool in there too.
The Divisive:
* Error handling. A lot of people I've seen using Java/C# like exceptions for error handling. Go doesn't use exceptions except in exceptional circumstances (and no try catch when that happens). Go instead recommends you use secondary return values (since you can return multiple values) for your errors. This leads to a lot of code that says `if (err != nil) { return nil, err }`. I find that in my first pass, that line is everywhere, but when I start building toward production of the system, I'm responding to the errors fairly deep in the call stack and the number of default error lines drops dramatically. Your mileage will vary.
The Bad:
* No generics. This might be a deal-breaker for you, depending on how you like to program. Go has first class support for a simple hash map (generic) and dynamic arrays (with slicing semantics similar to python) (generic). Every other generic collection type you might want will be made yourself, made by code generation with a third party module, or lacking any type safety through the use of `interface{}`. Generics are probably going to come at some point, but not yet.
* Package version management. While Go makes it easy to get the latest version of a package, Go does not have a robust package version management system yet. Getting the specific version of a package your project needs is difficult and error prone at times. Third party tools are currently the best way to deal with versioning and freezing your dependencies. Hopefully the `dep` tool or something like it will become a first class part of the tool chain, but it's not there yet.
* Debugging and IDE support. There's still not a lot of IDEs that support Go, but it looks like JetBrains may be fixing that soon with a dedicated IDE: https://www.jetbrains.com/go/
* Lack of expressiveness. In Go, there is often only one way to do things. Go is specified in it's entirety in under 30k words. You can write a whole compiler based on that information. That means it's lacking a lot of nice syntax that's become popular: Option types, pattern matching operations, decorators, lambda expressions, etc.
That's a tricky one. Right now it's wonderful, because all the included core modules are recent and relevant. I suspect in a decade you might find that the core modules are somewhat more crusty, sometimes support defaults that don't necessarily make sense with what's the common standard at the time, and is hard to change because of backwards compatibility. You might find in a few years you're not using the built in SSL library, or the http2 implementation, because better (either through capability or interface) alternatives have come about, and the core libraries start to look really annoying as you have to continuously tell new users to avoid them in lieu of the current best practice, which is not in the core libs.
It's a trade-off these languages make when designing their core libraries. There are upsides and downsides to both approaches, but one isn't necessarily clearly better than the other overall (even if different approaches have stronger outcomes when the language is new and when it's mature).
Eh. Go certainly starts out faster and is faster in some benchmarks, but in most workloads Java is faster.
> but even Java 8 doesn't have the ability to set a variable equal to a function definition
Function<Integer, Integer> f = x -> x + 1;
> which I don't think any JVM language has.Java (and so all JVM languages) has had Unicode support since at least 1997.
> The standard library feels really good to use compared to C++ and Java for me
I think you haven't seen Java's standard library recently.
> The tool chain.
This is one area where Java is ahead by a large margin in almost every single component you list.
For me, Go shines for small applications, and especially small command-line tools, for which the JVM is not a great fit. It's easy to learn and get started with, and the deployment is convenient. But for anything big, Java wins hands down, in robustness, ecosystem, debuggability and serviceability.
I can't find any data to back that up, can you point me at some?
> Function<Integer, Integer> f = x -> x + 1;
Fair point, didn't know about Function
> I think you haven't seen Java's standard library recently.
I dislike the standard library. It feels kludgy, as if things were added haphazardly for the last 20 years. It's still missing valuable things that have been around and proven to be very common and desired, like format reading/writing (CSV and JSON come to mind). The HTTPServer implementation is even in com.sun.* and isn't part of the official standard library. Oracle even has a page telling you not to use it: http://www.oracle.com/technetwork/java/faq-sun-packages-1422...
> This is one area where Java is ahead by a large margin in almost every single component you list.
Java as an ecosystem, they may be ahead in some ways (IDE + Gradle). But Java is not, they are missing most of the components I listed. You have to use an IDE and Gradle/Maven to come close to the out-of-the-box experience with Go. And I did note that IDE support is one of the negatives.
These[1] are some recent results of the computer language benchmark game, where Java beats Go overall even though startup time is measured (similar results here[2]). How much faith you'd want to place in these benchmarks is questionable. As to real workloads, that's what people I know at Google tell me.
> It's still missing valuable things that have been around and proven to be very common and desired, like format reading/writing...
I don't think any of it should be part of the standard library. In fact, one of the best things happening with Java now is that the standard library is being broken apart, and things like XML, cryptography and JDBC are taken out of the "base" module.
OTOH, a standard library should provide truly foundational stuff, like good data structures, deep monitoring infrastructure, things that Go seriously lacks.
> You have to use an IDE and Gradle/Maven to come close to the out-of-the-box experience with Go.
But that's because the Go ecosystem is poor in comparison. The Java ecosystem is so strong and well established that the "out of the box" package simply can't compete with it (and when it tries -- as with the logging API -- it loses). Go had to provide this stuff out of the box because there was no ecosystem. True, this makes Go much easier and more pleasant to get started with for beginners, but you can't compare something that's built around an ecosystem, and something built to be self contained.
[1]: https://sites.google.com/view/energy-efficiency-languages/re...
[2]: https://benchmarksgame.alioth.debian.org/u64q/compare.php?la...