top | item 11264454

Scala School

224 points| alongtheflow | 10 years ago |twitter.github.io | reply

173 comments

order
[+] pcx|10 years ago|reply
Learning Scala is such a pain. Either you follow a large book completely and master it across several months/years or go through overly complicated online guides and get discouraged. I understand it's a large, advanced language, but the community has to seriously work on making things a bit easier for beginners like me. Just look at how easy it is to learn Go or Rust, their official tutorials are amazing and free on the web.

Here is what worked for me to learn the basics well: I started off with the book 'Scala for the Impatient', the first half of the book is freely available. I then used Scala School as a list of topics and researched on each using Google. StackExchange has some amazing answers that helped me a lot.

Free part of Scala for the Impatient: http://fileadmin.cs.lth.se/scala/scala-impatient.pdf

[+] hythloday|10 years ago|reply
I've taught Scala to tens of engineers. The golden path is the Coursera course "Functional Programming Principles in Scala"[1]. It's a pretty comprehensive set of lessons, by the author of the language, of how to tastefully compose the basic elements of Scala to solve interview-sized questions. I really think that Martin Odersky's skill as an educator is a highly underrated part of the success of the language.

[1] https://www.coursera.org/course/progfun

[+] salex89|10 years ago|reply
This might be true, but I don't think it is hard as the general opinion is. I think it's mostly about the technique and patience. You can't expect miracles at once or a wow factor. I generally started using it for smaller projects or parts where I could experiment a bit, and started using it as a better Java. I also played CodinGame with Scala. As things caught pace I started evolving it a bit and looking into refactoring and so on. Too be honest, I'm not too advanced, but I kinda like the pace. Word of warning: Java is still my main language at work, but the language choice is not my decision. However, whatever happens with Scala or me in the future, one thing stays, I became a better Java developer because of Scala. Also, the colleagues got interested after looking into some Akka Streaming apps :D .
[+] 20andup|10 years ago|reply
I actually had the opposite experience. Yes, Scala takes some time to digest but I didn't find it particularly hard. I come from a C# background and Scala just makes things so much easier to code once you get the hang of it. On the other hand, I tried learning Go before picking up Scala. Something about it's handling of concurrency just didn't sit well with me. Perhaps it was because it was so different for C#. I never really got a good hold of it.

