top | item 3781035

The truth about Scala

121 points| janm399 | 14 years ago |cakesolutions.net | reply

85 comments

order
[+] enjo|14 years ago|reply
Scala has been on my mind this week, so it was interesting to see this article pop up. I've started to dive into an existing code-base, and I honestly just can't grok what Scala is trying to be.

I think my biggest issue is that the language is so syntactically flexible (verbose?) that I simply have no idea what is a language construct and what isn't.

For instance the code is littered with stuff that looks like:

val something = some_obj open_!;

Is open_! just a method (literally some_obj.open_!) or is "_!" some sort of language construct, because underscores are special sometimes, like with unary_ for instance (or not.. it really just depends).

At first glance the 'almost any method can behave like an operator' stuff is really cool, although as I learned about alarm bells where ringing all over the place. In the hands of even an actually competent programmer it's going to be abused well beyond the utility you get out of it.

It took 30 seconds of looking at existing code to find obvious examples of it. Why is it so evil to clearly denote a method as being an actual method?

Then there is the whole "is this functional or not" madness. It reminds of PERL in that respect. You can accomplish the same tasks in a bunch of different ways.

I guess I'm not terribly impressed. It actually makes me long for the simplicity of C. If you want static typing Scala (and readability adverse type inference system) seems like a really bad choice. At least at the point I'm at about a week into this stuff.

At the end of the day give me the beauty of C, the explicitness of Python, or a much more complete functional language like Clojure. I don't want a hybrid of all of those that seems to create a whole new set of weaknesses and big-time issues. It really seems like the language designer merely looked at Java and tried to create an interoperable language that was as "un-java-like" as possible.

[+] pron|14 years ago|reply
I think I've figured Scala out. It's a statically typed JVM language meant to be more powerful and at the same time easier to use than Java. It's a functional language. Though, it's also imperative. And object-oriented. It favors immutability, except that mutability is just as easy (or hard). It has adopted the actor model. But it has also adopted all of Java's concurrency constructs. It was designed as a very practical language. And it's also a research language with some experimental features. Oh, I almost forgot: it is meant to be a high-performance language. But it's also designed to build DSLs. It's a very opinionated language in the sense that it's opinion is that all opinions are valid.

So I must say that any difficulty you may have understanding what Scala is trying to be is due to no fault of Scala itself. It's very simple, really (well, to be precise, there are different tiers of simplicity in Scala, but I can assure you that each tier is quite simple once you've mastered all the design decisions, and category theory, that fully, consistently and self-sufficiently define the simplicity of the respective tier).

[+] ootachi|14 years ago|reply
Why not just use Java?

Java was designed as a reaction to the complexity of C++. Scala was, in turn, designed as a reaction to the simplistic nature of Java. It sounds like you prefer minimalism, and in that sense Java is a better choice for you. That's what it was designed for: simplicity.

[+] luriel|14 years ago|reply
> I guess I'm not terribly impressed. It actually makes me long for the simplicity of C.

You might want to try Go. One of the great things about Go is that is almost completely devoid of 'magic', and what it says is what it does, and what does what it says.

The syntax is much simpler than C's, and it lacks the (very good at obfuscating) preprocessor.

Once you read the spec (is short and sweet) is very easy to know what a piece of code does by just looking at it.

At the same time Go code is not verbose and manages to be very concise.

[+] kev009|14 years ago|reply
I'm a C fan as well but really like Scala for certain domains. There is complexity in Scala but it's layered in a way that I think is able to support that complexity long term.

I think a lot of this is addressed in the "Programming in Scala" book.

[+] michaelochurch|14 years ago|reply
At first glance the 'almost any method can behave like an operator' stuff is really cool

I dislike operators and all the unspoken, must-be-remembered complexity they impose with regard to associativity and order. I actually think the S-expression syntax of Lisps is a lot better.

