3 ms·
No it isn't. Scala has three complete type systems: an OO, inheritance based type system, a Haskell-like algebraic type system (sealed traits and case classes),
by pron 13y ago
No it isn't. Scala has 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 its own (in different languages, of course). Scala's got all three, plus macros. Scala is a superset of Java, Haskell, JavaScript and Lisp; such a language is not simple. A language where it takes an expert to understand how the standard library's linked list is implemented is not simple (even the language creators say that understanding, let alone implementing, Scala collection classes is reserved for experts). You may well understand parts of it, most of it or even all of it given enough time, but it is definitely not simple.
EDIT: Scala does have an incredible compiler, though, and it is interesting from a PL research POV (which is to be expected, given its origins). The JVM community will forever be indebted to Scala. But it is not a language that many will feel comfortable using, and most of those that do, use a subset of it (which is basically Kotlin), and ignore the fact that they can't understand how the linked list is implemented. Kotlin takes a lot of inspiration from Scala, obviously, and learns from its mistakes. It takes that subset of Scala that gives people 99.9% of what they want and need with only 10% of the complexity.
- konstruktor 13y agoI like that you can even explain why it is complex. I was just able to give an example, that is explained by your argument (a type system for a purely functional language as opposed to a mix of everything).
- lmm 13y agoScala's standard library linked list is complex, sure. But it's also considerably more powerful than any equally safe implementation in any language, and considerably safer than any equally powerful implementation. If anything the fact that such complex libraries are written in it is evidence of scala's simplicity - if the language itself were complex, it would consume too much of one's attention for it to be possible to write such complex libraries.
- pron 13y agoBut this is exactly why Scala's designers have their priorities wrong. This safety comes at a price (complexity), right? So, first, they should have asked themselves whether this safety is worth the price. Second, Scala is inherently an unsafe language (unlike Haskell) because it freely allows casts, and doesn't even make them difficult. So then the question is should you pay the cost of complexity in exchange for safety in a language that doesn't really provide safety? I think that the only case where a language designer would answer this question in the affirmative is if they cared more about PL research and compiler technology than about programmers.
- lmm 13y agoCasts are fine as long as you are explicit about them - Scala is about giving the programmer control and visibility over what they're doing, not satisfying some academic notion of purity. My experience is that Scala makes exactly the right tradeoff - in practice, Scala code is substantially less buggy than most other languages (equivalent to Haskell, I'd say), while the complexity of map's implementation doesn't get in the way unless you need it (things that are easy with Haskell's map are still easy with Scala's map, things that are hard but possible with Haskell's map are still hard but possible with Scala's map, and some things that are impossible with Haskell's map are hard but possible with Scala's map).
- pron 13y agoI understand that some would agree with you. After all, there are some people who like Scala and not just for its "Kotlin subset". But can you understand why many organizations would think this is the wrong tradeoff? I, for one, do not like using stuff I don't understand, and I am unwilling to put in the time to understand Scala's types, especially because it's so easy to do without them. If I need Haskell-level type safety for some subset of a project, I would use Frege or another Haskell implementation for the JVM that is certain to come along. For the rest, I'm perfectly happy with Kotlin-level type safety, and for those portions of the project (over 98% for sure) I don't have to put up with a class library I don't understand.
- kenbot 13y agoYou ran with this "three complete type systems" line in the last thread, and it's still totally wrong. ADTs/pattern matching are not "a complete type system". Structural types are not "a complete type system". Scala unifies the different concepts by expressing them through Java-style classes and inheritance. Even if they were incompatible non-orthogonal type systems sitting side by side (they aren't), it is immensely useful to have both dynamic dispatch and ADTs/pattern matching in the toolset; they are often useful for different problems.
- pron 13y ago> ADTs/pattern matching are not "a complete type system". Structural types are not "a complete type system" Why not? Can you not write any program using either? Haskell uses just the former, and JS the latter (though without type safety). > Scala unifies the different concepts by expressing them through Java-style classes and inheritance. I think it "unifies" them only in the sense that the (single) compiler can compile all three. But case classes cannot be part of an inheritance hierarchy nor structural types (or inheritance types) be used as ADTs. The three certainly intersect, but they're not really unified. > It is immensely useful to have both dynamic dispatch and ADTs/pattern matching in the toolset; they are often useful for different problems. Obviously, and that is why some languages employ the one or the other. The question is, how useful is it (from a cost/benefit perspective) to have all three (plus macros!) in the same language? After all, while each has its benefits sometimes, they also overlap a lot, as most programs are about as easily implemented in all three. As I've said elsewhere, in language design, as in most things, one must choose. A pizza, a steak and ice-cream all have their place, but may lose much of their flavor if mixed into the same dish. In the JVM ecosystem we are lucky enough to have easy interoperability between languages. The JVM is a restaurant with a varied menu, and you can have a meal of several courses. The best way to go, IMO, is to pick one simple language you're comfortable with and use it for most tasks, and for those tasks that require specialized skills outside your chosen language's strengths – use another.
- kenbot 13y ago> Can you not write any program using either? While you can make do with either, they have complementary strengths and weaknesses, which are useful in different situations. See "Expression Problem", and "Visitor Pattern". > Why not? "Single Dispatch Polymorphism" is a language feature. ADTs/pattern matching are a language feature. Subtyping is a type-system feature. "Structural Typing" is a type-system feature. Guaranteeing exhaustive pattern matching is a type-system feature. They are not "type systems", and different languages pick them and combine them a la carte. > But case classes cannot be part of an inheritance hierarchy nor structural types (or inheritance types) be used as ADTs Yes they can, and they do. You just can't extend case classes from other case classes. You can use any class as an ADT-like structure if you want, leaving the hierarchy open or closed, and defining pattern matching extractors as you please. It's all part of the same system; whether you call it an "ADT" or a "class hierarchy" is a design pattern thing more than a rigid systemic property. > Obviously, and that is why some languages employ the one or the other Er... that doesn't follow. What I said is that it's very useful having both together. If you don't think that's valuable, that's fine; Scala's not for you.