Re:It’s strange what people put up with in C#
by goto11 on Saturday August 15, 2020 @06:57AM
(#24167954)
The compiler does warn when you discard a value, but I assume a C# notebook is something like Jupyter? It is probably a special case in that environment.
There is Comparer.Create convenience method which creates an IComparer instance from a lambda. But yeah it is a workaround.
Re:It’s strange what people put up with in C#
by np_tedious on Saturday August 15, 2020 @07:15AM
(#24168031)
Sounds fine to me. Unused valuable will get you some squiggle warnings in the editor, but not in a notebook.
As far as "language gotcha" articles go this is pretty weak IMO
Re:It’s strange what people put up with in C#
by dcanelhas on Saturday August 15, 2020 @07:19AM
(#24168056)
The semicolon at the end of a statement is possibly matlab-inspired.
Re:It’s strange what people put up with in C#
by siwatanejo on Sunday August 16, 2020 @01:36AM
(#24175480)
> The compiler does warn when you discard a value
The C# compiler doesn't; the F# compiler does.
I also don't understand how you can have a "return true" for a function that's supposed to return a formatted value.
I don't know what a C# notebook is, but the difference between a statement and an expression is made in any imperative programming language I know. However, the example is very strange; why would putting a semicolon at the end of the line make any difference? Why should it even compile without it?
As for the ICompare interface, I think the author has a point. The example class they give is unnecessarily complex, but they're right that the lack of concise inline class definitions can sometimes be annoying. However, I'm pretty sure you can use lamba functions to do the exact same thing the author is showing in F#, down to storing the comparator as a Func<> variable.
The lack of HTML generation is also a weird one. C# is not a template language and is not intended to be one. You can use ASP to generate HTML pages fine, but I don't understand the value of a DSL to generate HTML in pure C#. Is the loj 't that the syntax can't be radically reformed? Because I consider that to be a good thing.
The point I take away from this rant is that the author is trying to use an imperative language with some functional language features as a fully functional language. These aren't shortcomings of C#, this is the result of using the wrong tool (or using the tool wrong) for the job.