

Scala is for drivers - rbanffy
http://blog.fogus.me/2011/09/02/scala-is-for-drivers/

======
peteretep
Ever since I watched a Java developer at a client give a rabid "Why Scala is
OMFG AMAZING!!!!!" talk to a bunch of bemused Perl programmers ("and it has
this thing called a map and it has this thing where you can execute some code
for each element of a list inline and..."), I've been carrying around the
following prejudice, which I'd like to be freed from, so help me out:

There are only two types of people who find Scala even vaguely interesting:

\- Java programmers who have never used another reasonably powerful high-level
programming language

\- Programmers familiar with high-level programming languages who have a need
(or want) to target the JVM

What am I missing here?

~~~
joshhart
It's a hybrid OO-FP language that is statically typed with decent type
inference. This has never been done before.

Perl is not statically typed. You might think that's a good thing, but I don't
because I routinely refactor in a large code base. I can make one change and
start propagating it around until everything compiles and unless I've made a
mistake it will all work. I don't make very many mistakes so I can improve a
code base at rapid speed.

~~~
gaius
Ahem, once you have used OCaml, which _is_ a hybrid etc etc, you would never
say Scala has decent type inference. I have to annotate my Scala a hell of a
lot more than my OCaml to get it to compile. All function arguments for
example, whereas OCaml just deals with it with no fuss.

I understand this is because Scala can't use Hindley-Milner due to some OO
reason or other but still.

~~~
fogus

        due to some OO reason or other
    

Overloading would be that reason.

------
CoffeeDregs
I'm not sure I agree with the article. Given that Scala has tried to encompass
every paradigm except 'goto', it's hard to argue that Scala is a carefully
tuned high performance machine (e.g. a specialty sports car, that Alfa romeo).
Rather, Scala is a bit like a Java that had been 'improved' by the Windows
Team. Lots of pieces of flair, plenty of buzz words and a very complicated
UI/language. As a car, it seems more like a combination between the Alfa, a
Zamboni and 18 wheeler.

~~~
sreque
If you compared Scala to C# you'd find that Scala has many features absent in
C#, like a more powerful type inference engine, implicits, pattern matching, a
better module system, and traits. C#, however, has many language features
Scala doesn't, like dynamic blocks, unsafe code, unsigned arithmetic, a built-
in events system, built-in LINQ syntax, real reified generics, and so on. Yet
no one complains about C# being a kitchen sink language!,

It turns out, Scala isn't hard because of all its language features. There are
other languages that easily comparable in size to it and also support multiple
paradigms. It has some syntactic flexibility that some people find offensive,
but it's certainly not the difficult part of learning Scala. Scala is
difficult mainly because it is so well designed that it easily enables the use
of functional patterns that most people aren't familiar with. This means that
to use it you have to learn a new paradigm, and most people aren't willing to
put in the effort to do so.

~~~
jshen
"Scala is difficult mainly because it is so well designed that it easily
enables the use of functional patterns that most people aren't familiar with."

I hear this argument a lot, but I don't think it's true. I've done a fair
amount of haskell, OZ, lisp in various forms, etc, etc. I often have a hard
time reading scala code, more so than any of these other languages which are
also FP. Maybe it's just me, but it sure seems like other people have had the
same experience. I've begun calling it statically typed perl, because my
experience with it is very similar.

~~~
sreque
I haven't used Oz at all, and don't feel like comparing Lisps to Scala right
now, but I would agree with you that functional code that I've seen in Haskell
looks a lot cleaner than it does in Scala. Haskell is, of course, in many ways
a narrower language in scope. It doesn't support subtyping or an imperative
style, and doesn't have to deal with the constraints of running on the JVM or
Java interoperation. I would say that, in general, the Haskell community are
much less interested in Haskell becoming a widespread or pragmatic language.

I feel like the compromises Scala makes are valid. I guess in the end though
if you feel like Scala is unreadable then it is not the language for you.
Since Scala is something I believe strongly in, I wish there were a way I
could help make it more readable for you! As someone who knows both Perl and
Scala well, I feel like there is a whole world of difference between the two.

~~~
Locke1689
_It doesn't support subtyping or an imperative style_

I would argue that monads are the ultimate imperative style.

I would also agree that Haskell users have very little interest in it becoming
mainstream.

My main gripe with Scala (in which another developer in my compilers class
used it, not me), was that when reading his code I saw a lot of "magic." I'm
not sure if that was better or worse, just... different.

~~~
sreque
There are few things that seemed more magical to me at first glance than
Haskell's point-free style! :)

I would explain the difference between Perl magic and Scala magic as being
that Scala magic reduces down to a relatively few simple but flexible rules,
whereas Perl magic reduces to a bunch of edge cases and special rules that
lack any form of cohesion. Once you learn these rules, reading Scala code
becomes very manageable.

I found the Haskell code I saw to be clearer because it's type system allows
one to omit types much more frequently, its indentation and function
declaration style let you avoid a lot of curly braces and parenthesis, it's
type class system involved less syntactic ceremony than Scala's implicits,
point-free style allows one to omit Scala's underscores, and so on. All of
these things added up so that in the end, I felt like Haskell just looked a
lot nicer, much more concise and like the math it was trying to express.

