Hacker News new | ask | show | jobs
by mukaiji 4952 days ago
Anyone has a good summary of Scala vs Go? I know a bit of the former (with typeface for high-concurrency) and was wondering what Go might have to offer.
3 comments

Go is far simpler and smaller. You can learn go in an evening. It comes with a nice standard library, but the ecosystem isn't as lively as what you get on JVM. But if you have native library for a task, using it from Go is straight forward. Web frameworks are in their infancy. Writing network programs in Go is a pleasure. You write code in the natural way(no callback spaghetti) using go-routines, and go takes care of making it non-blocking. The go oop is structural sub-typing based. Though it might seem lacking at first glance, it's actually quite wonderful.

Bottom line: Learning go is far simpler than learning Scala. Read and write some programs, and make up your mind. Here is an example you should read through to get a feel of the language.

http://golang.org/doc/codewalk/sharemem/

C is far simpler and smaller than Go. Languages are optimized for different things, depending on their context. They all have a place.
> C is far simpler and smaller than Go.

Mentioning Go is simpler than Scala is to point out the difference to OP, and to emphasize that trying out Go doesn't take much effort.

> Languages are optimized for different things, depending on their context. They all have a place.

I am not denying that. That's why I said - Read and write some programs, and make up your mind.

Yeah, I like modern languages that don't need an IDE or other complicated mechanisms to get started. Go seems to have made a lot of good design choices too.
great response. thanks!
Well, both have good support for concurrency through Actor implementations. They have a little bit similar syntax, both have a basic level of type inference. After that, pretty much everything is different about them.

There are really too many differences to consider, but some things come to mind first. I apologize for the problems in this description. At some point I may write a detailed article with examples, so any feedback on inaccuracies in this would be helpful.

Go is designed as a minimalist language. This has some benefits and drawbacks.

Scala is design as a language that is small but very extensible, making for a much larger programming system that you have to learn to use effectively.

Scala has lots of advanced language features from functional programming. Idiomatic Scala uses these features extensively. Go has closures, but not any other features for functional programming - for example it has no immutable data structures, no pattern matching, no tail optimization.

Scala has advanced features from object-oriented programming; everything is an object but basic types are compiled to JVM primitives where possible. It has traits/mixins which provides a way to implement multiple interfaces but they can also provide implementations which makes it a lot easier to provide default implementations so that a previously-written class can be declared with that Trait even though it does not know how to satisfy the interface. Go has a simplified and in some respects novel approach to OOP. It has interfaces and duck-typing which may be familiar but you really have to learn "the Go way" to understand what is happening with features like embedding which may seem to have some superficial similarity to inheritance in Java/C#.

Both provide a means to multi-plex Actors (Goroutines) onto threads. Using the Akka package with Scala provides an Actors implementation which will work with both in-process and out-of-process Actors. Google's netchan package was dropped before 1.0 and I do not know if there is any productive development being done in this direction. So to scale goroutines out of a single-process you'd need to use RPC, zmq or some other low-level socket approach.

So far, the Scala code I've looked at in different open-source projects seems fairly consistent. While the language-space seems big, I have not seen the fragmentation problems that some people may have predicted. With Go there is little chance of this, often there is only one reasonable way to do a given thing.

Go compiles to native code but the compilers are optimized for very fast compile times - the code produced is 2-3x slower than Scala in doing math-intensive benchmarks. For most apps we'd actually write, I'll bet they are pretty close. Go statically links a runtime and has garbage collection. It starts up VERY fast compared to any JVM application.

Scala takes more time to learn, but targets a different audience. Scala runs on the JVM which lets you leverage Java libraries etc. For long-running apps Scala is usually faster than Go, but will use more memory than Go.