10

I've almost completed the scala book, and I want some nice code sample that would help me solidify what I have learned.

Is there anything on github that you can recommend?

Preferably some sort of library that I could learn from, maybe an API wrapper? or maybe something else that you recommend?

Nathan Hughes
  • 94,330
  • 19
  • 181
  • 276
Blankman
  • 259,732
  • 324
  • 769
  • 1,199

4 Answers4

8

My advice is to not just look at code examples, but dive in and start coding. You can read all the code in the world and at the end of the day still not have a clue how to write even the simplest function. Try solving some of the Project Euler problems, even the simple ones should quickly help you build your confidence.

Here's a link to my solution for Project Euler #42 using Scala and Akka actors. It's a pretty simple problem, but forcing myself to solve it using actors taught me a lot how to work with them and learn about other Scala peculiarities.

Personally I've learned a fair amount by looking at a few projects. The Lift framework's source code is actively being developed and there's tons of stuff to look at. when I started using Specs2 I used some of their tests as learning tools.

I first learned about Scala from using Twitter's Kestrel project, its code (as well as related projects) have lots of things to look at as well.

Also, when I was learning how to use Akka, I found this basic example of setting up an Akka web application to be invaluable. It also helped learning how to properly setup SBT

Dan Simon
  • 12,891
  • 3
  • 49
  • 55
  • I've looked at kestrel, but I find it is both a challenge in terms of syntax and overal architecture. You have to know the overall design goals don't you? To bad there is no high level writeup! – Blankman Jun 29 '11 at 21:46
  • 1
    In addition to Project Euler I'd recommend [S99](http://aperiodic.net/phil/scala/s-99/) and [Scala Labs](https://github.com/scala-labs/scala-labs). Both of these have exercises from a beginner level to more advanced. – Brian Jun 30 '11 at 04:09
7

You can have a look at Scala by Example by Martin Odersky. It show how the scala library was designed:

http://www.scala-lang.org/docu/files/ScalaByExample.pdf

You can also have a look at the scala library source code. There is a link to the source on most pages of the official scaladoc:

http://www.scala-lang.org/api/current/index.html

paradigmatic
  • 40,153
  • 18
  • 88
  • 147
4

99 Scala Problems is also quite good for getting the hang of the functional style.

Some of the solutions are a bit out of date or over-complex, but it's a nice feeling when you can improve on the ones given.

Luigi Plinge
  • 50,650
  • 20
  • 113
  • 180
1

IMHO option nothing solidifies knowledge better than simply coding - you decide to tackle a problem in Scala, you start implementing it and you learn as you go. Any time you've hit the wall you ask google and the nice people at #scala or the many forums/mailing lists for help.

It's not that reading code is bad - it's great. But you wouldn't be able to appreciate the elegance of many of the solutions if you haven't first encountered the problem and dealt with it in a worse way, due to a limited understanding of the Scala ecosystem.

As Scala is mostly implemented in Scala if it's source code that yo want to read - I'd heartily recommend starting there. Exploring Lift or Akka is a great idea as well (and starting your own project using Lift or Akka is even a better idea).

When we're talking about nice small excercises - 99 Scala problems is great first step.

Bozhidar Batsov
  • 55,802
  • 13
  • 100
  • 117