A lot of these "weird" decisions were made in the interest of backward compatibility (in the ideological sense, not character-for-character) with Java. If Odersky hadn't supported these infix operators, which have a lot of weird-seeming rules about first characters and what it means when it ends with a ':', the language wouldn't be nearly as palatable.

ETA: It really seems like the language designer merely looked at Java and tried to create an interoperable language that was as "un-java-like" as possible.

I think Scala was designed to use the good parts of Java while throwing out the cruft. It's designed to be a "meeting point" between Java, Erlang, and Haskell.

Clojure, I feel, has disowned its Java heritage more than Scala has.

[+] thebluesky|14 years ago|reply
It's an April fools joke: "Happy April Fools’ Day!"
[+] zohebv|14 years ago|reply
Scala is far more object oriented than Java. So + is a method of the Int object and you can write 2.+(3) instead of 2+3. Methods are allowed to be operators, so that you can write 2+3 instead of 2.+(3). If _ is a separate token it represents an unnamed parameter, no more no less. In your specific case some_obj open_! translates to some_obj.open_.! It is not too difficult, you are just at week 1 of Scala.

As for language comparisons

1. C is simple/readable

It is way better than C in terms of readability. All constructs in C are simple, but it takes a lot of C code to accomplish simple things. Also, how readable is while(<star>d++ = <star>s++);

2. Python is explicit

The advantage of Scala here is static typing and performance and much better IDE support. Python code typically looks cleaner than Scala code, but I have been told that closures in Python are less than perfect. Python OTOH has no build time issues.

3. Clojure is more functional

Clojure is not more or less functional than Scala. There are varying definitions of "functional"-ness. However, the gold standard of a functional programming language is widely recognized as Haskell. Scala is far closer to Haskell than Clojure in this respect. Again the significant difference between Clojure and Scala is static typing, not functional-ness.

[+] soc88|14 years ago|reply
I really wonder where you found “some_obj open_!” ... that looks like Ruby.
[+] nerd_in_rage|14 years ago|reply
this mirrors my experience with scala, except we had about 100+ maven dependencies and build times were closer to 10 minutes.
[+] ismarc|14 years ago|reply
This has been the opposite from my experience with Scala. Rather than build a single system with a large codebase, it allows us to build small, compartmentalized systems and compose them together. Then again, we don't use maven, instead using ant for building and git submodules to handle dependencies.
[+] dkhenry|14 years ago|reply
Reading through these comments I would like to point out this is an Aprils fools day post. Its funny because if you didn't read to the end you might very well believe it.
[+] eta_carinae|14 years ago|reply
> Reading through these comments I would like to point out this is an Aprils fools day post. Its funny because if you didn't read to the end you might very well believe it.

You know that Scala has gone off the deep end when somebody makes a parody post of how complex it is and several people comment and say "Yup, that totally matches my experience with Scala".

[+] stcredzero|14 years ago|reply
90 seconds is a build time issue? Kids these days don't know how good they have it. It used to be time to go and grab a smoke to just login to a box with X-Windows. If our project always compiled in less than 300 seconds, we were golden!

And yes, sounds like I'm imitating a hackneyed SNL skit, but everything here is factual. I am indeed getting that old.

[+] jvandenbroeck|14 years ago|reply
On a serious note, is anything true from the post - if so, what parts? I find the post funny but, I've started to learn Scala (I think it has some pretty awesome features!) but if some of it is true, I might cancel my Scala-learning mission.. :p
[+] nessus42|14 years ago|reply
Scala is awesome–you should definitely learn it.

Scala does provide you with enough rope to hang yourself with. What's the solution to this? A. Don't hang yourself. New Scala shops should definitely abide by the style guide that is provided at scala-lang.org to help with this.

Also, use implicits and multiple inheritance very judiciously. One thing that is quite true from the OP, is that the "cake pattern" is indeed "the bakery of doom". If you have to use dependency injection, use something sane, like Guice. Or just ol' constructor injection.

My only big gripe with Scala is that OO syntax is a blight on the world. They should have provided multi-methods instead, so everything could be done with functional syntax.

