4 ms·
If you compared Scala to C# you'd find that Scala has many features absent in C#, like a more powerful type inference engine, implicits, pattern matching, a bet
by sreque 15y ago
If you compared Scala to C# you'd find that Scala has many features absent in C#, like a more powerful type inference engine, implicits, pattern matching, a better module system, and traits. C#, however, has many language features Scala doesn't, like dynamic blocks, unsafe code, unsigned arithmetic, a built-in events system, built-in LINQ syntax, real reified generics, and so on. Yet no one complains about C# being a kitchen sink language!,
It turns out, Scala isn't hard because of all its language features. There are other languages that easily comparable in size to it and also support multiple paradigms. It has some syntactic flexibility that some people find offensive, but it's certainly not the difficult part of learning Scala. Scala is difficult mainly because it is so well designed that it easily enables the use of functional patterns that most people aren't familiar with. This means that to use it you have to learn a new paradigm, and most people aren't willing to put in the effort to do so.
- jshen 15y ago"Scala is difficult mainly because it is so well designed that it easily enables the use of functional patterns that most people aren't familiar with." I hear this argument a lot, but I don't think it's true. I've done a fair amount of haskell, OZ, lisp in various forms, etc, etc. I often have a hard time reading scala code, more so than any of these other languages which are also FP. Maybe it's just me, but it sure seems like other people have had the same experience. I've begun calling it statically typed perl, because my experience with it is very similar.
- sreque 15y agoI haven't used Oz at all, and don't feel like comparing Lisps to Scala right now, but I would agree with you that functional code that I've seen in Haskell looks a lot cleaner than it does in Scala. Haskell is, of course, in many ways a narrower language in scope. It doesn't support subtyping or an imperative style, and doesn't have to deal with the constraints of running on the JVM or Java interoperation. I would say that, in general, the Haskell community are much less interested in Haskell becoming a widespread or pragmatic language. I feel like the compromises Scala makes are valid. I guess in the end though if you feel like Scala is unreadable then it is not the language for you. Since Scala is something I believe strongly in, I wish there were a way I could help make it more readable for you! As someone who knows both Perl and Scala well, I feel like there is a whole world of difference between the two.
- Locke1689 15y agoIt doesn't support subtyping or an imperative style I would argue that monads are the ultimate imperative style. I would also agree that Haskell users have very little interest in it becoming mainstream. My main gripe with Scala (in which another developer in my compilers class used it, not me), was that when reading his code I saw a lot of "magic." I'm not sure if that was better or worse, just... different.
- sreque 15y agoThere are few things that seemed more magical to me at first glance than Haskell's point-free style! :) I would explain the difference between Perl magic and Scala magic as being that Scala magic reduces down to a relatively few simple but flexible rules, whereas Perl magic reduces to a bunch of edge cases and special rules that lack any form of cohesion. Once you learn these rules, reading Scala code becomes very manageable. I found the Haskell code I saw to be clearer because it's type system allows one to omit types much more frequently, its indentation and function declaration style let you avoid a lot of curly braces and parenthesis, it's type class system involved less syntactic ceremony than Scala's implicits, point-free style allows one to omit Scala's underscores, and so on. All of these things added up so that in the end, I felt like Haskell just looked a lot nicer, much more concise and like the math it was trying to express. I'm sure some of the authors of Scalaz could do a much better job than me explaining Haskell's advantages over Scala when writing functional code, since I am by no means a Haskell expert.
- chromatic 15y agoPerl magic reduces to a bunch of edge cases and special rules that lack any form of cohesion. I can think of two general philosophical premises which underlie most of those special rules in Perl: implicit variables and context. Most tutorials and books explain them poorly, which is why so many people never understand them.
- Rusky 15y agoMonads are definitely not the ultimate imperative style. I love Haskell, but once you use too much IO or Reader/Writer or anything like that everything gets messy and ugly. Imperative style really benefits from loops and also several design patterns that really don't work or exist in monads.
- saurik 15y agoFWIW, the main (only?) reason Scala needs "implicits" is to deal with polymorphism of generics while being screwed by the JVM's "type erasure": an implementation of Scala that targeted .NET would not need to deal with that, and would therefore also not need the implicits feature. (That said, the port of Scala to .NET made the design decision to not fix this; however, the reason is not "we liked it", but "we don't want to be incompatible with Scala for the JVM": a decision I consider totally reasonable.)
- azakai 15y ago> C#, however, has many language features Scala doesn't, like dynamic blocks, unsafe code, unsigned arithmetic, a built-in events system, built-in LINQ syntax, real reified generics, and so on. Yet no one complains about C# being a kitchen sink language! Actually they do, and exactly for the reasons you just said. C# is one of the largest mainstream languages in terms of syntax. It's definitely a "kitchen sink" language. Which is not to say it is a bad language. It has its uses like every language out there.