3 ms·
But 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 thems
by pron 13y ago
But 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.
- lmm 13y ago> 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. Learning Scala's type system takes time, yes; it quite possibly takes longer to learn Scala than most languages. But it's still going to be less effort than learning two different languages. I think that most organizations are already using a lot of code that they don't understand. The JVM itself is many thousands of lines of not especially clear code; I suspect very few java-based organizations really understand it (and I've hit bugs in the JVM in real life, so it's not that there's no need to understand it). Likewise large, popular Java libraries like Spring and Hibernate (particularly given that they do bytecode manipulation, so you can't always even assume that the normal rules of the language apply). I think standard library implementations are rarely read in any language, so the complexity of the standard library implementation in scala isn't a concern. I think the interfaces are important, and if users are unable to understand the method signatures then that's a problem. But documenting what a method does is often seen as adequate (e.g. in Python or Ruby the documentation is the only interface signature you get), so I don't see a fundamental problem with the "simplified signature in the documentation" approach (though it would be better to have some way of automatedly ensuring these were correct). (The only alternative would be to give up the power entirely, or to have two distinct collection libraries; neither of those seems like a good answer. If you don't see having Haskell-level language power as an advantage, then yes the complex library interface is not worth it and you'd be better with a less powerful language. But if you see value in writing parts of your system in something like Haskell, I think it's a big win to be able to use the same language for the haskell-like parts and the kotlin-like parts, and learning a complex library is less overhead than learning a second language).
- pron 13y ago> I think it's a big win to be able to use the same language for the haskell-like parts and the kotlin-like parts, and learning a complex library is less overhead than learning a second language. I think not, and here's why: we're talking about large organizations here, right? Because if you're a single developer or a small team, then anything from assembly to VisualBasic goes and it all pretty much boils down to personal preference. But in a large team (say 50 people and up), only one or two would need to master the "Haskell part" (assuming there was a real need for one), and the rest would use Kotlin. So there is no overhead in learning two languages. The developers would learn one simple language that they can understand, and the single star developer (there is usually one in any team) could probably master five different languages if the need arises. Throwing everything in a single powerful-yet-very-complex does not fit with how complex software is actually developed. This is one of the reasons many huge organizations abandoned C++ and flocked to Java pretty much on the day it was released (I'm exaggerating, but in a software-timeframe terms that's pretty much what happened).