3 ms·
> 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
by 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.
- asdf1234 13y ago> They don't get variance right. Do you know what variance is? You ignored that part of my comment. 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.
- pron 13y agoI don't have anything against correct variance, but just to play the devil's advocate, you do know that there are other ways to write correct code than with a "correct" type system, right? AFAIK, none of the safety-critical code running avionics, medical devices, guided missiles and operating systems has been written with a "correct" type system. And people "continue to write broken code" in any language.
- pron 13y ago> This is false, you were misinformed. 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).
- codygman 13y agoI haven't checked anymore than glancing through the slides but it has the words "concurrent data structures in haskell" at the beginning: http://www.scribd.com/doc/28336206/Multicore-programming-in-Haskell http://www.scribd.com/doc/28336206/Multicore-programming-in-...
- pron 13y agoYou are right! Didn't know about MVars. Got some learnin' to do now...
- pkolaczk 13y ago
- ssmoot 13y agoI don't see how a case-class is different than a non-case-class from a Type perspective? It was my impression it was just sugar around generating copy, equals, accessors, an Extractor and a companion-object. 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...
- pron 13y ago> I don't see how the sugar makes them a fundamentally different kind of Type system? 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.
- ssmoot 13y agoI don't think you can write idiomatic Scala with any one of those things exclusively. And I don't see why you'd even try. You might as we'll be arguing that the language shouldn't have for-comprehensions, lambdas, pattern matching or keyword arguments the way I see it. 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.