2 ms·
One big thing: Immutability by default. That's possible in C#, but it's hard to be sure everything is immutable => http://stackoverflow.com/questions/5097287/ho
by eloisant 12y ago
One big thing: Immutability by default. That's possible in C#, but it's hard to be sure everything is immutable => http://stackoverflow.com/questions/5097287/how-to-create-immutable-objects-in-c http://stackoverflow.com/questions/5097287/how-to-create-imm...
A lot of interesting aspects of Scala are possible only because of immutability.
And a lot of smaller things:
* Typeclasses. In Scala you can implement them with implicit parameters, I have no idea how you would do it
* Case classes. Again in C# you can implement something that kinda looks one with readonly and just a getter, but it's not as good as you won't get stuff like equality and copy, you'll have to write the boilerplate
* Pattern matching, in particular with case classes
* Option. You can create your own, or use the Option from FSharp, but all the lib you will use will be returning null all the time.
* And more...
Additionally there are aspects that are more of a personal preference, like how the "map" function is called "Select" and "filter" is called "Where", and so on. All functional languages use the same names, the SQL-like naming for manipulating collections is just confusing for me.
At the end of the day, Microsoft tried to build a better Java when they designed C#. And it is indeed better than Java, especially because they moved fast in their versions while Sun/Oracle was terribly slow (why did we have to wait that much for lambdas??). But C# mostly sticks with the same concepts as Java (OOP) while Scala truly embraces both FP and OOP.