7 ms·
Ask HN: Should I learn Scala or Go?
I understand they're from two different paradigms, and I'm interested in learning both to some degree, but I would like to heavily commit to mastering one.
I'm a Python developer. This is probably at least 1 + vote for Go, since there are quite a few Python developers that have learned Go and a lot of articles have been written specifically for people like me. Scala, on the other hand, tends to be similarly popular among the Java community (Scala runs on JVM, etc.). I'm ignoring this fact for the time being, and I'm ignoring the difficulty of learning each language for this exercise. I'm primarily interested in thoughts on:
1. the languages' communities as a whole
2. the languages' qualities/problems (be subjective - this is not StackOverflow)
3. the possibilities of personal economic gain from learning each (e.g., where/why do you think your choice will grow, etc.)
- osipov 12y agoScala
- mangeletti 12y agoThanks for the reply. Would you mind explaining why you choose Scala?
- icedchai 12y agoScala is syntactically complex, compiles relatively slowly, and some of the tools (IDE plugins) are terrible. Or, at least, they were a few years ago. On the positive side, you'll have a more mature ecosystem of third-party libraries since you'll be able to tap into everything Java offers. Go, on the other hand, has a simple syntax, excellent tools, and compiles lightning fast. Depending on what you're doing you may not have the library support you need.
- mangeletti 12y agoThanks for the reply and the data about each. Compile time is actually something I hadn't given one iota of thought about, likely because I've never really worked in a compiled language. I imagine this is a huge pain when you want to make a quick production change or you just like to get quick changeset feedback.
- deferpanic 12y agoc++ had huge compile-time issues which is one of the motivations behind go's compile-time speed - it feels like you are working in a dynamic language
- kasey_junk 12y agoIt is largely not a problem for that because Scala's incremental compiles are reasonable and test time dominates build times in either case. The speed of the go tool chain becomes a huge asset when it comes to integrating with other tools. This allows freedom to use the environment you as a developer want to use. Being able to work exclusively in vim/tmux after years of needing intellij to be productive is a breath of fresh air.
- giaour 12y agoCompilation is speedy enough that you can just use `go run` in development and it feels like running a python script.
- deleted 12y ago[deleted]
- tptacek 12y agoGolang if you're writing systems-y network-y code more than application-y database-y code. Scala if you're more interested in language theory and statically analyzable correctness. Or, again, if you're doing anything database-intensive. Golang is a very pleasant language to get systems-y things done in. I'm fond of saying that it's not an amazing language, but is an amazing programming tool. Scala is going to be much friendlier to you if you're into language features; generics would be a big one, pattern matching is a Scala-y one. Are you writing web apps? I'd give the nod to Scala. Are you much more inclined to write a web service, something that spits JSON out instead of HTML? Golang back in the running. IRC server? Golang. Social network? Scala. Emulator? Golang. Compiler? Scala. Do you like C, even though you never use it anymore? Golang. Do you think a lot about someday learning Haskell? Scala. Are you picky about languages? Golang will occasionally frustrate you with the things it lacks. Scala will occasionally frustrate you with the things it has. They're both good languages and --- unless you need a graphical UI (in which case: Scala) --- both of them will do better than Python for almost any task.
- mangeletti 12y agoExcellent, thanks for the breakdown.
- deleted 12y ago[deleted]
- deferpanic 12y agoI'd just like to point out that most of our customers have webapps written in go - not just JSON apis so this argument that go is not for webapps is at best incorrect. I talk to gophers around the world everyday that are using it just for that. They much rather hack on a webserver that they can use in 15 LOC from stdlib than some beefy JVM framework. From the conversations I've had I strongly believe most webapps are going to be written in go in the coming years.
- tptacek 12y agoI'm a full-time Golang developer, the last product I shipped was a Rails app, and my career started in the 90s as a shrink-wrap C software developer. Golang is an unpleasant environment in which to build web applications: * Good SQL persistence abstractions aren't there yet, so realistic SQL-backed applications depend on writing tons of raw SQL and (worse) parsing results. Like a savage. * Golang's built-in templating is good for self-contained full templates but not great for hierarchies of templates and partials. * Golang's net/http library is so good that it's a gravity well for other request handling abstractions, so that sessions, CSRF tokens, and access control either have to be built directly on Golang's equivalent of Rack, or inevitably get put into libraries that conceal too much of net/http. "Going with the flow" and writing idiomatic Golang code feels a lot like writing those Sinatra apps where you get 1/3rd of the way through and regret not just using Rails. You can totally write a good web app in Golang, especially if you're doing minimal serverside HTML generation and leaning on something like React or Angular or Ember instead. But it's not what Golang is best at. Meanwhile, Scala is both a language designed in part for serverside web apps and built on the JVM. If you're writing a web application, where your functionality is exposed by a port 443 that Firefox connects to directly and asks for "/" from, I'd prefer Scala to Golang. Reasonable people can disagree or object to any of this, but I'm not going to waste time sugarcoating.
- kasey_junk 12y agoFor background, my last few years experience were in Scala and I'm now writing golang systems. Item 1: Both golang and scala communities are large enough now that you aren't dealing with lack of community as an issue. There are very bright people working in both communities and there is a lot of passion for the languages. Unlike something like Java or Php, if you are working in one of those languages it is largely because you want to be. That said, I'd say both communities suffer from an abundance of arrogance that is above normal for other languages. Item 2: You can learn go in a couple of hours. Its warts are obvious on casual inspection and typically if you aren't doing something the "go way" you will pay for it. This usually isn't a practical problem but occasionally the "go way" leaves you stuck. It took me a solid year to learn Scala to the point I would call myself competent. I still have zero degree of confidence in dropping into an existing Scala project for the first time. Part of that is a design decision as there is "no" Scala way. Part of that is the community itself has a large contingent of language tinkerers who will try out experimental features. But I've never seen a problem that couldn't be solved in a Scala code base in an "elegant" way. Incomprehensible is also easier in Scala. Item 3: I doubt there is any way to predict this and it is largely not the way I would choose a language. Personally, golang the language irritates me like crazy. I do like the simplicity for small web services or cli tools though. If something starts approaching the "bash is too much" here, I happily do a quick golang program. This is more a function of the go tool chain than anything else, but if golang has proven anything, its that the tool chain matters. Conversely, I doubt I will ever write a system again in Scala. I'm glad I did, and learning Scala made me hone some development chops I wouldn't have otherwise, but it isn't something I love programming in (even though it doesn't irritate me like golang does). My advice would be to learn Scala, but that is largely because I think paradigm shifts are more long term rewarding than language/framework shifts. Golang hasn't taught me anything I didn't already know and if you do need to learn it for a job or something it isn't hard to do.
- brudgers 12y agoLearning Scala in a significant sense of learning, means also learning the JVM, SBT, and some degree of Java because "That's stack, Jack." Scala errors sometimes talk in terms of Java and having a mental model of Java helps a programmer parse them (it's like Clojure in this way). I don't see either as high market share among general purpose languages. There are almost certainly more jobs in Python than both combined.
- runT1ME 12y agoIf you can afford the JVM (hardware wise and startup time wise), I think Scala wins hands down. Now, people will say "Scala will be better for it's type system and correctness, and Go will be better for performance/network applications". But they'd be wrong. You can check out here: https://www.techempower.com/benchmarks/ https://www.techempower.com/benchmarks/ If you compare scala (scalatra in this instance) vs. Go for multiple queries, you can see Scala's more performant than Go. Part of this is because the Go GC is still new, while the JVM has had a lot of time to tweak things. For network apps, Scala plays quite nice with Netty, which is the JVM's non blocking asynchronous network framework. So, I think you should learn scala if you want to stick with server side code. However, some reasons you may not want to pick scala: 1. You'll be more productive quicker with Go. I think C# folks can be productive with Scala right away, but from python it will take you some learning. 2. Tooling. Scala's tooling is sub par compared to some other languages, so there's definitely a period of learning the language where you don't know enough to get a productivity gain, but the tools can still frustrate you. 3. JVM startup time. I imagine Go is always the better choice for anything client side.
- bontoJR 12y ago1. Both communities are big enough, if you are in Asia, gophers are everywhere 3. If you don't have any knowledge about functional programming, Scala will open you a new world. It will force you to think in a different way and will introduce you to many new concepts in how to solve parallelism and asynchronous computation using easy concepts like immutability or far more complex like functional reactive programming or duality. 2. I worked with both languages, I liked the fact I was able to write a whole, easy, REST web app in just half a day with Go, but the syntax and the verbosity in error handling, made me kind of crazy. I would definitely say that is a very good language, extremely fast compared to others like Ruby or Python and it can be even a very good complement to Scala. Scala is my favorite language, by far, for server side projects. It requires time to be mastered, there's never a "Scala way" or a single way to solve a problem, but there's (almost) always a best solution. Twitter's scala school[1], for example, is a good place to see examples about when and how to use certain language features. The fact that runs in the JVM, a Virtual Machine with 20 years of development, improvements and optimizations, is almost a killer reason to pick Scala. I worked with Java/Spring/Hibernate in the past, a very frustrating experience, but Scala changed my mind about the JVM and opened a completely new world: Functional Programming. Now I know and use concepts like Monoids, Monads, Future/Promises, Reactive Programming, Actor Model, Duality, etc... without any problem. It's a complete different world and I think it deserves a shot. [1] https://twitter.github.io/scala_school/ https://twitter.github.io/scala_school/
- deleted 12y ago[deleted]
- throwawuy222 12y ago(throwaaway here) Before you waste the next few months of your life learning a corrupt programming language: - Typesafe co-founder quits: https://www.youtube.com/watch?v=uiJycy6dFSQ https://www.youtube.com/watch?v=uiJycy6dFSQ - https://vimeo.com/64716826 https://vimeo.com/64716826: Paul Dix - Why Node and Scala will dry up: Go will drink their milkshake - I can personally tell you, scala is awful at handling large codebases and is so filled with idioms, you have a difficult time reading it. I remember opening scala code, seeing english, but it felt impossible to decipher. - You feel clever when you write it. No doubt about that. Other programmers and your customers don't care. - Compilation time: It's atrocious, we're talking 1 to 10 minutes to compile web apps. - Package dependencies: You end up incorporating java at the end of the day. Version mismatches. - As for the "functional language" thing, just pick real Haskell or Ocaml. Don't fall prey to scala being a functional language. - You need to rely on a huge, laggy IDE with missing / out of date plugin packages to get autocompletion. On the other hand, Golang: - compiles these massive applications in line 2 seconds. - It's highly lintable. - The syntax is just... dumb. - Yet you don't feel limited at all. - It runs fast-fast-fast without having to rely on JVM. - Familiar syntax... like a hybrid between Python and C - You can import packages from github / git repos, automatically grab dependencies with one command. - The build system and tooling is simple and genius - Autocompletion (https://github.com/nsf/gocode https://github.com/nsf/gocode) OP: I hope you don't waste your time on a scala venture. Scala has it's die hard fanboys, especially those who spent 15 years in java and have too much of an ego-investment to think anything else, but even the co-founder of typesafe, the most prolific committer says the language is a mess.
- d4rkph1b3r 12y ago> the most prolific committer says the language is a mess This is a lie. He says the compiler implementation is a mess. he's still a contributor and involved in the language. Second, your argument is basically you aren't smart enough to write/read scala. I love it. I have more faith in the OP. Not everyone needs idiotic languages that ignore 30 years of programming research to coddle their fragile ego. We're not all like you.
- throwawuy222 12y ago
- fiatjaf 12y agohttp://rosetta.alhur.es/compare/scala/go/# http://rosetta.alhur.es/compare/scala/go/#
- flippant 12y agoI find that the Go and Scala versions for most of those examples both take the same amount of time to read.
- throwawuy222 12y agoThis isn't an accurate depiction of what scala ends up looking like. If all scala stuck to simple idioms like in the example, it'd be an excellent language.