by jimmy1 · 8y ago · 0 comments
Every time a new version comes out theres a 500 page tome of all the new features added. Did we really need all those features? I would love it if I saw a new version of a language come out and it removes language features, wouldn't that be a change!
It still has all the annoyances of java (the first thing you see in any C# file is a laundry list of imports), I am not convinced the profiling tooling is better. I will preface this with I am still bitter about the initial .NET core rollout which was a crapshoot and had no parity whatsoever with .NET Framework.
> Did we really need all those features?
If you don't need them, don't use them. I've found the new features to be great. nameof, string interpolation, property initializers, exception filters, static imports, null propagator. And if you haven't used the language in awhile going back to 5.0 the async await features are fantastic. 7.1 introduced async Main which we've started using in console apps. I use all of these features every day.
> I would love it if I saw a new version of a language come out and it removes language features
Why, exactly?
2. I will propose that programming languages are like anything else created by humans - some parts great, some parts not that great. Furthermore some parts of a language are used more than other parts, it should be hoped that the parts least used in any particular language are parts of that language that are not that great. Given these things it might be reasonable that some time you saw a new version of a language in which they said Feature X really sort of didn't make sense and anyway hardly anyone ever used it so we are removing Feature X. Adjust code accordingly. (probably there should be deprecation stage of a year or so with warnings)
There are multiple levels of understanding, regionalisms and specialized technical terms that few get to use.
I like C# adding new features, and understand some try-and-see-what-sticks is unavoidable. But I don't understand them not deprecating the old versions. And still wonder if improving an earlier version would have been possible/better.
That's not really true, the list of features in each version is pretty tight and focused:
https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csh...
But .NET is a framework that is written in C# and extensively used by C# and not a language.
But what is true is that there starts to be a lot of overlap and inconsistencies between multiple generations of the framework. You have object methods vs generics. You have async/callback methods vs async/await. You have ref/out returning methods vs valuetuple returning functions. etc. The language is starting to show its age even though the .net team has been adding to the syntax sparingly.
"I am still bitter about the initial .NET core rollout which was a crapshoot and had no parity whatsoever with .NET Framework."
Those two statements seem to be in direct contradiction with each other. Would you like iron-clad parity, or would you like to break compatibility in an effort to shed bloat?
Many changes have also made C# much more productive and expressive by letting you do more with less. Every language has imports but the strong typing and amazing tooling makes it a non-issue. Use VS or Rider and you can type out entire programs in a few minutes without ever worrying about imports.
How come it was decent once but not anymore? As others said, you are probably exaggerating by saying new version comes with 500 page tome.
However it is a joy for me to program in C#. Super-consistent language. And my favorite feature "LINQ" really gets rid of loops and loops and maybe more nested loops. Interfaces, generics - all great features, decently implemented under the hood.
C#'s feature changes over the last few years have been marginal. They nibble at the edges while stuff like record classes--an actually and materially valuable thing that significantly improves the writing of immutable and functional code--have been punted for multiple versions now.
C# is Java now, in a way it wasn't when it was younger. It's afraid of change and in being afraid of change has slowed to a crawl. Such is probably the way of most programming languages and ecosystems. But it is a little sad for me to see.
using System;
using System.Linq.Expressions;
class Program
{
static void Main(string[] args)
{
Expression<Func<int, int, int>> expr = (a, b) => a + b;
Console.WriteLine(expr);
Func<int, int, int> fun = expr.Compile();
Console.WriteLine(fun(1, 2));
}
}
When run, this outputs: (a, b) => (a + b)
3
When a Expression<T> variable is assigned to or a method taking an Expression<T> parameter, the C# code is not translated into MSIL (normal C# is compiled to MSIL). Rather it is translated into an AST. In my example I just compiled it to MSIL, however LINQ-to-SQL and Entity Framework translate the AST to SQL. This macro-like capability is the true power of LINQ. The rest is syntactic sugar (though very delicious sugar).If I were to try to critique LINQ, it would the normal ORM complaints. Sometimes you have to care about what is going on underneath in the C#-to-SQL translation. Your code may compile, but at runtime the generated SQL might have terrible performance.
-anonymous types -implicitly typed variables -object initializers -lambda expressions
It's interesting that all of these features are very widely used (except maybe for anonymous types) outside of LINQ, but LINQ was the driving force for adding them to the language.
Anonymous types were needed to do the equivalent of "select field1, field2" that are familiar to SQL programmers, or to have intermediate values in a chain of Select/Where/Select operators. Implicitly typed variables (var) were needed to refer to the above types. Object initializers are needed so you could create the anonymous types, and non-anynymous ones too without breaking the LINQ chain. Lambda expressions of course were needed. All of the above are used outside of LINQ.
This was done in 2007. Java got streams and lambda expressions in 2014. JavaScript got it in 2015.
The SQL like syntax - well it exists. I think many people don't realize it's there. Everyone uses the method/lambda syntax.
As is probably obvious from my reference to them, I believe that record types would be a contender for "most important new feature"--even moreso than async/await--after spending a lot of time with Kotlin and data classes, it is nearly impossible to go back. C# provides you with the choice of manually-updated boilerplate or mutable objects through your whole stack. That's what has generally kept me away from C# since exposure to first Scala, later Kotlin, and most recently TypeScript. And, while I now work at a C#-first company (not on the C# backend), I don't see a real reason to change that for me personally until they make writing correct code easier.
In many ways, TypeScript seems to me to be a wiser future than what C# is presenting, but that's a whole other kettle of fish.
And the power of ExpressionTrees that allows you to interpret code your own way. For example, substituting SharePoint CSOM library
.IsPropertyAvailable(string)
with IsPropertyAvailable<T>(this T clientObject, Expression<Func<T, object>> propertySelector) [0]
is neat. Instead of magic strings you now have compile-time checking. Now you write .IsPropertyAvailable(s => s.ServerRelativeUrl)
instead of .IsPropertyAvailable("ServerRelativeUrl")
As for SQL, it may sometimes be a blocker, yes. But EF Core, for example, provides a FromSql method to use for complex queries.[0]: https://github.com/SharePoint/PnP-Sites-Core/blob/206ee97d4b...
It can be easily translated to other query languages (like SQL) or functional paradigms, and is much more advanced than some map/iterate operators on generic types (which languages like Go dont even have).
The LINQ query syntax (from x in list select x.a) is syntactic just sugar to easily write complex expressions that the compiler turns into the same standard list.Select(x => x.a) method calls.
The fact that Microsoft keeps doing things like core 1, the 2, xamarin and now this web assembly stuff made the business case for changing better though. Because staying up to date on c# has also become expensive.
Still, stuff like AD and ADFS, msSQL and windows servers are the backbone in a lot of enterprise, and C# integrates really easily in that environment. I still think node.js, powershell and SSIS does it better, but I can certainly see why c# is still a thing.
* Async/Await implementation is pretty much superior
* Real threading; great for task pools as well
* Task local storage; something the nodejs community is very interested in but thus far only lives in hacks on obscure run-time features
* Speed?
* Integers?; come on man
* Linq/Entity Framework(though these should mostly be possible to implement in TypeScript now)
If I had my druthers I'd be using F# though, TBH.
Threading and tasks add unnecessary complexity.
Speed? What speed, this web assembly example is more than 5mb of .net libraries. We make apps for people on less than 3g.
Entity is one of the worst, least productive and most error prone frameworks we’ve ever had in our stack. Especially code first.
Linq almost made us stick with C# forever.
I think that hits the nail on the head; I never got why anyone used that. We never did and we have been using c# for a long time (all over to Core now) and all the horror stories never applied to our work, I think, because we never touched entity.
JavaScript isn’t light either, if you look at the amount of stuff a major website loads.
C# on the server running on .NET Core is one of the fastest web stacks, and the async and threading help greatly with that. You can keep everything synchronous if you want, but it's good to have the flexibility when needed.
How is EF unproductive? What options are better?
C# the language is also not the same as the .NET runtime and framework, but Microsoft is the best organization in the world when it comes to backwards compatibility and the C# code you wrote a decade ago will still work flawlessly today.
I don't understand how you're switching to Node.js and shell scripts(?!) to take over all that functionality.
SSIS is better at moving data.
Powershell has come really far, it’s certainly not C#, but where it really excels is when it’s integrated into our Azure orchestra giving us faster error reporting and making us capable of addressing those errors quicker. It’s also a language that’s shared between developing and operations. So while C# is better technically, powershell is better organizational and that means it’s better.
Simply put C# has become an unnecessary burden, in our setup. I’m not sure I’d use node for huge projects, but our backends are mostly simple frameworks for manipulating relatively small amounts of data.
We’re not leaving .Net or Microsoft, our node server runs behind an IIS with IIS node. SSIS, powershell and Azure are obviously Microsoft. Our entire security model is based around AD and ADFS.
That is exactly .NET Core
C# might have minor drawbacks (ok single inheritance is a pain) but it works better than most languages in its class. The only thing that makes me feel inadequate is seeing some really advanced level Haskell code :o
But all that aside, C# is still decent, the only thing making it less shiny now is that we realized that OO is a promise that didn't deliver. I don't want to program another line without proper algebraic types for example - yet here we are.
Hell, it’s still not easy for people to deploy a .net core web api and run it in an IIS installed with basic settings. You can laugh at it, but that’s 80% of the damn workforce who doesn’t know how to do that.
I mean, the JS environment changes, but I haven’t had to pay for anyone getting reschooled since we swapped to JS.