tags:

views:

1263

answers:

6
+14  Q: 

Learning Scala.

What was your methodology to learn Scala? (exercises? small project? library? manual?)

What surprises have you encountered when you have been learning Scala? Both subjectively positive and negative.

Please state also what is your background i.e. primary language of your choice.

Edit: Please try to state your experience, not opinions.

+2  A: 

Honestly, I'm learning it now using the list of options on the learning page of scala-lang.org.

There, you can find tutorials for those with:

  • Several years of Java programming
  • Some Scala programming
  • Several years experience of C++, Ruby, Python, Visual Basic, etc
  • Experience of a functional language like Haskell, ML, F#, Lisp, Clojure etc as well as an imperative one.
  • Researcher in Computer Languages
  • Beginner, never programmed in any language

I fit into the "Several years of Java Programming" and "Several years experience of C++, Ruby, Python, Visual Basic, etc" bullets, and the tutorials are helping me along nicely. I just keep moving along with the examples that they provide, analyzing the syntax and available libs. If you know how to program in multiple paradigms, then picking up a new language becomes little more than learning new syntax and the new "sugar". Then it's reading the docs/api from there.

geowa4
+4  A: 

I ported some nifty sample programs from F# to Scala.

  • Error estimation showcases implicit.
  • Probabilistic modeling showcases monads in Scala. It also reveals a limitation of the type inference engine in Scala: I had to declare most arguments because Scala would otherwise infer that they are products.
namin
Have implicit was a cause of any surprises for you?
Łukasz Lew
Do you have a blog or other means to post your impressions of working with F# vs. Scala? Would be an interesting read.
Steve Lianoglou
+4  A: 

I'm a Java developer and learned Scala by reading the book Programming in Scala and experimenting with it a lot. I did some of the problems of Project Euler in Scala.

Functional programming requires a different way of thinking than what I'm used to in Java, so it takes me some time to really get into the functional mindset. Many of the Project Euler problems are well suited for learning functional programming concepts.

Jesper
+3  A: 

I started off porting an already-written Java application to use Scala. As I went, I started asking lots of questions on SO, many of which I now find confusing because they were written from the perspective of a misunderstanding (note: when asking questions, think about what you assumptions are and declare them in the question)

I got about halfway through porting the app and decided to abort it as I'd realized that some of my early decisions were not particularly good ones. So I decided to start writing my next app in the language from scratch. Of course, I'm at work, so have a constant stream of apps which need to be written. If this wasn't the case, I'd pick something like the standard programming task: write a system for a library (as in books, not API).

Among all this, I was reading stuff like Daniel Spiewak and James Iry's blogs, and looking at all of the examples on scala-lang.org too.

oxbow_lakes
+20  A: 

It goes without saying, but I'll say it anyway, that the best way to learn a programming language is to use it. There's no better teacher than one's own mistakes.

I expect it to go without saying that Scala books are helful. The most traditional, Artima's Programming in Scala (PinS), whose authors include both Scala's mastermind, Martin Odersky, Lex Spoon of Google Web Toolkit fame, and ScalaTest's creator, Bill Venner, will give you a good, general grounding. This is the only book I have read so far.

Beginning Scala, written by Lift's creator David Pollack, and Programming Scala, an O'Reilly book which has Dean Wampler and Twitter's Platform Lead Alex Payne as its authors, are both more practical-minded. You might pick up Scala faster from the latter two, but still want a bit more depth from the former. Finally, there's Pragmatic Bookshelf's Programming Scala: Tackle Multi-Core Complexity on The Java Virtual Machine, by Venkat Subramaniam, Agile Developer's founder. I have dipped here and there in some of these books, and follow quite a few of these author's blogs an twitters.

Then, of course, there's a whole page on Scala-Lang about learning Scala. I have perused it, and I make references to Scala's formal specification now and then, but this is already whole other level. I can't say it helped much when I began learning, but mostly because I prefer a more theoretical slant to language texts.

So, skipping all that, I have browsed available blogs on Scala (you may scan this link for examples), and, once I was done with that, started following selected favorite blogs as well as Scala blogs aggregator Planet Scala.

I have also read Scala questions on Stack Overflow, and the answers. I tried to solve the questions, and posted my answers -- it's one way of getting criticism on your code. :-) I also tried my hand at Scala with language-agnostics and algorithm questions.

If you don't have any project to use Scala at, and are presently with a writer's block, there's 99 Scala Problems, an adaptation of 99 Prolog Problems. Project Euler is also a good place to find problems. I have spent a few hours here and there with both. EDIT Another source of problems are the tutorials on Simply Scala, with the added benefit of being able to execute code from the tutorials with a simple click on the site.

If your thing is web programming, then Lift is the way to go, hands down. There's APress The Definitive Guide to Lift, based on a web collaboration effort, of which you can find more in this group. I'm starting into Lift right now, and my last web "programming" experience targetted Mosaic and Lynx.

Scala also has a number of mailing lists, with very helpful people, and an IRC channel where you can really talk about it. You can find information about both from Scala-Lang. You'll find me in both.

Finally, I blogged about it. This was probably the most effective of my efforts. First, because I'd clean up my code before posting it, which significantly improved it. Second, because writting about my code made me think about it, which often improved my understand of Scala and gave me insights into the language.

As for my own background, I learned BASIC over 25 years ago, and followed with Assembler (Z-80) and Forth within a year. I have a thing for unusual languages, and I find it annoying that so-called OO programmers nowadays mix methods and messages, and think there's something wrong with prototype-based OO languages. Scala's "_" annoys me, even though I did get used to it, and bemoan the fact that it isn't as concise as it could have been. Other than that, I'm in love with Scala, and think mainstream and I will finally have a meeting of minds. Well, meet again (last time it was C).

EDIT

While I haven't used it to learn Scala, particularly since it was just finished, David Copeland produce his own Scala Tour, as he was a bit disappointed with the existing ones on Scala-Lang. I, myself, haven't had time to peruse it yet, but it has earned approval from some very smart people, including at least one of the authors of the books previously mentioned. I'll quote David here with regards to this work:

Many of the examples lacked the answer to the question "what problem does this feature solve?" or contained examples that I found too abstract to really show the utility of the feature.

So, I decided to investigate each language feature and answer it myself. I have little experience with (or allegiance to) functional programming, so I approached it from my perspective as a Java application developer. For each feature I tried to find a common problem faced by app developers, and then work out how Scala would provide a solution. It wasn't always easy.

Daniel
For some reason my server is unable to deal with the encoding of the URL to the Scala Tour given here. The url http://www.naildrivin5.com/scala_tour should work (%5F is messing things up for some reason)
davetron5000
Funny, because that *is* the url in the answer.
Daniel
scala tour now at:http://www.naildrivin5.com/scalatour
Gene T
@Gene thanks, fixed.
Daniel
+3  A: 

I worked through the Tour of Scala and, as mentioned by @Daniel, created my own. With some supplements from Odersky's main Scala book, I learned quite a bit.

davetron5000