I'm sure some of the authors of Scalaz could do a much better job than me
explaining Haskell's advantages over Scala when writing functional code, since
I am by no means a Haskell expert.

~~~
chromatic
_Perl magic reduces to a bunch of edge cases and special rules that lack any
form of cohesion._

I can think of two general philosophical premises which underlie most of those
special rules in Perl: implicit variables and context. Most tutorials and
books explain them poorly, which is why so many people never understand them.

------
bwanab
Since there are a lot of comments that disagree with the post, I'll say that I
largely agree with its essential premise which is that a language's perceived
difficulty shouldn't be based simply on the initial learning curve, but on how
much it helps (or hinders) once it has been properly absorbed.

My only evidence for this statement is my own experience. I am well on the
right side of the java curve as the article describes and over the first hump
and well down it on the scala curve.

~~~
sreque
In support for your statement I'll add my own experience.

As a language expert, I've become more proficient with Perl the language than
most people I know who program in the language daily. Perl has a tremendous
number of nooks and crannies to explore and is so complex that as far as I
know there are no other implementations of the language besides the original.
However, having mastered Perl, I am still far less productive using it than
any of the other several dynamic languages out there that let you accomplish
the exact same things but without all the extra complexity.

Scala had the opposite effect for me. Having reached a certain level of
proficiency with it, many times I feel like I can express my ideas in code
faster in Scala than I can in any other language. If Scala had faster compile
times and a more Unixy library (not likely, given its Java heritage), I would
even replace my use of scripting languages with it for small tasks!

~~~
wanorris
When you say you "can express my ideas in code faster in Scala than [you] can
in any other language", I'd love to see you expand on this. Why is it more
productive for you than say, F#, or Haskell, or Python, or Clojure?

I don't say this to dispute your findings -- as someone potentially interested
in learning Scala, I'm genuinely interested in any specifics you can provide.
Thanks!

~~~
sreque
Well, a lot of coding comes down to data structures and algorithms, and I feel
that Scala has the best out-of-the-box collections library experience of any
language I've used. This makes it easy for me to choose an appropriate data
structure and write my code as a series of transformations on it. I also like
to think in terms of objects and Scala has the best fusion of OO and
functional that I've ever seen. Finally, for most problems I like having a
type system to help catch errors and to help shape the design process, and I
like the IDE and tooling support that comes with it.

That said, I've never written a line of F# and have written very little
Haskell and Clojure. Clojure also seems like a fine language to get things
done if it is more your cup of tea. If I were to pick a Lisp for development,
Clojure would definitely be it.

~~~
Dn_Ab
I think Scala is a wonderful language, however it is one of many.

Data structure and collections support in scala is equivalent to any
functional language. I would be interested in hearing where you think Scala
offers more.

F# is another functional language that balances OOP in a way that works well.
It is different to but homomorphic with Scala's OOP functional synthesis. Both
allow a very unique style with algebraic types, matching objects, structural
recursion and monad syntax.

------
EponymousCoward
What's worse than a blanket assertion that one language is hands down better
than another? Defending that assertion with trite infographics and limp
analogies.

If you're in a technical leadership role and convinced that Scala is better
than Java then run your team on Scala and take a quantitative look at the
results - bugs, developer happiness, velocity, etc - all the myriad dimensions
of development.

Anything else is just anecdotal, an assertion, fluff.

~~~
fogus

        better than another?
    

Where did I say that? This post was about complexity curves observed during my
experience. I can say I like Scala better than Java, but I wouldn't assert
that is indicative of anything that you should believe. Decide for yourself.
(although it sounds like you might have already)

    
    
        Anything else is just anecdotal, 
        an assertion, fluff.
    

And what are the measurements that you describe? They're certain not science.
But yes you're right that this is anecdotal. That was the entire point.

------
abalone
What are these "incidental complexities" and "type system inconsistencies" the
author speaks of as keeping Java from becoming second nature?

There are probably literally a million Java developers who have reached a
point on the learning curve where it feels second nature, makes sense in the
larger context, stays out of the way (except for a thing or two), and lets
them focus on the problem at hand.

The latest argument I've heard for Scala is that its complexity and difficult
to read code is a plus, because only really smart and dedicated programmers
can handle it. It's a "filter". I like that one. It soothes egoes while
simultaneously allowing results-oriented businesses to dismiss it.

------
ryndam
Am i missing something here? From what I know of Alfa Romeo's they're gorgeous
but about as reliable as driving around a faberge egg.

------
serichsen
Comparing Scala to Java is not the point. You should compare it to Clojure,
ABCL, or Groovy.

------
gaius
Scala is to Java as F# is to VB.

------
mypov
We can put an end to discusion if we just port Haskell to the JVM. (Edit: i
hate my silly cell phone. Spelling!)

------
mberning
So a self-confessed car hater is going to make his case for Scala using a
tortured car metaphor. It doesn't come across well.

A good driver can take a slow car around a track quicker than a bad driver can
take a fast car around a track.

