5 ms·
>And you know why people liked it? Mostly because it had lambdas and traits - two features that are in Java 8. I don't think this is the main reason people lik
by runT1ME 13y ago
>And you know why people liked it? Mostly because it had lambdas and traits - two features that are in Java 8.
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.
- tikhonj 13y agoClasses are types. And in Scala, case classes are just an awkward take on algebraic data types. 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_trouble_with_types_strange_loop_2013/cd3bgcu 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.
- runT1ME 13y ago>You also don't have any notion of kinds, which makes quite a bit of otherwise-idiomatic code hard to write. I'm not sure that is true. Otherwise this would not be possible: class MyExample[A[_]](a: A)
- tikhonj 13y agoYeah, I think that part was a bit inaccurate. The core problem is more like the fact that higher-kinded code is hard to write. You always end up writing in terms of concrete types--you can talk about A[_], but not about A by itself. This becomes a hassle when working with things like monad transformers.
- pron 13y ago> How so? Can you explain how you think Scala isn't sound/typesafe? 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.
- runT1ME 13y ago>pure functional languages don't support concurrent data structures which is what I deal with the most 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.
- 13y ago
- jules 13y agoHow in the world is this the top upvoted response? All of this is either nitpicking, arguing over the meaning of words when the intended meaning is perfectly clear, stating an opinion without argumentation, and the rest is just plain false.