Scala is for drivers
blog.fogus.me
blog.fogus.me
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?
Maybe, one day, when the JVM finally keels over and dies and we're freed from the yoke of bad enterprise decisions, we'll all be able to use functional languages that were designed largely without compromise.
To me at least this is a very powerful and important thing.
PS: http://foursquare.jobs for anyone interested in working at a startup that does most of its work in Scala!
Also, I didn't know that .jobs was a top level domain.
On .NET they have it much better, F# is much more MLy.
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.
I understand this is because Scala can't use Hindley-Milner due to some OO reason or other but still.
due to some OO reason or other
Overloading would be that reason.What about OCaml? I've never used it, but I was under the impression it is sort of OO combined with ISWIM FP. I've been poking about and reading about Standard ML and the module system seems like it supports some quite powerful OO stuff, but I also haven't really wrapped my head around it.
I'm a Lisper and I basically don't know what I'm talking about here when it comes to ML and Scala. I do find Scala interesting though.
Scala's static type system also seems to be quite a bit more sophisticated than OCaml (though its type inference is crippled as a compromise).
Nemerle has been available at least since 2005, but I can't blame you for not being aware of it. I probably wouldn't have heard about it, had I not attended the university where it was invented.
Check it out: http://en.wikipedia.org/wiki/Nemerle
The research I'm doing as I wait for comments suggests that it's the power of Perl with some of the good parts of Java, and without having to lean on Moose to get decent OO...
https://github.com/foursquare/rogue/blob/master/src/main/sca...
or
the function/tuple/product classes found here: https://github.com/scala/scala/tree/master/src/library/scala
I don't disagree that letting people express themselves isn't always very useful...
It is a unique language, though. Functional, yet lets you program in nouns, unlike verb-obsessed lisps. Powerful type system, but less stodgy than Haskell. Terse, but fancier than Python. Plus access to rich and well-documented libraries by virtue of the JVM.
In my world (job) you either have to squeeze every possible cycle out of the innermost loops or get new hardware land on your desk which has an assembler and C compiler, maybe even a buggy, unfinished C++ compiler if you are super lucky. This probably sways me heavily against having an especially deep interest in all of these newer languages... I guess there might be some appeal if you are stuck with having to write code which targets JVM.
Real programmers write Fortran anyway, right? (j/k obviously they write C++ [j/k]) :)
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.
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.
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.
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.
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.
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.
Imperative style really benefits from loops and also several design patterns that really don't work or exist in monads.
Actually they do, and exactly for the reasons you just said. C# is one of the largest mainstream languages in terms of syntax. It's definitely a "kitchen sink" language.
Which is not to say it is a bad language. It has its uses like every language out there.
(That said, the port of Scala to .NET made the design decision to not fix this; however, the reason is not "we liked it", but "we don't want to be incompatible with Scala for the JVM": a decision I consider totally reasonable.)
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.
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!
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!
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.
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.
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.
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.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.
Deleted comment
calling many people idiots
Yikes! Did I say that? I have to say that this is a very black-or-white reading of the post. However, I apologize if I hurt feelings because I know some brilliant Java programmers and likewise brilliant people who hate Scala.A good driver can take a slow car around a track quicker than a bad driver can take a fast car around a track.