2 ms·
I don't know C#, so maybe it has these, but it's unlikely: - absence of null pointers - proper sum types which can be statically checked for exhaustiveness -
by tazjin 3y ago
I don't know C#, so maybe it has these, but it's unlikely:
- absence of null pointers
- proper sum types which can be statically checked for exhaustiveness
- statically controlled mutability (yes, borrow-checking is still useful if you have a GC!)
Also no exceptions, but that's not a type system feature.
- seabrookmx 3y agoC# calls the first one "nullable reference types." When that build option is enabled, all types are non-nullable by default, and you can make them optionally nullable by declaring them like "MyClass? cls = null;" The compiler will ensure you check for null before de-referencing a nullable type.
- tazjin 3y agoHow does this interact with third-party dependencies you use? In my experience, most gradual typing things break down at that boundary.
- seabrookmx 3y agoThis isn't gradual typing? If libraries are not compiled with the compiler option, then all their reference types will be deemed nullable and I need to check for null before dereferencing. I can't do something like "GetItem().Name" if "GetItem()" returns a reference type like I could in Java, GoLang, JS, etc. If that library did use the flag and was provably non-nullable, then I could.