Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: What are the best resources to properly learn Scala?
143 points by godmodus on March 27, 2017 | hide | past | favorite | 57 comments
Hello, I've started to work with scala and I think it's a beautiful language. that said, I'd like to be better at it. What are some good books to get thst teach about the nitty gritty details of the language and it's use in production?



I'm the author of a couple of books on Scala: Essential Scala and Advanced Scala. You can find them here: http://underscore.io/books/

Depending on what your background and what you want to learn, different books will be appropriate:

- Our books are focused on what we consider the most important concepts for functional programming and how they are implemented in Scala. If you want to know about algebraic data types, type classes, and so on, and how to implement them in Scala or use the implementations in the Cats library our books are a good choice. We emphatically do not teach all the language. If you want to know about OO features like self types and trait mixins don't turn to our books.

- Odersky's book has a lot of detail. It does a good job of presenting all of the language but doesn't IMO do a good job of showing you how to use the language.

- FPiS is a very good book that does what the title suggests. My main criticism is it can take a bit long to get to the point and it doesn't talk about libraries you might use in practice like Cats or Scalaz.

- The Coursera courses I have taken are fairly good, but don't do a great job of talking about the higher-level design concepts.

I haven't read other books, so can't comment on them.

Finally, if you don't have a background in formal CS our free book Creative Scala might be useful. The current draft is at https://dl.dropboxusercontent.com/u/8669329/creative-scala.p... and the source is at https://github.com/underscoreio/creative-scala/


I'm interested in hearing about your team and diversity discounts, it doesn't look like there is any information on them on the site (unless I missed it!)


Team discount is 20% off for purchases of ten or more copies.

Diversity discount ... I don't think we have a policy for books, but for training we offer 50% off to people who are under-represented in tech and I'm happy to offer the same for books.

Email me (noel at underscore.io) to arrange either.


A very quick glimpse, seconds, at your create-scala book and it there are a lot of figures like in the logo turtle language


Yes, we've taken some inspiration from there, and in Chapter 10 we build a little turtle graphics system.


Advanced Scala appears to be just what I'm looking for. According to Gumroad it's in Early Access -- are you able to advise on when you're hoping to publish the final version?

I see from browsing the TOC that some topics are out-of-date (Xor.)


In this particular case the TOC is out of date. We released a version of the book compatible with Cats 0.9 (including Either and removing Xor) a few weeks ago.

Final version should be out last half of this year.


There is a course on Coursera thaught by the Scala creator: https://www.coursera.org/learn/progfun1


It's actually a series of 4 courses, 5 if you include the "capstone project." I've watched a few of the videos-- it's pretty decent, but intended for those who don't have much experience with functional programming. The first course I believe is modeled off the Structure and Interpretation of Computer Programs.

I think the answer to this question really depends on where you're coming from. An experienced Java developer will need to focus on different things than someone who has spent the last decade hacking Common Lisp or OCaml.


I would agree and disagree.

The first course is the one that's dedicated to Scala the language, whereas the rest are more focused on reactive/parallel programming that happens to be in Scala.

The first course is good, and acts as a good introduction if you've encountered functional programming before.


I found Functional Programming in Scala to be the best source: https://www.amazon.com/Functional-Programming-Scala-Paul-Chi...


I would say that rather depends on what OP means by "properly".

If OP already knows Scala and would like to get better at it and one assumes that "Scala as Haskell in the JVM" is more desirable than "Scala as a better Java", then yes, that's a great suggestion.

If OP wants to learn Scala from the ground up, I disagree pretty strongly with starting there. It's a great book, well written, with a wealth of challenging and mind-opening exercises, but I wouldn't recommend that as anyone's first exposure to the language. The second or third, sure, but it purposefully restricts itself to what its authors consider a sane subset of the language.

I happen to agree with their definition, but, in my experience, knowing a programming language is about reading it as well as writing it, and by restricting your learning to a subset of the language, you'll find yourself unable to understand perfectly valid, normal code - code that is part of the standard library, for instance.

I would rather suggest reading Odersky's book while allowing oneself to skip large chunks that go rather in too much details about fairly useless things like the XML API. Or going through scala-exercises (https://www.scala-exercises.org). Or the coursera class - its first incarnation was pretty good, I assume the new one is at least of the same caliber. They might not make you an expert overnight, but they'll get you to know most of the Scala features you're likely to encounter in the wild, and to be able to read and learn from most Scala OSS projects.


I actually learned Scala from this book, and the only languages I had used in production before were Python and Fortran. I don't think learning the functional subset first made it harder for me to learn the object-oriented and imperative parts later on. Plus, understanding the functional subset gives you a better understanding of many of the internals, such as what `for` comprehensions are actually doing.

