I don't think this is the main reason people like it. Java's lambdas are also inferior to Scala's.
>a Haskell-like algebraic type system (sealed traits and case classes)
What do case classes and traits have to do with types?
>It doesn't have Haskell's type safety
How so? Can you explain how you think Scala isn't sound/typesafe?
>It doesn't have OO's simple, highly extensible, and just-powerful-enough type system
Uhm, can you explain to me an example of a simple OO type system that is 'just powerful enough'? Because most of the ones I know of are broken, and Scala easily has the best OO type system. C#, java, Go, etc. are all either missing generics (lolwut) or completely fucked up variance.
Scala doesn't even come close to Haskell. For one, it does not do anything to capture effects in the types. Apart from being markedly less safe, this also makes things like STM impractical. Additionally, implicits may be more powerful than typeclasses, but they're also easy to mess up: you lose canonicity. In Haskell, if you have a Set a, you know it uses the same ordering of a as any other Set a; in Scala, you lose this guarantee. You also don't have any notion of kinds, which makes quite a bit of otherwise-idiomatic code hard to write. Take a look at this post[1] for more examples and details.
[1]: http://www.reddit.com/r/haskell/comments/1pjjy5/odersky_the_...
If you want a simple yet powerful OO system, take a look at OCaml. It does OO much better than any other statically typed language I've used. The funny thing is, of course, that people don't use OCaml's object system--not because it's bad but because by the time you're using OCaml, you've already realized functional programming is the way to go. Most of the reasons I've heard for not using OCaml's object system apply even more to other OO languages!
OCaml's object types are expressive and, unlike Scala, fully inferable. And they don't mess variance up! You also get a dual sub-typing with polymorphic variants--I don't know if Scala can do anything comparable with case classes.
I'm not sure that is true. Otherwise this would not be possible: class MyExample[A[_]](a: A)
Because you can do casts, and it's not pure. It doesn't even enforce immutability. You know what? Forget about enforcing – it doesn't even make mutability or casts hard. Look, Haskell is certainly not my cup of tea. Personally, I don't think the effort of thinking about my program twice (once in terms of logic and once in terms of types) is worth it in most circumstances, and pure functional languages don't support concurrent data structures which is what I deal with the most. But I do recognize Haskell's elegance, and if the elaborate type system is worth it, it's only because it can enforce many guarantees. I mean, the whole point of Haskell is that it supposedly makes safer programs. So you pay for the elaborate types (though some consider it a plus), but you gain safety. With Scala you just pay.
> Uhm, can you explain to me an example of a simple OO type system that is 'just powerful enough'?
Sure. C++, Java, C#. Almost all of the world's software is written in C++ or Java. The question is not which language has "the best type system" (and even if it were, Scala can't make up its mind because it's got three of them). A type system is not an end but a means. Practically everyone who deals with type systems agrees that they come at a cost (and Martin Odersky himself admitted as much). But the cost hopefully buys you something. It arguably buys you better design, and it definitely buys you safety. Well, Scala doesn't give you safety any more than C++ or Java, and as for design, it can't even pick one type system; a cornerstone of great design is that you have to make hard choices.
This is false, you were misinformed.
>Sure. C++, Java, C#.
C++ Has a good type system, IMO. The other two are broken. Literally, you can write broken code. Scala has a long list of warts, I just don't think you're listing any of them.
>Well, Scala doesn't give you safety any more than C++ or Java, and as for design, it can't even pick one type system; a cornerstone of great design is that you have to make hard choices.
This is just FUD. Are you telling me Java/C#'s type systems enforce more safety than Scala? Because they don't. They don't get variance right. Do you know what variance is? You ignored that part of my comment.
If I'm wrong, I apologize. I am not familiar with any concurrent data structures in a pure functional language, but I'd love to learn of any. I have not encountered a data structure in a functional language that supports more than one concurrent writer (and I don't mean parallel construction of an immutable DS - that's trivial – but concurrent mutation, like in a concurrent B-Tree, concurrent skip-list, or concurrent hash map).
http://www.scribd.com/doc/28336206/Multicore-programming-in-...
As of C++ templates being extremely powerful - I agree. But this is a similar kind of "powerfulness" as C macros are, only little safer. Technically they are still just a fancy macrogenerator working at the AST level instead of lexer level, knowing nothing about the types (you even have to tell it which symbols are the types, because it cannot reason it out from syntax). IMHO it is years behind true generic typesystems like in Haskell, OCaml or Scala and calling it a "type system" is an exaggeration.
This can't be stated enough, and it's a huge problem in Java and C#. Unfortunately, most programmers don't care and simply continue to write broken code.
I don't see how the sugar makes them a fundamentally different kind of Type system?
And Structural Typing is just Reflection I thought. It's still compile time (which is kinda the point). Which again doesn't feel like an alternative Type system.
But I'm not at all versed in Type theory so maybe I'm just mischaracterizing what a Type is...
They're not sugar. Their crucial feature is that they can't form an inheritance hierarchy, which doesn't work well in an algebraic type system.
> And Structural Typing is just Reflection I thought... Which again doesn't feel like an alternative Type system.
The point is that you can write (and obviously people have) a big, complex piece of software just with inheritance-based types, or just with algebraic types, or just with duck types. They all serve quite nicely. It is completely unnecessary to put them all in a single language (other than to advance compiler technology), and worse than that: putting them all together takes away their respective advantages and causes a lot of confusion.
These things (types) do have uses, but not as competing systems in Scala, but Features. I want to write c#'s using() statement, I'm not especially worried about performance, I can't go and add IDisposable to everything because I want to use it with other people's code and I don't feel like writing a Type Class every time I need to work with a new type. Structural typing is a really convenient feature for that.
Case classes are just Scala's version of a data-object. If you didn't have them you'd just be writing your own version, poorly, and forgetting about hash code and equals and all the other stuff until it bit you.
I really don't see a rationale here for removing these other than you find it offensive. I use Scala because of these things.
Yes, scala is more complicated than java, considered in isolation. But you can write a large program in pure scala, rather than the bloated enterprise frameworks you end up with in java.
If anything, Java is showing that it can clean up years of cruft (Java EE 7 is pretty neat, and even the JDK is finally being modularize) while maintaining backwards compatibility. This is the kind of thing Enterprise wants and needs.
What is this, 1985?
Libraries, frameworks and the community etc make the language these days.
My biggest complaint about Scala isn't the language itself, but the flakiness/immaturity of some of the libraries/frameworks/tools compared to Java.
The only thing enterprise managers want is a language that can dumb down the art of programming to a level a programmers can be managed like assembly line workers. And that is what Java does exactly, an IDE that can make a novice and expert work at the same levels of productivity, extremely verbose code that gives an illusion of people building something big(even if its down right trivial). And most importantly programming effort can be accounted like a couple of least important replaceable folks down the hierarchy doing some assembling reusable units of material.
Change this scenario, a good technology with merit makes programmers very important and makes managers look like desk clerks.
Enterprise Managers don't care a least about type systems, lambdas, or traits or whatever. Most managers don't have a remote clue what those things are. Can the technology enable them to manage herds of programmers dumbed down enough to be managed like sheep? That is all they care.
I won't go into an argument over verbosity, because Java is indeed verbose (about the same as Go and less than C or C++, that were what many in Enterprise used before). But as to the "assembly workers" kind of thing - it is far more complex than that. First, in no language is a novice as productive as an expert; not in Java, not in C and not in Haskell. Second, lots of enterprise projects are far from trivial. Some projects are so damn big that no matter what language you use, it's gonna take a couple of years, several million LOC, and at least several dozen developers, if not more than a few hundreds. Once that's the case, productivity means something else entirely, and yes, planning for team members coming and going is part of it; I think that in that respect Java hit a sweet spot. Obviously, it could be made better; it could be modernized. Personally, I also believe that the JVM is such a great polyglot platform, that projects should be written in several languages – yes, even in the enterprise.
Not all enterprise managers are stupid, and there are good reasons your bank doesn't run on Ruby or Python. Enterprise software technology changes all the time – yes, some of it is due to excellent sales team, but some of it is based on merit. You wouldn't expect that software technologies that are good for constantly pivoting SV startups would be equally good for running banks; or aircraft carriers. The requirements are just too different. Python has its place, as does Java. It's just not always the same place.
Your kidding right? Scala's Java interop is seamless compared to that of Clojure.
Since then, Scala has become a sort of a testbed for new ideas in compiler technology. Consider this – it's basically got three complete type systems: an OO, inheritance based type system, a Haskell-like algebraic type system (sealed traits and case classes), and a duck-typed type system (structural types). Each of these type systems has been enough to write good, complex software, on each own. Scala's got all three, while at the same time missing on all of their advantages. It doesn't have Haskell's type safety and purity (or type inference). It doesn't have OO's simple, highly extensible, and just-powerful-enough type system, because it's so big and complicated, and it doesn't have duck-typing's care-freedom, because it's so heavy. Oh, and it's got macros, too, just for the heck of it.
I know some people like it because they have fun writing lisp, Haskell, Java and JavaScript in the same file and have it compiled by just one compiler. Yeah, it's a cool compiler. But seriously, it doesn't offer anything enterprise would want. It doesn't offer safety; it doesn't offer simplicity; it doesn't offer familiarity. It doesn't even offer much compatibility: it's much harder to integrate Java with Scala than with Clojure or Groovy, let alone Kotlin.
And I'm willing to bet that almost all large companies that currently employ Scala, do it because of its original promise of being a better Java. But if you're a superset of about 4 language families, than you clearly can't a better Java.
For those who want that productivity boost while maintaining familiarity and compatibility, there's Kotlin. And Java 8, of course.