For me Scala has a little bit more upfront cost to learning (but if you come form Java and C#, it should almost be second nature) but the things you can do with it once you get a hold of it is amazing. Go (for me) on the other hand is very easy to write simple Hello World programs, but if you want to do complex applications, it has much more down payment.

[+] chuwy|10 years ago|reply
I agree about painful learning curve for Scala. Problem I think in very divergent community and in different approaches for a every single problem (unlike for example Python or Go): OOP vs FP, Typesafe vs Typelevel, scalaz vs cats, Cake Pattern vs sanity.

There's a also a problem that most powerful Scala techniques are there "by accident" [1] and unlikely will (or should) appear in official guides.

Also I disagree that "Scala for impatient" is good book for start. It make me feel Scala is dump of random unrelated features, it's very easy to disappoint.

However, despite all above I think Scala is definitely worth to invest some time. It made all other learning curves (for languages, techniques, concepts) more flatten.

[1] https://meta.plasm.us/posts/2015/07/11/roll-your-own-scala/

[+] eatonphil|10 years ago|reply
If you have the time and the interest, start with Standard ML. It is one of (or just?) the simplest languages in the ML family (which also include OCaml, Haskell, Scala, etc.).

You'll see yourself wanting a number of features you'd expect in a modern language, and end up discovering the motivation and approach behind how Scala or Haskell work. Operator overloading (ad-hoc polymorphism) and modular implicits are two of the ones I come across the most.

I have always felt that Haskell and Scala (and OCaml sorta) are way too complicated. However, spending time learning Standard ML and the foundations of this family have been really illuminating - you'll discover how powerful Haskell and Scala really are. For an analogy, you can think of switching to FreeBSD from Linux to get closer to Unix roots so you can understand Linux (the historic decisions and reasons) better.

Take a look at the /r/sml wiki [0] if you need help getting started.

[0] https://www.reddit.com/r/sml/wiki

[+] Homunculiheaded|10 years ago|reply
I think the Scala learning experience is very different depending on whether you're coming from the Java -> Want to use Functional Programming route or the Functional Programmer -> Have to use Java for a project route.

As someone with a lot FP experience having to work with some Java libraries, getting started with the "This is more pleasant than Java" style of Scala takes very little time. To the point where the typing it saves you in a week roughly equals the cost of skimming through Scala for the Impatient to get started.

Granted the "This is more pleasant than Java" style of Scala is the equivalent of the "C with Classes" style of C++. But as far as getting started learning Scala I've found that it is quicker than most FP languages to just dive in and get things done, refactoring as you learn more idiomatic approaches to problems.

For me the big risk for Scala that I've seen is the same as C++: The language is so big and so flexible that you can have two developers write the same programs and get results that are difficult to see as being the same language. And because you can get stuff done without writing idiomatic code it's very easy to stop learning and be quite far from what experienced Scala developers would consider a Scala programmer.

[+] StreamBright|10 years ago|reply
The real question: is it worth it? Up to now I could successfully avoid learning Scala. My problem with it is the complexity that the language by itself introduces and the readability of code that comes out at the end. Maybe I am just valuing simplicity too much when it comes to programming languages. Anyways thanks for the impatient guide!
[+] critium|10 years ago|reply
I've taught scala to several devs as well and I'd like to echo that the course on coursera is absolutely essential.

On a separate note, I leared scala and clojure nearly at the same time and I'd say that learning clojure actually helped me grow in scala as well.

edit: Reply fail. This was a response to hythloday -----

[+] argonaut|10 years ago|reply
I totally agree with you, as someone who had to learn it quickly for a new job. A bit of hearsay indicates that a former VP of Engineering at Twitter is not sure he would have gone with Scala again because of the on-ramp for new devs (https://www.quora.com/Is-Twitter-getting-rid-of-Scala).

Even if someone (a fan of Scala) doesn't believe it's that hard, the fact that this comes up again and again should really be an indication that it's truly an issue for people new to the language [1]. It is difficult, and it is intimidating. I would not have learned Scala if it weren't for the extrinsic push of learning it for a job.

[1] This applies to other things that people new to a language constantly complain about: Python's problem with v2 and v3, etc.

[+] kailuowang|10 years ago|reply
My advice is that don't expect that you can "learn" Scala in a couple of weeks or months. Instead expect that you can learn enough Scala to get the next task done. If you like it, you might be pretty happy spending a couple years learning it.
[+] cabalamat|10 years ago|reply
I'm currently going through the book Functional Programming In Scala, and recommend it.
[+] mjt0229|10 years ago|reply
Really? Rust was harder for me to adjust to by far. It seems like a moving target and the documentation I found was still lacking.
[+] sheldor|10 years ago|reply
A well known resource (albeit a bit outdated); however I'm genuinely curious why is this on the front page of hacker news.

I thought at first that it's been updated to some 2.1X version but, judging by the github repo, it hasn't been touched for years.

[+] rco8786|10 years ago|reply
Also expected this to be an update or something. Strange.
[+] Zaheer|10 years ago|reply
My biggest problem with Scala is that it's too powerful. Reading code I've written weeks or even days later is painful. Conciseness is not always good.
[+] joshlemer|10 years ago|reply
In what ways does Scala you've written end up being unreadable just days later? I honestly find that Scala code is some of the simplest and easiest to reason about of any language. Writing Scala has honestly been such a joy, it's easy to refactor, easy to read and write, and I almost never miss something -- if it compiles, Scala code is usually correct I find.
[+] jinst8gmi|10 years ago|reply
Well written Scala code is fantastic to work with, but it does take some practice and judgement to write well structured readable code. If you're having trouble reading your own code days later perhaps consider the way you're using the language. I'd strongly recommend reading http://www.lihaoyi.com/post/StrategicScalaStylePrincipleofLe... if you're have trouble reading your own code.
[+] morsch|10 years ago|reply
I find that I consciously need to go over any code and rewrite it with a reader in mind. The first version is usually crap, but at the same time, it's very easy to fall into the trap of making it Just Right which makes the second version "super elegant" but completely opaque at the same time.

I often end up making a "super elegant" version and, almost invariably, end up scrapping it for a (hopefully...) more bread-and-butter version, which may or may not incorporate some lessons learned from the concise version. Even if not, it's not all loss, because coming up with the elegant version is intellectually rewarding and super fun.

Add lots of in-line (not just scaladoc) comments helping the reader along. Extract vals for intermediary steps. Variable naming is always important, but even more so when you don't explicitly declare the type.

[+] justinhj|10 years ago|reply
Conciseness is optional. Sometimes a new Scala programmer will learn functional combinators and try to cram a lot of logic into one line. Breaking things up into semantically related steps and assigning each step to a val with a descriptive name will make the code more readable to others (and the author's future self)
[+] taude|10 years ago|reply
I was learning Scala at one point. I was reading Atomic Scala [1] (I'm a big fan of Bruce Eckel as I learned Java from one of his earlier books, and some C++ before that). And I also took the Coursera Course from Martin O on functional reactive programming with Scala. I don't remember what is was actually called...

I'm still into alternative languages that run on the JVM...however I went and learned Go Lang in a weekend and it meets a lot of my needs for building out newer services.

Also, for my team the overhead of learning another JVM language (we already use Groovy quite a bit) didn't seem worth it in the end, even though I was a bit of a fan of the Scala idea for a few months.

I might still learn Scala some day, but we're not even on Java 8 at my current job, and that would alleviate a lot of my current Java grievances....

[1] http://www.atomicscala.com/ebook/

[+] Negative1|10 years ago|reply
Maybe I'm in the minority on this but I felt this guide by twitter was poorly written. It has good coverage but concepts were just not explained very well.

The way I learned was reading from front to back "The Scala Programming Language" by Martin himself and starting a new project completely in Scala (which I'm launching soon). I'm sure that's not the best approach for everyone but using Scala in a practical environment in an idiomatic way really helps ground the concepts which can at first seem intimidating and difficult to comprehend.

Mastery is a whole other story...

p.s. I recommend Scala Cheatsheet if you are just learning: http://docs.scala-lang.org/cheatsheets/

[+] merb|10 years ago|reply
What I hate about Scala School is that they are still using Twitter Future's and not Scala Future's, that could be aweful for Beginners.
[+] gamapuna|10 years ago|reply
Can anyone recommend a good scala based open source project which gives a flavor of how to write good/effective scala
[+] lmm|10 years ago|reply
Do you want basics or advanced? At the moderately fancy level, Spray is great - any time you're using a directive, you can just click through in the IDE and see the implementation of what it actually does. And Doobie is a tour-de-force for advanced type constructs. At a more basic level a lot of Twitter's own libraries are straightforward readable code (e.g. Scrooge is one I've patched a bit myself), though coupled to the Twitter stack of Finagle/Scalding/etc. that you probably don't want to use.
[+] rahilb|10 years ago|reply
twitter/util is very well written, and useful.

After that you could look into the spray.io source: it is quite complex, but the API it exposes and how extensible it is is amazing... They also coined the _magnet pattern_ which is pretty cool, and probably less abused than the cake pattern.

[+] joshlemer|10 years ago|reply
http://www.squants.com/ seems like a great library for studying, since it's inherently intuitive, self contained, well documented, and exposes a terrific api.
[+] ikurei|10 years ago|reply
(Somewhat off-topic, sorry)

This book does an interesting thing:

> For each chapter (and occasionally for individual sections), I indicate the experience level. The chapters progress through levels A1, L1, A2, L2, A3, L3.

The number is the expertise level, from junior to expert; A stands for Application developer, L for Library developer.

I often find myself unsure about wheter a book or text is intended for the kind of user I am for whatever the topic is. Skimming through a book trying to identify what parts you should focus is not always easy.

Do you know of other books that do this kind of thing?

[+] bsaul|10 years ago|reply
are there any other big company relying on scala for their core infra ?
[+] flurdy|10 years ago|reply
Twitter, Etsy rely on Scala as their main tech stack.

You can probably list a large chunk of the big banks. I know quite of few of City of London's big investment banks all continually look for scala developers. In the same breath I would probably list the gambling companies which seems to be on scala bandwagon as well...

In the UK the public sector (GDS) are investing in scala based projects. E.g The HMRC have about 200 scala developers (me included).

[+] joshlemer|10 years ago|reply
Walmart, EnerNOC, Verizon, LinkedIn, Hootsuite, Coursera, Foursquare, Meetup.com, Nitro, Workday, AirBnB, there's quite a lot..
[+] meowzero|10 years ago|reply
The Weather Channel's core weather services such as their weather API, their alerting services (for your phones), and most of their other services are all written in Scala.
[+] romanhn|10 years ago|reply
PagerDuty relies on Scala for many of its critical services.
[+] sidcool|10 years ago|reply
I recently gave a talk on basics of functional programming. I have observed Scala syntax comes easier to people than Haskell or Clojure.
[+] SriniK|10 years ago|reply
Curious question, anyone here using Scala for Android development?
[+] psynapse|10 years ago|reply
The company I am contracted to has an Android app written in Scala.
[+] mclifton|10 years ago|reply
I'm about to release an app (will probably publish a beta today - https://invotes.com), and it actually works quite well.

The compile times are probably a bit slower than a standard java project, but not bad - something like 5-30 seconds depending on if it's a full rebuild.

I use android-sdk-plugin with SBT along with Scaloid. Wrestling with proguard to hide appropriate warnings can be a little bit of a pain, but even with no prior Android knowledge I was able to figure everything out.

Everything works as expected. There are a few minor issues where Java expects null and that's not normal Scala style, but other than that, nothing important to speak of. My binary builds to 4-5mb.

[+] lmm|10 years ago|reply
I've written some basic android apps for my own use in Scala. There's a bit of a mismatch with the android API (which is very much oriented towards traditional-Java mutable objects and one-thread-per-thing style) but I still find it nicer to work in Scala.
[+] brakmic|10 years ago|reply
The Dark Side for Beginners ;)
[+] diimdeep|10 years ago|reply
Isn't scala dying ?
[+] partycoder|10 years ago|reply
I have heard that Twitter is now moving away from Scala.
[+] jowiar|10 years ago|reply
My biggest challenge with (learning) Scala and the Scala community is that it feels like nobody is actually shipping software, or advocating for making shipping software easier.

And that's a shame, because Scala is language I love for writing a few dozen lines of code, and expressing a domain concept. It's a fantastic language for solving a homework problem set (and it's origins may be part of the reason why). But every library feels like it was concocted as a search for purity with zero attention given to the user experience.

The community is badly missing a DHH or Kenneth Reitz -- someone saying: "Ok, it's cool that we have this academic purity stuff and all that, now let's get serious about shipping software, and making tools that help people ship software." It's not that this view needs to dominate a community, but right now it's thoroughly unrepresented in Scala land.

[+] mclifton|10 years ago|reply
I feel like my experience is quite a bit different. I chose play framework for my web frontend and REST API, and it's quite easy to get started and ship something quickly.

Play framework itself is pretty straightforward with not much in the way of advanced Scala concepts (implicits are probably the most you have to understand). Testing is baked right in and they even handle setting up the application for you in your fixtures.

Coming from the .NET world, it was a huge relief to see that I could just use activator/sbt to compile and publish my artifacts on a build server, just as it works on my local machine. Setting up continuous integration was super easy in comparison to what Microsoft has historically offered (but looks like they're improving with .NET Core).

As for other frameworks and libraries, you may be right on a number of them, but I wouldn't say that all or even most Scala libs are designed to be pure. I have a number of dependencies that are very easy to reason about even if you aren't aware of advanced features.

[+] akavi|10 years ago|reply
Twitter? Foursquare? Linkedin?

(Also my old company, PagerDuty. Wee bit lower profile than the other three, admittedly.)

[+] kailuowang|10 years ago|reply
> nobody is actually shipping software

What about Spark, Kafka and Akka? I actually think the Scala community is working very hard to improve user experience, it's just that they don't do in the expense of soundness.

As a ruby -> Scala developer, I don't miss DHH.