Of course, if you just read one book and stop there, I'd agree. But most people will continue learning from tutorials, videos, stackoverflow, etc.

I've also seen several other people learn Scala this way, usually without knowing any functional programming before, and really haven't seen any signs of issues wrt not understanding code written in other styles.


That book is by far the best one I ever read about Functional Programming in general, even if you don't want to learn Scala itself it is an amazing reading about FP.


+1 for this The best book for how to use Scala. It talks about not just how to use FP, but also why to do it and the best practices.


+1 amazing book! A lot of FP ideas and how these apply to real world situations!


Depends on your level. Scala is extremely powerful, and so can be you. Just pick progressively more and more advanced books, and you'll be there in no time. Compiler's always got your back. Seriosly, I've been on search for good language for last 8-10years, always been unhappy. 2 years ago I started working with scala, and never looked back. I am happy with it and I can see myself doing it for as long as it's around and there is competetive market.


Until you try clojure or even kotlin


I mastered kotlin to dev some mobile apps. Having years of C# behind me, it does not impress me much.

Clojure only for fun, I need types. But lisps sounds fun. Can't comment more. Prehaps you're right ;)


There is `clojure/core.typed` if you want types or `clojure.spec` if you want specs. What I love in Clojure (and in any lisp for that matter) is that you can imlement language features if you need them and the language itself provides you with many but only if you need it (optional dependencies). This gives you flexibility which you can only dream of if you use scala.


I know of clojure typed. But im worried it needs to be first class. I.e i need all my dependencies to be typed, as that is my api and it usually covers large surface.

Id also be careful with your 2nd statement. Scala has macros.

Im happy clojure is on the block, dont get me wrong :) each to their own. Type system is incredibly important to me and my productivity.


Scala macros are not like clojure macros. Clojure is homoiconic while scala is not so you really can't compare the two.


I would recommend the stairway book and the coursera course. I would also steer away from the some of the other recommendations posted here, including "Functional Programming in Scala", which are basically teaching you how to write Haskell in Scala. I don't think this is a good way to learn Scala because I don't think Haskell-style code makes for effective Scala.


>I don't think this is a good way to learn Scala because I don't think Haskell-style code makes for effective Scala.

Why is writing functional code in scala not effective? How would one go about understanding 'for comprehensions' in scala without understanding what flatMap/map is used for in lieu if exception. Or why pattern matching is used.


In my opinion, functional programming, like most programming terms, including object-oriented programming, means very different things to different people. For example:

1. The LISP family of languages encourages a style of functional programming that eschews static type systems, relies heavily on macros and algorithms involving singly-linked lists, and doesn't mind exposing the ability to mutate state.

2. The ML family of languages, of which I am the least familiar, are statically typed, but are also OK exposing mutable state and do not track any effects in their type systems.

3. Haskell heavily pushes reliance on Monads, monad transformers, and effects/state tracking through the above.

4. Proof assistants and similar languages like Coq go beyond tracking effects in the type system; they track values themselves, and essentially require you to prove mathematically that your program is correct.

So, given the above, what do you mean by functional programming? From the talks I've seen given by the creator of Scala itself, I believe he sees Scala as fitting in with the ML family languages moreso than Haskell.

Also, the way Scala's type system and runtime currently work, I don't think it's a good fit for Haskell-style programming. I tend to find monad transformer-based code in Scala exceedingly ugly and difficult to read compared to Haskell. The underlying runtime itself also has little mechanism for optimizing monad-based code, whereas the GHC compiler has probably man-years of effort spent into optimizing code using monads.


I used https://twitter.github.io/scala_school/ to learn, I found it useful.


That tutorial is good. But be mindful that in it there is no explicit distinction being made when using Scala standard library types and Twitter library types.

e.g: Futures used in there are from Finagle rather than scala.concurrent.Future