[+] michaels0620|14 years ago|reply
I enjoy Scala but I would say there is truth to 3 (phantom menace). Although tool support has improved markedly over the last couple of years I still get cases where the IDE is complaining about an error and I go nuts trying to fix it only to give up, run it anyway, and have the error just disappear.

If you spend too much time reading Scala blogs, you may get the impression that 6 (the type babel) is how many people write scala. A lot Scala bloggers like to write articles that exploit or examine clever aspects of the type system but it can be pretty impenetrable at times. At least to a blub like me.

[+] manorasa|14 years ago|reply
Scala is definitely worthwhile learning, particularly if you're coming from a Java background. If you're using it as a "better" Java it can make your code much more succinct through type inference, pattern matching, traits etc and short code is usually easier to understand and debug. It's also a great way to start learning about functional programming since Scala supports both imperative and function programming styles.

The things to be careful of are the advanced features such as implicit conversions, they seem like a great feature and in a small code base they work great. But if your code base grows at all it can be next to impossible to be sure what your code is going to do.

Not trying to repeat a cliche but as with most things, "With great power comes great responsibility," and Scala gives you a lot of power but it also puts the onus on you to know how and when to use it.

[+] thebluesky|14 years ago|reply
Scala is definitely worth learning. Learned it as a (much) better Java and have never looked back.
[+] wheaties|14 years ago|reply
One thing is true: implicits. Do not let new scalable programmers use them. When used with type classes, magic. When used as "helper" or "convenience" convertions, disaster.
[+] zohebv|14 years ago|reply
Its an April Fools joke.

3) was true until a few months ago. Or maybe its because I switched from a remote source repo mounted via Samba to a local flash HDD :-) I have been using Eclipse trouble free for a few months now, no issues whatsoever, except for some magic required during the initial maven setup.

4) Is an issue Scala outsiders complain about, but I have never seen this as an issue with people actually using Scala.

Build times are high compared to Java projects, though this could simply be because I am using scalac instead of fsc to build projects via maven. However, compilaton is incremental, so crazy build times should never occur in practice and the IDE highlights mistakes in less than a second.

[+] soc88|14 years ago|reply
For all means — learn the language — you can only profit from it whether you decide to use it or not.

In my experience, the language is built by people who really want to make things work. They do all the painful work to make even the most exotic corner cases work as people would expect it. So developers can be confident that the language doesn't break down suddenly, like when you overuse Generics in Java and just hit the wall where the compiler decides that it won't let you do that for no good reason.

The best thing about Scala imho is that they deliver. People are constructive and when valid issues are brought up, they will be fixed. (Better IDE support, more documentation, faster compilation, smaller standard library, better performance ...)

[+] mindslight|14 years ago|reply
Tying a new language to the JVM is basically like helping a drowning man by throwing him an anchor. Scala the language is decent, but the JVM-induced clusterfuck of complex stdlib/IDE reliance/maven makes for a non-starter.
[+] eta_carinae|14 years ago|reply
> Scala the language is decent, but the JVM-induced clusterfuck of complex stdlib/IDE reliance/maven makes for a non-starter.

I see things the other way around: the JVM is a very impressive piece of technology that has been aging impressively well for more than fifteen years while Scala is a C++-like monstrosity that will probably be all but forgotten in a few years.

Personally, I'm more interested in the new crop of JVM languages such as Kotlin.

[+] SkyMarshal|14 years ago|reply
It's also possible to write Scala in Vim or Emacs and using commandline tools like SBT, conscript, and giter8. It's not that bad.
[+] liftup|14 years ago|reply
Some could be taking this article a bit too serious. I self taught myself to code 6 months ago and like enjo stated it seems very littered and perhaps too flexible.
[+] ilcavero|14 years ago|reply
Why does a scala centric company publishes such a poor flame bait article against scala? I think this is just a joke and not to be taking seriously in any way
[+] meow|14 years ago|reply
well it does say "happy april fools day the end" :)