Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Because less is more.

What makes Java and Kotlin more popular languages than Scala is that both Java and Kotlin are being extremely deliberate in choosing what features they include and more importantly, which not to include.

Scala includes everything by default because it allows the EPFL to submit a lot of papers to conferences.



Why do you think Scala has more features than Java/Kotlin?

I think it's the opposite. For example null: where Kotlin has a special operator and semantics, Scala simply has the "Option" type in the std lib.


Do you seriously think Scala has fewer features than Java and Kotlin?


But there is no such thing as Java. It is Java plus spring plus guava plus something else for immutables


I think the point is that comparing Scala the language to Java the language is apples-to-oranges. In general you are using Java along with a bunch of libraries (or Scala plus a bunch of libraries) so the question is whether Java plus all the libraries you are using is less complex than Scala plus all the libraries you are using. And the answer is not nearly as obvious as many people tend to assume.

For example, the most common thing people point to when talking about Scala's complexity is implicits. And that's fair because implicits can be hard to understand and can be used in wildly inappropriate ways. But I have found that what implicits are mostly doing (at least when used correctly) is taking stuff that would be implemented in Java with some crazy runtime reflection scheme and making it a compile-time construct. So then the question is not "are implicits complex?" but "are they MORE complex than the equivalent implementation using reflection?" And on that question I would say absolutely not! Runtime reflection is (to me at least) much more opaque, error prone and difficult to debug.


Implicits are just typed globals that you have explicitly ask for. Scala’s flexibility is the problem, we make scala code look like Haskell, or strange Java, or Idris. Very few people actually write scala sticking with their own pl linguistic baggage instead


All languages have their libraries and design patterns, not sure how your comment answers my question.


I would say so. The language specification of Scala is much shorter than Javas.

Having less features does not mean the language is easier to learn though. Scala has less features, but the ones it has do work well in combination with the others and are very general.


The specification of Brainfuck fits in two paragraphs, according to your definition, that should make it a very easy language to program in.

The fact that Scala's features work well together is a myth that's been debunked over and over. Just look at the number of semantic meanings for "implicit" or the underscore character.

Scala is just what happens when a language just adds every single feature under the sun with very little care for user productivity.


Scala is one of the more misunderstood languages, partly due to its higher learning curve compared to most language.

The implicits you mentioned are a good example. It is one feature and consists of two parts:

1. Implicits at use-site: they define that a not explicitly provided value can be filled in implicitly by the compiler

2. Implicits at definition-site: they mark those values that the compiler is allowed to fill in at use-site when a value is not explicitly provided

That's all there is to it and one without the other would be utterly useless, so it really is _one_ feature.

But that one feature can be used for multiple things and I assume that this is what you meant. For example, they can be used for method extension syntax (which is a distinct feature in Kotlin) or derivation (e.g. serialize a structure into json, which in Java is usually done with reflection or annotations) or ad-hoc polymorphism (emulating typeclasses similar to Haskell).

Mind that these use-cases were not foreseen when Scala was created! But because implicits are such a powerful language feature, Scala can now have method extension syntax without any changes in the language (well, besides some minor optional syntactic sugar, but that's it).

Java cannot easily have this syntax and Kotlin only has it because it was added from the beginning.

Implicits are a beautiful example how a well thought and flexible language feature covers multiple features of other programming languages at once.

The underscore character is a different thing, because that isn't really a language feature, it is syntax. But I agree that it is overused in Scala and is quite confusing in the beginning.


Wait, so is it that Scala has too many feature or too few?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: