So good to see this. I have seen so many developers use the latest C# features heavily, to avoid looking weak.
So good to see this. I have seen so many developers use the latest C# features heavily, to avoid looking weak.
> Our aim is to produce timeless code that will be readable, understandable, and maintainable by programmers who have not yet been born.
Older developers (like me) have opposite problem and I have been fighting for months to not upgrade .NET4.8 to .NET8 due to compatibility with our current deployment chains etc. In the end I had to admit that using .NET8 for everything is going to work too and is going to give us access to better tools and new tech either through some teething problems.
There is no such community push but like anywhere else, you'll see folks get excited about new toys and then try to force them in to try them. It's not any worse for C# than anything else.
Yes. Engineers use the latest features heavily to demonstrate that their skills are current.
One of the worst such features is "var". Some tools even flag your code for not using var when you could. Inappropriate use of "var" makes code harder to read (and even MS documentation says this) and makes code slightly less reliable too.
https://en.wikipedia.org/wiki/C_Sharp_3.0#Local_variable_typ...
Besides making the code harder to read, "var" also makes your code less reliable as seen in this example: https://circles.page/567f44465c28b00bf8ed6cf9/Csharp-Type-In...
The problem you see is independent from var.
Employee e = SomeMethod();
e.Fire();
This does NOT have the same problem as var. When you use var you reduce the opportunities for the compiler to catch your bug. So the best practice is to explicitly state the type when possible. It makes the code more readable too.What's more, Microsoft recommends using implicit typing for local variables only when the type of the variable is obvious from the right side of the assignment. See: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals...
But that's not what the community is doing, and some tools (JetBrains Rider) recommend using var whenever possible.
I disagree with this too, I think your example is a classic case of preprocessor directives making it difficult to know what your code is doing because the build system is going to conditionally change your code. Var or not, you can't even know what's being compiled just by looking at the file, and that's a larger problem than the use of var
https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...
I have seen code that sorts numbers as strings, because nowhere in the code was the intent stated that the array is supposed to hold numbers. As a result, if the programmer forgot to convert strings to integers at input time, the bug is never caught.
See: https://circles.page/567f44465c28b00bf8ed6cf9/Csharp-type-in...
There are, occasionally, the “wow, I got to have that” moments and those are great, but rare.
But somehow, almost no one wants a language that is already super-terse in the first place (like Lisp or APL- family).
And yes, that requires a paradigm change to make the most of it - but so does e.g. LINQ.
It’s about the journey, not about the destination.
Just put the equivalent code side by side and look. You would be surprised at how much verbosity you choose to ignore.
I purposely type everything when coding[0], which makes me painfully aware of all the verbosity and boilerplate. I last wrote Java about 12 years ago (first wrote Java 25 years ago), and it was among the worst at every point in time; I have very little desire to see what it evolved into, but if you can link to a terse, modern Java codebase I will take a look.
chaining a-la Ruby does not make code terse; good selection of primitives, and good idioms do. APL family including J & K are at the extreme, and nothing else comes remotely close.
[0] need to get on the AI assistant bandwagon .. haven't yet