
Scala School - Baustin
http://twitter.github.io/scala_school/
======
eranation
Few other great learning resources for Scala:

\- a "JSFiddle" like editor for Scala:
[http://scalakata.com](http://scalakata.com)

\- Interactive tours:
[http://scalatutorials.com/tour](http://scalatutorials.com/tour),
[http://www.scala-tour.com](http://www.scala-tour.com),
[http://www.simplyscala.com](http://www.simplyscala.com)

\- Learn Scala in X minutes:
[http://learnxinyminutes.com/docs/scala/](http://learnxinyminutes.com/docs/scala/)

\- Typesafe Activator:
[http://www.typesafe.com/activator](http://www.typesafe.com/activator)

\- Official docs of course: [http://docs.scala-lang.org/](http://docs.scala-
lang.org/)

~~~
tmarthal
People are doing all sorts of great things with Scala.

Scala Notebooks, which can be classified as a learning resource
[https://github.com/n8han/scala-notebook/](https://github.com/n8han/scala-
notebook/) \- It is an in-work conversion of iPython notebooks using d3
instead of matplotlib.

Another great analysis resource is Saddle, a scala data munging library
(analogous to pandas, around the 0.8 revision).
[http://saddle.github.io/](http://saddle.github.io/)

------
MojoJolo
If you guys really into Scala, I really recommend trying Finagle
([https://github.com/twitter/finagle](https://github.com/twitter/finagle)). It
was also created by Twitter. It was a lightweight HTTP server and client for
Scala. It's my favorite. With just a "single" line of code, you can create an
HTTP server in Scala.

I usually combine it with Rogue
([https://github.com/foursquare/rogue](https://github.com/foursquare/rogue)),
an "ORM"-like for MongoDB. I used Finagle and Rogue to build a fast and
lightweight REST API.

~~~
smrtinsert
As someone getting into scala, where can I find the list of top available
libs? For clojure I just browsed github, but I feel there probably is some
resource out there I'm missing.

~~~
MojoJolo
What I love about Scala is that all (most, if not all) libraries built in Java
can also be used. This includes those awesome apache libraries.

For Scala written libraries, here's a link to Github page:
[https://github.com/trending?l=scala](https://github.com/trending?l=scala)

~~~
mikegagnon
Whenever possible I avoid using Java libraries in Scala. Scala and Java have
very different programming styles, which are codified in the APIs for
libraries. You lose the benefit of Scala style when you are forced to program
against a Java library.

------
pkinsky
I've finished Martin Odersky's Scala Course. I've built a few small play2.0
apps. I've used Scala to solve ~20 Project Euler problems, and I'm fiddling
around with parsers and scalaz.

However, all the Scala positions I've found are looking for engineers with
experience using Scala in production. How can I make that jump? Are there any
opportunities out there for junior engineers who are proficient in Scala?

~~~
rybosome
Be careful; once you've been working in Scala, going back to Java is
unpleasant. =)

~~~
seanmcdirmid
I worked with Scala at EPFL during my 2 year post doc (in Martin's group). I
later started working for Microsoft, and found the transition to C# to be
initially painful but not incredibly so. I'm now a happy C# programmer, though
I take a lot of liberties [1] with the system, and I also use C# mostly to
build programming systems of my own [2] (though Scala has had an everlasting
influence on my own work).

C# is a bit more advanced in Java (they have lambdas), and in someways better
than Scala (reified generics). But the best thing about C# is that...it forces
you to to settle on less elegant but functional designs in a "worse is better"
style. I found myself obsessing over my Scala code to come up with perfect
solutions because...I could...while in C# perfect solutions obviously don't
exist. C# relieves the burden of choice, which is an interesting trade off to
keep in mind when designing PLs.

[1] [http://bling.codeplex.com/](http://bling.codeplex.com/)

[2]
[http://research.microsoft.com/apps/pubs/default.aspx?id=1898...](http://research.microsoft.com/apps/pubs/default.aspx?id=189802)

~~~
pkinsky
In my (limited) experience, for expressions make for some of the most concise
code I've seen. So many problems can be represented as a chain of Options or
Futures mixed with standard {val x = expression y} expressions.

~~~
seanmcdirmid
But why would you want to? Even in Scala? Use Futures only when bothered with
async IO, and even then be very careful about it. Options always made
debugging more difficult because they defer where you get your NPE.

~~~
pkinsky
Isn't the point of options to statically rule out the possibility of NPE's?

    
    
        def f1:Option[Int] = Some(1)
        def f2(a: Int):Option[Int] = Some(a + 1)
    
        val r = for {
            a <- f1
            b <- f2(a)
            c = a * b
        } yield c
        r.getOrElse("generic error")
    

Individual error messages with scalaz's Validations

    
    
        def f1:Option[Int] = Some(1)
        def f2(a: Int):Option[Int] = Some(a + 1)
    
        val r: Validation[String, Int] = for {
            a <- f1.toSuccess(e = "f1 failed")
            b <- f2(a).toSuccess(e = "f2 failed")
            c = a * b
        } yield c
        r.fold(e => s"error: $e", r => s"result: $r")

~~~
seanmcdirmid
The problem is that on the JVM, you are given a debugger based on control
flow, not data flow. Once you go into heavy option code, debugging that code
becomes a PITA because your tools are simply wrong. So ya, you can come up
with what basically amounts to a printf for data flow code, but you are stuck
doing everything on your own at that point.

The problem really stands that no one knows how to build decent data-flow
debuggers. Haskell programmers prefer static safety over debugging just as
much as because their debuggers suck as the type system is so powerful. In
Scala, you have the option to write crash-early strict code: do it, you will
make your life so much easier as a result.

~~~
pkinsky
Is it realistic to split long chains of Option into subfunctions returning
Option? If long chains of Options are hard to effectively reason about,
breaking them up could ameliorate the problem.

I suppose that conceptually, I consider returning None inside a chain of
flatmapped options as the equivalent of terminating early. It's not hard to
pass along an object describing the error instead of None, which gets you the
equivalent of a thrown exception.

Also: can you point me towards any examples of this antipattern? I 'd like to
see it in action, if only so I can avoid it in my own code.

~~~
seanmcdirmid
I found the best way to debug a complex piece of scala code was to get rid of
as much laziness and deferral as possible. Creating a huge lazy sequence that
propagated through multiple call-layers was absolutely evil. Also, options,
although strict, are troublesome across more than a couple of lines of code
given the way they crash. In general, only use option if failure is expected,
otherwise null is your friend!

For simple programs that do not need to be debugged, laziness is great, you
can write some very concise code. Once you are debugging however, you want to
expose as much control flow as possible to break and step through. I say this
from writing 10s of thousands of Scala code in a fairly complicated context
(Scala compiler + Eclipse) with non-trivial control flow (mostly event
driven).

------
joshz
Coursera has a class as well. Martin Odersky tweeted a while ago about a
possible advanced course in the fall but it doesn't look like it's happening
yet.

[http://www.coursera.org/course/progfun](http://www.coursera.org/course/progfun)

~~~
pramalin
I finished the course when it first came out last year. This appears to be the
third session of the same class. I'm also eagerly looking for an advanced
course. I used Scala in "Algorithms: Design and Analysis, Part 1" programming
problems. Even as some algorithms are described in recursive style, using tail
recursive implementations fail for large data sets and I have to fallback to
imperative styles with lots of mutable data structures to complete the
assignments. A Scala based algorithms course would be very useful.

------
mikkelewis
It's worth mentioning that I got into Scala because of Akka. Amazing features
like remote actors, supervision and more. I also appreciate how active the
project is :) [https://github.com/akka/akka](https://github.com/akka/akka)

~~~
kclay
Akka is great I just launched an app into beta with Play( websocket game) and
Akka , currently I'm trying to get a hang of the clustering features so I can
distribute my connections out.

------
applecore
Starting out, it makes sense to just "write Java in Scala", and gradually
introduce the advanced concepts of Scala as you learn them.

That way, you can be immediately productive.

~~~
catnaroek
That way you can delude yourself into thinking you are productive, because you
are writing code immediately. However, productivity is not to be measured by
the number of lines of code; rather, by 1. the amount of actual functionality
implemented, 2. the elegance of the design (which saves time refactoring later
on).

~~~
lmm
It's easy to forget the value of delivering functionality immediately. It's
all too easy to spend a long time on an elegant design that doesn't actually
serve business needs. I like to follow an agile approach where if something
can't deliver value in 2 weeks then it's not worth doing (or, more likely,
needs to be split into smaller pieces). That's plenty of time to learn enough
Scala to be more productive than you were in Java, even though it will take
months or years to learn the full language.

~~~
catnaroek
Learning a new programming language is an intellectual, exploratory endeavor,
even if it might result in adopting that language for future programming
projects. Writing software professionally is a pragmatic engineering job
constrained by non-intellectual considerations such as customer expectations
(and lack of knowledge thereof) and limited availability of resources (time,
money, skills, etc.). Suggesting that both activities should be approached the
same way is a huge mistake.

~~~
lmm
I learnt scala very effectively simply by delivering a program in it at my day
job. I'm not sure about "should", but in my personal experience I've found
that the best way to learn.

------
stickhandle
Timely. I'm interested in scala. Would love a couple opinions from those in
the know ... (1) As a (very) experienced java guy, what's really the best
learning approach: comparative? clean slate? I'd "like" to do Odersky's
course, but I can't commit to scheduled tasks; (2) A minimal framework seems
like a good idea to me - rather than Play!, what do folks think about Scalatra
as a starting point?

~~~
wiradikusuma
if you want smoother transition, try my approach: code with Java style (OOP,
imperative) but using Scala syntax. once you're familar with the new syntax,
naturally you will wonder, "this seems clunky, there's got to be a way to do
this the Scala way". and you'll start googling "how to do X in a list" etc.

to lower the bar, don't use framework. i even coded
[http://ngajakjalan.com](http://ngajakjalan.com) (one of my projects written
in Scala) without framework, just plain servlet+JSP. again, eventually you'll
think, "i keep doing the same thing, there's got to be some library out there
already doing this for me", and start exploring.

------
karavelov
I am learning Scala last couple of months. Twitter scala page is really nice
for starting up. Another place with discussion of more advanced topics I find
useful:

[http://danielwestheide.com/scala/neophytes.html](http://danielwestheide.com/scala/neophytes.html)

------
arms
This looks great. My favorite resources are those that assume prior
programming knowledge and aim to get the reader up to speed quickly with the
specifics of the language, not programming in general. If anything, I think
I'll start studying pattern matching :)

------
rlbaker
I've been interested in venturing into Scala but have not found a good
resource for getting a development environment setup. Should I be using an IDE
or will sbt/Sublime be sufficient?

~~~
ssmoot
You'll level up much faster with an IDE (IMO).

Ensime in Sublime is kinda pointless I think since it only updates on file
change. The REPL and SBT integration is nice.

I use Sublime for quick examples in Scala, or as a VIM alternative for larger
projects (as opposed to my main editor like with Ruby).

For most of my Scala work I use IntelliJ though. The lack of half-decent
theming in Eclipse and Preferences/Settings being all over the place really
puts me off ScalaIDE personally.

Going from Zero to Code in IntelliJ and SBT (on OSX) is pretty trivial. Given
a command-line "Hello World" with a traditional Maven layout:

First, install IntelliJ, navigate to "Plugins" under preferences and install
the Scala plugin.

Now make sure you have Homebrew installed ([http://brew.sh](http://brew.sh))

    
    
      $ brew update
      $ brew install sbt --devel # currently 0.13.0-RC5
      $ cd ~/src/
      $ mkdir hello-world
      $ cd hello-world
      $ mkdir project
      $ echo "sbt.version=0.13.0-RC5" | tee project/build.properties
      $ cat <<EOS | tee project/plugins.sbt
        resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
    
        addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.0-SNAPSHOT")
        EOS
      $ cat <<EOS | tee build.sbt
        name := "hello-world"
    
        version := "1.0-SNAPSHOT"
        EOS
      $ mkdir -p src/main/scala
      $ cat <<EOS | tee src/main/scala/Whatever.scala
        object Whatever extends App {
          println("Hello World!")
        }
        EOS
      $ sbt
      > compile
      > gen-idea
      > run
    

And there you go. It could be simpler if we were having a LOC competition, but
this is actually very close to the exact setup I use for projects day in and
day out, including getting a jump on the next version of SBT and best-
practicey stuff like setting the SBT version in build.properties.

If this were a Play app, you might have a "project/plugins.sbt" that looked
something like this (to get a jump on the upcoming Scala 2.10 version of Play,
that integrates with SBT 0.13.x):

    
    
      // Comment to get more information during initialization
      logLevel := Level.Warn
    
      resolvers := Seq("Maven Central" at "http://repo1.maven.org/maven2/",
                    "Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/",
                    "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/",
                    "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/")
    
      addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0-M2")
    
      addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.0-SNAPSHOT")
    

This just adds a few more common resolvers you might use for dependencies, and
locks you to the latest Play milestone snapshot. You can pretty much otherwise
copy/paste files/folders from a sample Play app, like you might see with the
Typesafe Activator for example.

Good luck!

~~~
gtani
Excellent, thx.

(just remember "brew doctor" first).

Also for non-maccies: [http://www.scala-sbt.org/0.13.0/docs/Getting-
Started/Setup.h...](http://www.scala-sbt.org/0.13.0/docs/Getting-
Started/Setup.html) (it would be nice to discuss the red hat and debian distro
families in that Setup page, it looks like you can't currently "apt-get sbt"

------
user1241320
after years of java coding, i started following the scala "trend" but had no
chance of actually using it where i used to work. nonetheless, i did
coursera's odersky course and started using it here and there for (very
little) personal projects. with that in my toolbelt i was able to find the job
i now have. they were using scala/akka/play (but also scalding and other
stuff) and they were okay with somebody with little experience but willing to
commit to it. i accepted and now have spent 4 months away from java and diving
into scala and i just love every bit of it (even SBT that at first looked very
little interesting).

------
campnic
I've been looking for examples of applications built with scala and akka that
I can learn from. I've built small, toy-ish stuff but I feel I learn a lot by
looking at examples. Any have any recommendations?

------
pavanred
Bookmarked, I needed this, very helpful. Thanks.

------
hayksaakian
sorry to nitpick,

the unicode didn't render properly on chrome stable, windows 7

"From ∅ to Distributed Service"

otherwise quite interesting