Just to add on to this incase anyone is wondering, Twitter has a library that allows you to use the different futures together (https://github.com/twitter/bijection) if you need to.


This is really old at this point. IIRC it's for Scala 2.9, so there's stuff that's since deprecated (view bounds) and features it doesn't cover (implicit classes).


This course is super good! I also made some brief notes (not complete though), from this course: https://github.com/Dawny33/Notes/blob/master/Programming/Sca...


I started with Scala a year ago for work. I used a mixture of the resources listed here, but I found this [1] series the most valuable, after the other resources gave a basic foundation.

[1]: http://danielwestheide.com/scala/neophytes.html


The Artima book by Odersky is the bible, and so you need that one.

For reference, I like http://naildrivin5.com/scalatour although it's 2.8 rather than the current 2.12.

For style guide, I'd go with Li Hiayo's blog, notably the Strategic Style series: http://www.lihaoyi.com/post/StrategicScalaStylePracticalType...


I read scala for the impatience, but once you know clojure, haskell, erlang and other languages the scala language seems to be one more language, a better java but nothing that really surprise you. I know that using scala you can make your programs very difficult to read using obscure notations for operators. I like to use scala as a repl for exploring java classes, a little more useful that clojure in this regard.


As you are asking for books - Scala for the impatient (http://www.horstmann.com/scala/) - Programming in Scala (https://booksites.artima.com/programming_in_scala_3ed)

I found those books very good resources. The Scala website lists a few others (https://www.scala-lang.org/documentation/books.html)

Aprt from that I found Daniel Westheides blog a very good starting point (http://danielwestheide.com/scala/neophytes.html)


I learnt Scala from Odersky's "Programming in Scala" and can fully recommend it. I didn't have any functional language experience beforehand.


If you want to learn "functional" aspect and not only library and syntax, I would recommend SICP.

https://mitpress.mit.edu/sicp/full-text/book/book.html


How much of this book is "functional" aspect and how much is everything else? Going through the TOC, it looks like the book tries to start from 0.

Would you recommend any particular sections for someone who's looking to only understand the functional parts?


Your comment tells me you should start from the beginning and read the whole thing. :)

Just give it a try. I was hooked after first chapter!


atleast go through initial 4 chapters. then go through the coursera lecture of Odersky. Though SICP is lisp, the structure is very similar to scala.


Scala Cookbook: http://shop.oreilly.com/product/0636920026914.do (most of it is available online here: http://scalacookbook.com/)

Once you are done with this, you can pretty much pick any of the projects here and start reading the source code:

https://github.com/lauris/awesome-scala https://github.com/adamw/awesome-scala

Reading code is the probably the best way to learn any programming language IMO


"Another tour of Scala": http://naildrivin5.com/scalatour was informative for me.

It's a bit dated, mostly targetting Scala 2.8. Current version is 2.12. But should not be fundamentally different.


I know this question is mostly about resources in dead tree format, but don't forget there are sometimes local events and meetup groups that can help you learn Scala (and other languages too!).

For example...

If you live in Dallas/Fort Worth and would like to learn Scala then you should know that the local Scala Enthusiasts group is hosting a Scala Essentials workshop on April 7th, 2017. This will be an all-day, hands-on event for Scala beginners. We will start with a language intro and finish up coding a REST server. More details can be found here: https://www.scala-enthusiasts.com/scala-essentials-workshop-...


I reccomend "Just Enough Scala for Spark" tutorial from Dean Wampler. It was scheduled in Strata NYC, Singapore, and San Jose. Good part: practical. No "weird" or "religion-like" stuff. Just get st done today.

It's archived in SafariBooksOnline: check https://conferences.oreilly.com/strata/strata-ny-2016/public... before applying to Safari just in case.


If you're looking for books I recently made a list of good books for Scala - https://blog.matthewrathbone.com/2017/02/14/scala-books.html.

Otherwise Scala School is awesome: https://twitter.github.io/scala_school/

When I worked at Foursquare we would send folks to the Scala School website as homework. :-)


http://rerun.me/

This blog has some good articles on how to work with Futures properly as well as some Akka stuff.


I would recommend Introduction to the Art of Programming Using Scala: (https://www.amazon.com/Introduction-Programming-Chapman-Text...)

It's very practical, however it approaches the language from a completely novice perspective. If you have years of programming experience, it may be a little redundant for you.


Same



I learned by reading "Programming in Scala" by Martin Odersky who invented the language. https://www.artima.com/shop/programming_in_scala_3ed


I hope you don't mind me asking: Is there a specific reason behind you wanting to learn Scala "properly"?


piggybacking on this question. I am really struggling with sbt. Is there is a good FP in scala equivalent for sbt that walks you through feature by feature via exercises and examples .


Hi. Sorry I don't have a good answer for you, but check sbt docs, it's pretty comprehenful, but it's not best.

Your best bet is to visit opensource projects and look into their build.sbt's, how they do things -they're usually not big enterprise projects and you can quickly 'get' how they setup what.

Always feel free to visir /r/scala and ask sbt-related question there, there is active community happy to answer both sbt/scala/fp related questions.


I liked Scala for the Impatient but I'm pretty novice.


What's the market demand for Scala like?


Very good on the coast, high paying, fun work. Pretty sparse otherwise. I'm sure there are exceptions, but it does seem like it is growing. And, ironically, the main reason companies cite not choosing Scala (or only dip their toes into Scala) is lack of Scala engineers.


Interesting, thanks. I suppose companies on the coast may tend to be more open to new stuff.


If you aren't leaning Scala for work or a specific project that requires it , have you considered Kotlin? I have found the language much more productive in my day to day, after initially discovering Scala and digging deeper.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: