3 ms·
The traditional concept of generics you see in C# wouldn't be a selling point for Scala. There are more powerful "generic" programming tool in the scala world.
by kailuowang 11y ago
The traditional concept of generics you see in C# wouldn't be a selling point for Scala.
There are more powerful "generic" programming tool in the scala world.
See this article for an example.
https://meta.plasm.us/posts/2015/11/08/type-classes-and-generic-derivation/ https://meta.plasm.us/posts/2015/11/08/type-classes-and-gene...
- edgyswingset 11y agoThat doesn't seem to have anything to do with generics; it looks to me like a great showcase of Traits and having an Optional type. Although I agree that those are more powerful constructs than what you can use in C#, that doesn't quite answer my question about how Scala generics themselves are such a great feature. Perhaps the OP was referring to the type system instead?
- whateveracct 11y agoimplicit parameters of generic traits (aka the typeclass pattern) have everything to do with how Scala's generics can be used in more powerful ways than C#'s. And they are 100% tied to Scala's generics. Generic types in Scala can be used in implicit search kick off inductive generation of type-safe code. If you literally just mean generics at runtime, they are no different than Java's, outside of support for specialization for primitive types. > Perhaps the OP was referring to the type system instead? Generics and the type system are pretty much the same thing? They only matter and have true power at compile time regardless of your language. So the fact that Scala's generics have absurd power at compile-time (way more than anything in C#) is 100% relevant.