by MichaelGG · 11y ago · 0 comments
On the plus side, they're finally talking about something that should have been addressed back in 1999.
The downside is that C# seems to be getting a lot more complicated due to having to graft this stuff on in an ugly way. I agree the language needs tons of work. I just wish they had better fundamentals so it was neater. F# already has most of what C# can aspire to be, but it feels far less complicated.
Since the languages them selves work quite differently the interpreter and the CLR can't really treat them the same way heck if you make something simple lika a hello world in VB and C# the MSIL won't be identical.
And with the current nullable support then currently supported Nulleable Type Values for VB.NET and Nullable Types for C# don't really work exactly the same way because they still need to conform to the specification of their language first and then to the CLR.
I'm not sure which interpreter you're referring to, but languages don't need to emit similar IL for executable code (why would it matter?). What counts is that the type defs end up exported in the same manner. If making a class in VB emitted substantially different IL than C#, that'd be an issue.
Ideally these features would be designed at a higher level, in the CLR, aimed to target as many languages as possible. I.e., they shouldn't be proposed as C# extensions.
Yet in C# you have hard-coded keywords for things like System.Threading.Monitor (the lock keyword). This doesn't exist in F#-the-language, but is implemented via a simple function so it doesn't count. (Just like you wouldn't consider System.Math.Max part of C#-the-language).
In C#, you have hard-coded operators, whereas in F# they're essentially just functions (compile-time type parameters work similar to _Generic in C11). In C# you have hard-coded LINQ and async syntax, whereas in F# you don't (just one general construct for computation expressions).
People cite stuff like F# pipelining, but that's not a language feature, it's just a function. C# and F# both have quotations, but F#'s are more complete, not a one-off to implement LINQ-to-SQL. That reduces complexity, or is at least a tie. (In the way that arithmetic over integers is less complex than arithmetic over int32.)
Type extensions are another case of this. C# has them, but only partially implemented (extension methods), whereas F# implements the feature in a less complex way that provides more coverage.
OTOH, F# does stuff like transforming Int32.TryParse to match as a tuple (nice, but a complication). And it also has really ugly things like this one: Explicit parameter names take higher binding than = operator. Example:
Foo(Bar = Baz) // Calls Foo with argument Bar with value Baz
Foo((Bar = Baz)) // Calls Foo(bool) with result of (=) Bar Baz
My gut feeling is that once you subtract F#'s stdlib and add in C#'s plethora of edge cases, you're not actually significantly less complex in a meaningful way using C#, and F#'s improved uniformity wins out.