Hacker News new | comments | show | ask | jobs | submit login

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.




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).


I explain why I think Scala will be giant to people by saying it is Java's C++. It's as painful or nice as you want it, one company's use looks nothing like another's and it is building on years of pain points to solve problems in a different way while still using the current ecosystem(s).


I explain why I think Scala will be giant to people by saying it is Java's C++.

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.


Java's C++

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".


It is too late for that.


I have this sneaking suspicion that Scala has blown past C++ and is taking aim on Perl.


I agree, but use that as a sell for why I think it's reasonable to use for business. It usually follows a technical discussion of it's benefits.


I'm noting with some relief that the Scala hype is over. Definitely.


The Scala hype, if there ever was one, started because for a long while Scala was the only high-performance alternative to Java on the JVM. Groovy was too slow, and many people prefer static typing. But then a large gap started to emerge between what most Scala users needed (and the reasons they turned to Scala in the first place) and what the language designers decided to give them. There were all sorts of funny operators and then implicits, meant to support DSLs. Then came all sorts of nifty tricks like type constructors, whose purpose, I think, was to simply prove that it's possible to build a statically typed language that has inheritence, yet does not require casting, ever. That is, if you're willing to put in the time to learn the intricacies of the type system. Well, they've proven it's possible alright. It is truly a great achievement in PL research, only it came at the price of making the language more annoying with each release. Who cares if you need to cast now and then if it makes the type system simpler and compilation times shorter? Now there are other alternatives. For those wishing to see the light of a new, better, way to program modern machines there's Clojure. For the more timid of heart, Kotlin has been/is being released. It is everything Scala's original users wanted from the language.


I think your warnings about complexity in the type system are prudent, but your comment about casting is off. Casting (with the exception of primitive types) is a very blunt hammer to bash your way out of a type system. The MLs have a simple type system, yet you almost never need to cast. It's worthwhile from a language design perspective to try to eliminate the need to cast entirely, and I believe you don't have to complicate your type system to do so.

Also, you note that "many people prefer static typing", but then you suggest Clojure...


Well, avoiding casts AND supporting inheritance AND having a simple type system is pretty hard. You can usually just pick two of the three.

Many prefer static typing, and many don't. BTW, Clojure is indeed dynamically typed, but it has a "type philosophy" that keeps things nice and orderly, namely no encapsulation and uniform data access.


Java avoids casts in most cases with generics, it supports inheritance, and it has a simple type system. Ditto with C#. (I also haven't heard people complain about the complexity of F#'s type system, so I'd point to it, but I don't know F# enough to be able to say whether it's a good point or bad point in the space here.) OCaml also supports inheritance, although its object system is kinda weird (in that it doesn't really fit with the rest of the language; I wouldn't say it's overly complex though).

Basically I don't think that Scala's complexity should burn us on type safety in general. I think Go and Dart, for example, are an overreaction to the complexities of type systems like those of Scala (no generics and null pointers in the former, and unsound covariant generics and null pointers in the latter). There is room for a statically typed language that brings the benefits of type safety that make programming easier without the complexities that make programming harder; the fact that we haven't found that sweet spot yet doesn't mean that we should just throw up our hands. I'm not convinced that the sweet spot is either unsound or requires casts.


This comment is a masterpiece.


It's a statically typed JVM language meant to be more powerful and at the same time easier to use than Java.

Yes, I would agree with this.


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.


> 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.


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.


It's an April fools joke: "Happy April Fools’ Day!"


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.


"There are varying definitions of "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.


There certainly are varying definitions of "object-oriented"-ness, just contrast C++ and Smalltalk!


And then contrast Smalltalk with CLOS.

(CLOS is the Common Lisp Object System. If Smalltalk is more OO than C++, and I think most people see it that way, then CLOS is ... sideways OO than Smalltalk. It's not quite on the same spectrum, but it is still OO.)


Yes, OOP is not clearly defined: http://beza1e1.tuxen.de/articles/oop.html


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.


It's designed to be a "meeting point" between Java, Erlang, and Haskell.

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?


The biggest reason for supporting DSL's, as far as I understand it, is so that, as with Lisp, much of the functionality of the language can be moved out of the compiler and into libraries. This will make the language proper actually rather simple, though, of course, great complexity can come out of simple, orthogonal rules.


I agree with this 100%. Maybe it was an attempt to ride the DSL fad that Rails ushered in, but it really feels like Scala incurs a lot of extra complexity to support this feature. The Scala code I've written is pretty straightforward but I've made a point of resisting the temptation to build DSLs.


DSL support is tricky business. Consider Greenspun's Tenth Law. I think it's generally assumed in modern languages that it's better to allow this sort of thing than not do so and risk that people roll their own.

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.


I really wonder where you found “some_obj open_!” ... that looks like Ruby.


That looks like Lift's Box class.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: