121 points · by janm399 · 14y ago · 85 comments
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.
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).
You know, back when Java was getting huge and I was still in grad school, Java was supposed to cure everything that was wrong with C++.
In the same grad school -- an old timer professor (so old, he actually wrote the very first commercial implementation of Merge Sort -- on paper punch tape, no less) looked at some C++ that used templates and commented, "C++ must be the new Cobol."
The C++ code I like is minimalist. The languages I like the best are minimalist. It's just my personal taste, but I don't see the point of making things more complicated than they have to be.
I would sell it that way to non-technical executives but not to anyone else.
I worked with someone who's a personal friend of Odersky and he's confident that Scala won't turn into C++. He described him as "way more scrupulous than Stroustrup".
Yes, I would agree with this.
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.
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.
I think a lot of this is addressed in the "Programming in Scala" book.
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.
Plus, a DSL building language. I actually think that the features Scala introduced to enable DSLs were the harbingers of the Scala insanity. Why did the designers of a high-performance statically-typed language think that it would be a good idea to support DSLs?
On Greenspun: why are large Java programs hard to read? The language itself is simple. The problem is that most Java (or C++) programs devolve into shitty DSLs after about 2000 LoC.
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.
I wonder if there are varying definitions of "object-oriented"-ness.
Also, I hear clojure is a true scotsman while scala is not.
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".
And yes, sounds like I'm imitating a hackneyed SNL skit, but everything here is factual. I am indeed getting that old.
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.
I actually disagree. Functional syntax means that you need to start using qualified names or polluting your namespace (think of module/import usage in Python, but without OOP dot-notation). I like being able to say:
val herp: Option[Derp] = hurr()
herp.getOrElse(Darpity)
Leaving aside the awful metasyntactic variables, the `getOrElse` method could exist on any number of classes (stuff like `map` sure does!), but I never have to use a qualified name to get the right one. I use dot-notation on the object itself to qualify the method name.I don't find that to be a problem. In fact, I love Python's module and import system. And the worst thing about Python is it's OO dot notation. I wish that Python had multi-methods too, and no OO-style method calls.
Polymorphism doesn't need to be tied to the first argument's type, it can depend on any number of properties of any number of arguments (see CL's and Clojure's multimethods).
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.
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.
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.
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 ...)
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.