233 points · by pjmlp · 6y ago · 286 comments
So, what’s the best-organized resource for getting up to speed on .NET these days?
Then it's just a massive waste of time and gets in the way.
I really feel that you (and Microsoft) have completely lost sight of the reason why DI was ever even necessary and have become blind to just how much extra code it generates. The only reason was to inject mocks, and people hand-wrung for ages over it because the code to do so infects all the other code. Then people started to try and back justify it with IoC, but it's never really been a convincing argument.
It's also something that if you're not working regularly with it can be very mysterious and when it fails, fails at run-time, quite inscrutably sometimes.
From my perspective it's just boilerplate magic that if you actually need it, fair enough, but if you don't is a persistent, nagging, pain in the ass.
In C# the idiomatic way to achieve this is via constructor injection, which is made much easier to manage in ASP.Net with a DI library that works with the framework for you (either the built in one or AutoFac / SimpleInjector, etc.). But you don't have to use a library; many times I'm writing a simple-ish console app and just use good old "Poor Man's DI" where I manually construct my object graphs at startup.
The main thing holding C# back is the culture around the DI and weird hostbuilder code associated with ASPNET. If you just skip that part, it's great. Unfortunately a lot of web examples, solutions, and code libraries themselves are ASPNET-focused, and more and more of the code becomes some truly bizarre, unreadable framework injection in an inside-out fluent builder.
I find it very useful for several purposes that have nothing to do with mocking or testing.
> and have become blind to just how much extra code it generates
It doesn’t generate any extra code at all.
For the record, I think that built-in .NET DI is pretty bad. It would be better if they managed to avoid including that abstraction in the framework, even if I personally choose to use DI in most of my projects.
When I think DI, I think: //Startup.cs has all the config "goo" I don't want to repeat elsewhere.
services.AddDbContext<MyDbContext>(o=>o.UseSqlServer(config.GetConnectionString("foo"));
services.AddTransient<MyService>();
//MyController.cs (or Page, etc) and others get to use it with no ceremony:
public MyController(MyService foo){ this.foo = foo; }
vs no DI, where the config "goo" has to be repeated in every place I intend to use it (or in this case it could also be buried in MyService.cs):
public MyController(){this.foo = new MyService(new MyDbContext(ConfigurationManager.GetConnectionString("foo")));}
public Dispose(){this.foo.Dispose();}
If I knew MyService would never be swapped out and only ever used in one place, I may opt for the no-DI route. I'll often start there then move it to DI when I want testability, reuse of config, plugability, etc..
For our multi-tiered system, this means managing caching and logging of certain calls and events at the level of data access. And at the service level, it means dealing with things like authorisation.
Smart use of DI sets the system up in a way were it's easy to handle these types of cross-cutting concerns where appropriate, and with minimal boilerplate. It also simplifies refactoring.
Do you just want to `new SomeClass()` instead? If so, what's stopping you from just doing that?
A massive waste of time? Adding a constructor and one line to startup.cs is a massive waste of time? Just how long does it take you?
> It's also something that if you're not working regularly with it can be very mysterious and when it fails, fails at run-time, quite inscrutably sometimes.
If DI fails it’s usually just because you’ve forgotten to add that one line to the startup.cs, and the error you get will tell you that. Can you give me a concrete example of how DI is inscrutable?
Passing required dependencies by constructors makes this extremely apparent, not just to the DI framework but to the developers themselves. With constructor injection I can immediately grasp exactly what dependencies an object depends on without even going into the full code flow to look at all the code to find all the IOC container calls.
Edit: Also constructor injection is critical for testing dependency injection. IT allows you to have automated tests that construct every relevant object using the same DI setup as your live application and you can verify that the DI framework can resolve dependencies for everything.
If your DI is lazily done this cannot happen unless you explicitly call all code flows, opening yourself up to runtime errors that may be missed. Unit tests won't catch this because the dependencies of your production site will be different than the dependencies of your test scenarios.
Personally, I quite like that quite a bit compared to platforms and frameworks where the convention seems instead to be, "RTFM or die (at run time)."
I've actually worked with C# for over 15 years now and written apps with (in order of age) VBScript, webforms, web services (the MS SOAP stuff), MVC 1, MVC 2, MVC 3, MVC 4, Web API, Web API 2, the OData one I forget the name of and asp.net core. Oh and Silverlight. I've probably missed something. On yeah, WCF. And even WWF! Basically EVERYTHING web-related to C#. Plus enough work in PHP, Python, Ruby, Express, etc. to be able to compare different approaches. And even sometimes VB.net, I've maintained and then migrated entire code-bases from that to C#.
I'm not entirely sure what more familiarity I need?
I'd also note that there are a lot of other people agreeing with my in that thread, almost all of whom show a decent technical understanding. And it's got a lot of upvotes.
But, even if I "misunderstood" or have a "lack of familiarity", that speaks of how poor the design/documentation actually is. If you can so easily shoot yourself in the foot with it, it's not fit for purpose.
WebHost.CreateDefaultBuilder().Configure(app =>
{
app.UseRouting();
app.UseEndpoints(e =>
{
e.MapGet("/", c => c.Response.WriteAsync("Hello world!"));
e.MapGet("hello/{name}", c => c.Response.WriteAsync($"Hello, {c.Request.RouteValues["name"]}"));
});
}).Build().Run();
I also stumble over that once in a while but I have no hard feeling on it.https://github.com/davidfowl/Todos/blob/master/TodoBasic/Pro...
I recently ran through the entire ecosystem thinking that there must be something akin to Sinatra (micro web framework) in .Net. Nope. Every single thing is built on top of ASP .net.
I did find a WIP library where they are trying to go for a low ceremony framework https://github.com/featherhttp/framework, but even that is built on top of ASP .net
For me the worst bit about .Net is their treatment of F#. IMO, it is one of the most practical and usable functional languages out there. But none of the official docs have anything on F# at all. Here is an example doc; see if you can find any code example for F#. https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor...
Its always C#. And I have 0 interest in that kitchen sink language.
Between ASP.Net and C# being the entire world for .Net, I have really not much interest in using it for anything. There are plentiful of interesting languages and ecosystems that I can use for my small time projects.
I agree that the ASP.NET documentation is lacking in F# code samples (although the example you picked is a bad one as Razor doesn't support F#, and so naturally wouldn't have F# code samples). You might find that Giraffe is a more comfortable framework, as it's essentially an F#-ified shim on top of ASP.NET.
To me it's usually a synonym to the full-fat MVC with controllers, DI, everything. This is reinforced by most of the dotnet templates and documentation, which make it feel like if you ask for a banana you're given a gorilla and the entire forest whether you want it or not.
In comparison, if you look at Go you'll see the "net/http" package. It's the HTTP server. Extendable. Built in - not something to download from NuGet. Only does HTTP - not reinventing its own DI, configuration management, IIS, etc.
.NET supports as much ceremony as you want to deal with.
This is only true in theory, but couldn't be further away in reality.
Microsoft suffocates everything which is not built in-house 1), so there is absolutely no OSS ecosystem going on in .NET which would allow a choice of different non-ASP.NET web frameworks.
Other languages have a wealth of different web frameworks and some are super basic and lightweight and others are huge with batteries included.
You don't get that in .NET at all. Everything is ASP.NET Core, and ASP.NET Core is a typical Microsoft product - an attempt to build a one size fits all solution, the magic silver bullet to solve everyone's problems at once. Like with all silver bullets, when trying to please everybody you end up pleasing nobody.
1) Except F#. In F# you will find a more vibrant OSS community and non ASP.NET alternatives (most famously Suave), but only because Microsoft doesn't care about F#. Instead of creating an equal level playing field for C# and F# they are morphing C# into an F# hybrid and eventually will stop caring about F# even more than now.
If your view of low ceremony is matching HTTP verbs to methods, you may happily code your own against the HTTP primitives; if you want a framework that abstracts the complexity and provides a shiny-happy path, you may have to allow for some ceremony. The tooling is the antidote to this.
I think the place you trip up here is in not wanting to use a batteries included approach, while using a framework that makes the necessary abstraction/complexity tradeoffs for projects of mid to large scale. The appropriate tradeoffs _cannot_ be one size fits all.
F#'s support is tricky, as the number of users here is dwarfed by those in C#; and although .NET supports this language diversity, there are no direct idiomatic 'conversions' possible between C# and F# in many cases. This multiplies the effort of providing documentation and examples. I too would like to see it treated as a first class citizen, and for that - the code is OSS.
You have hit the core of my issue here. I am more used to the node-express or golang's way of working where you start off with the smallest and simplest scaffolding and then add on the bits that you need. Rails and ASP .Net are not something I want to use for my small time projects.
Its probably unreasonable for me to expect .Net to be something completely different from what it really is, but I really hope that .Net grows up to enable other way of using it.
Does it? The frameworks I use today are really, really simple. Polka on Node and Go + a few helper libraries. It's all really simple and clear what's going on, and I can solve problems of just about any complexity I've come across with just those basic tools.
This is a dangerous way to think about complexity management.
And for sure, they are all based on ASP.NET Core. ASP.NET Core is extremely modular which allows, e.g. a middleware stack like Sinatra being built on top of ASP.NET Core's Kestrel webserver (which ... cite once again Techempower benchmarks) beats everything nearby in the current situation. It would be a horrible choice to built a web server framework right now on .NET without using Kestrel. You will never achieve to get close to the performance of that.
Not very likely, but I think separating the two out would help the ecosystem a lot in the long run.
Here is the last techempower for it; https://www.techempower.com/benchmarks/#section=data-r19&hw=...
Also, F# is community owned to my understanding (up to the statement of a MS Research Employee and F# inventor Don Syme to say that the "Microsoft." prefix on ASP.NET Core are not open source community friendly) while C# is 100% design & developed by MS.
Which - IMHO - makes it very delicate for Microsoft to communicate well here.
1. For a new comer to the language, this is still too much of a hurdle. 2. If I wanted to use F# only as a proxy for C#, then I would rather use C#. I want to write F# code in a functional first and idiomatic way.
This is the stock answer I have gotten in the .Net Community and as someone who wants to use F# for web apps, its a huge turn off. There are pretty much no tutorials, no recent articles and no performant native F# libraries out there. There is no push from MS to improve the situation. and the community is like - This is fine!
Expecting a new user to write c# code with "let" isn't going to fix that.
That said, the new C# language features really do reduce boilerplate when used judiciously - multiple return is now available, "expression-bodied properties", improved template strings etc. Lots of good stuff that is hard to find good documentation for :)
C# 9 also brings top-level programs, which essentially eliminate all ceremony for the entrypoint[0] - an app can now be as simple as:
using System;
Console.WriteLine("Hello World!");
[0] https://dotnetcoretutorials.com/2020/08/30/top-level-program...As far as I've heard it does not exist e.g when it comes for ASP and I believe that what "OP" meant.
I may be very wrong here
You would of course still have all the usual ASP.NET configuration and DI setup to do though, so the impact would be rather limited.
Having this feature aligns nicely with those use cases.
Its nice for beginners, not having to explain every weird word they see, but not much for professional development.
However managing complexity with various language features all over the project makes impact.
>he very sight of dependency injection configuration is cringe.
I'm curious - why?
First of .NET has excellent documentation, right up there with the PHP. Still my favorite documentation site to snowball through sometimes.
Second, "old DI/enterprisey boilerplate" is what saves you when you get handed the project 5 years down the road, and have to be productive as fast as possible.
Edit:
> So, what’s the best-organized resource for getting up to speed on .NET these days?
Probably just the official documentation: https://docs.microsoft.com/en-us/aspnet/core/?view=aspnetcor...
.NET had excellent documentation. I still pine for the truly-comprehensive MSDN of yore (where "yore" == 2007 or so). Back then, they had less ground to cover (only one .NET Framework and it ran on Windows only), and a bigger budget to do it.
These days, and especially after the big migration to a new CMS a few years back, it's really hit-or-miss for me, especially when it comes to UI framework docs.
Overall though, I have to agree that the .NET docs are very good.
If you want to build apps in an entirely different way that looking nothing like the wretched enterprisey nonsense of the C# and Java worlds, check out SAFE: https://safe-stack.github.io/
As far as starting up F#, I try some of the resources here https://fsharp.org/
However, especially in the HTTP land, the namespace give away instantly on any sample (System.Web => .NET Framework vs. Microsoft.AspNetCore => .NET Core/.NET 5+).
To speed yourself up when you have previous experience: I think the docs.microsoft.com page is not too bad on that.
I should say, as someone who wrote Java/Kotlin for years on IntelliJ, Rider is a welcome addition to the C# world for tooling. JetBrains really does try to produce the best editors they can.
I should mention I use Dart / Flutter, this might not be a problem on Java or Kotlin.
If I don't use the right case it's unable to find the right keyword and most of the time doesn't offer the most relevant option after 'myObject.'
The other day I was joking that my main mode of programming on Visual Studio is pressing CTRL+Space and let the IDE code for me. I can't say the same thing for Android Studio.
> Match case - Select if you want letter case to be taken into account for completion suggestions. Choose whether you want to match case for the first letter or for all letters.
Also, there are a few interesting plugins that improve the autocomplete in IntelliJ further, such as Codota: https://www.codota.com (language support varies)
I don't know what Android Studio uses for Dart, but it's definitely not that! It's definitely not an issue for Java, Kotlin, Go, or even languages with more complex semantics like Rust.
They're noticeably working on making it less terribe lately, but at their current speed and considering the work ahead it's going to take multiple years until they have anything anywhere close to Rider today while JetBrains are developing it at multiple times the speed.
Drawbacks: No XAML hot reloading in WPF, lacks GUIs for Microsoft's questionable file formats (resx). That's it.
Ruby's site even does that visual thing where you can tell it was made only to be seen on Macs.
- runs on x86, x64, arm32, arm64
- runs on Linux
- RedHat adding RedHat specific networking adapters
- runs in Docker
- supports systemd as service manager
- is faster than anything else
- stateless is implementor's choice and easily doable
- Redis, memcached, postgres, mysql, ... driver
- Works on AWS and Azure on Linux OS
- VS Code, Rider (and VS on macOS) and dotnet templates for development
I am not exactly sure what is missing.I have been a .Net developer for about 15 years and remember when it was a violation of terms of service to publish .Net performance measurements. Especially performance comparison against Java was something that would get you on Microsoft's bad side real quick.
So it's really I think the difference between performance being a secret, and it being on the front page and Microsoft throwing significant developer resources into it.
My point being, I thought .NETs performance was pretty well regarded already fwiw.
edit: here you go, ranking of web frameworks: https://www.techempower.com/benchmarks/#section=data-r19&hw=...
ASP.NET Core 3.1 holds up pretty well, only beaten by C++, Rust, and a Java/Kotlin Framework called Jooby
And yes, beating PHP was never a thing. Beating node and Java containers is a thing.
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
But unlike GO, you will need to write 50x less lines of code to achieve the same result.
I looked at the benchmarks.
In cases where .NET is faster it's because the C# version is optimized using unsafe code and x86-specific (i.e. non-portable) AVX2 intrinsics to do the math.
Go version is written in straight-forward way. I think all Go programs are shorter than their C# version.
Compare mandelbrot benchmark:
* https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
* https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
Those are not fair comparisons and therefore don't paint the correct picture of relative performance.
This is the link you should share: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
https://medium.com/servicetitan-engineering/go-vs-c-part-3-c... - check out "Runtime Performance" section here, it shows that geometric mean on exactly this benchmark is heavily in favour to .NET, and it's .NET 3.1, not .NET 5.
And we have an unsubstantiated claim from you, the Go is faster, and code is shorter, on average. What is this based on?
What to you is a fair comparison?
Presumably unsafe code is not allowed for C# and Go assembly not allowed for Go. Are there any other restrictions? We could do a naive port of one of the Go benchmarks to C# and see how it goes, which one do you think is a good candidate?
I wrote a lot of C# and a lot of Go. C# has so much more ceremony that it is more verbose and it shows even in the code we're discussing. You just have to be willing to look.
Fair comparison between C# and Go is actually very easy. Those languages are so similar that you can transliterate a given benchmark from one language into another. Then benchmark those versions.
There's just no way that on an average program Go (language statically compiled to assembly with a very competent code generator) will loose in performance to C# (which compiles to bytecode and then JITs that code at runtime using a much weaker code generator).
1. First, unsafe doesn't mean you shouldn't use it on .NET. It just means you need to do more checks manually.
2. A lot of things you can do in Go are unsafe in .NET terms - e.g. even slice is a leaky & unsafe abstraction: https://alexyakunin.medium.com/slice-an-extremely-leaky-abst...
3. Yes, the fact Go doesn't support SIMD intrinsics explains why it loses not only to C#, but also to C++ and Rust on math-intensive tests. But it loses to C# on other tests too - e.g.: - https://benchmarksgame-team.pages.debian.net/benchmarksgame/... - https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
And as you might notice, the code length doesn't differ much there.
Go has support for assembly and supports SIMD intrinsics just fine. See for example https://github.com/bamiaux/rez/blob/master/vscalers_amd64.s
My point is that if you want to KNOW which language is faster (as opposed to trying to PROVE that YOUR language is faster) you wouldn't compare a C# code optimized with SIMD intrinsics with Go code that doesn't use SIMD intrinsics.
The problem with BenchmarksGame is that it doesn't try to enforce apples-to-apples benchmarks.
It's fun thing to see how far you can push a given implementation if you're willing to spend a lot of time on it.
It compares implementation of the benchmark code, not the quality of the compilers on the code that you'll actually write in real life.
Go and C# are so similar that for benchmarks you can transliterate one into the other.
We should be comparing programs that are comparable.
My point is that BenchmarksGame is not comparing comparable programs.
Code for some languages has extreme optimization, including doing things that most people don't do in day-to-day programming.
Go supports assembly. Given enough time I could probably implement a given benchmark in assembly, beating C# (and pretty much anything).
This is used to good effect in Go runtime and some really niche applications but in real life I don't have infinite amount of time to micro-optimize my code and write parts of it in assembly.
What I want to know is the performance of competently written code.
I think the fact that Go compiles to native executables as the default, just gives the impression that it is "low level". That and the lack of features I suppose.
I say all of this as someone who loves Go as a language by the way. C# could use some simplification!
.NET Core in Version 1.0 cheated then by just taking the network layer of node.js called libuv and linked it up (C -> .NET) . In Version 2.x they wrote and independent socket based networking layer straight in C# which outperformed libuv significantly. In Version 3.x they switched over to use new low level runtime primitives (e.g. Span<T>) which could never have been delivered in the .NET Framework (no breaking changes!). Now in .NET 5 more runtime improvements were added.
I think what really changed was the mentality. Before low level stuff was tried to be contained and used mostly for interop. Now the value of the performance of safe low level primitives is seen.
[1] not web stuff, "plain" C# essentially. It has some compute-bound things like encryption and compression and some fancy tree structures, uses a lot of linq in certain parts.
I haven't come across a package that isn't available for .NET Core in at least a couple of years, I think.
In cases where we want to store really complex object graphs in SQL, we typically resort to JSON serialization of those objects. This allows for us to keep the important SQL facts in dedicated columns (i.e. for PK/constraints/indexing) and also have a copy of the full serialized POCO sitting in the last column for convenience.
For reference, these databases (SQLite) are not shared with external parties/systems so we can get away with this sort of heavy-handed denormalization approach. Our use cases of the databases are very well bounded.
In terms of migrations, we just write a simple for loop and use SQLite's user_version pragma to keep track of an incrementing integer version. This means that we actually have a superior solution to EF in that we don't need additional special metadata tables to keep track of this information.
There are some interesting and insightful comments even in those under this article though. I find hiding the entire tree once I see a comment that’s just there for the sake of being negative makes it easier to find the valuable ones.
I remember trying it out (on Linux, that is), and really liked the concept, but it was painfully slow, so it was no fun for me. Like, waiting 3-5 seconds in the REPL for a single line to compile and execute.
Kill the bitch and you will have normal times.
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
https://salsa.debian.org/benchmarksgame-team/benchmarksgame/...
README
https://salsa.debian.org/benchmarksgame-team/benchmarksgame/...
DI == Dependency Injection
My hope was that by the time .NET 5 was out of preview, we would have seen something for this so people could write C# for Canvas in WebAssembly. Alas, not yet!
https://github.com/BlazorExtensions/Canvas
It supports both Canvas2D and WebGL. The API supports batching calls across the interop barrier, so that the interop performance costs are minimized. As for Blazor being slow: please correct me if I'm wrong, but my understanding, that Blazor code is interpreted, because JIT compilation in wasm is not really possible. The implementation of AoT compilation, which will fix the perf issues is coming along, but it's not quite there yet.
Is it basically LiveView on Elixir?
Personal wish for author (Alex Yakunin) - now compare it with rest (Java mainly).
As for me, I wrote https://medium.com/servicetitan-engineering/go-vs-c-part-3-c... that compares C# and Go, and conceptually nothing changed a lot from the moment this was written.
IMO Go is the only viable competitor to .NET nowadays. Java is holding there solely because of Android - performance-wise it's so far behind...
this can of course depend on workload and whether you care about startup time or throughput vs tail latency etc, but on the whole it tended to allow you beat out java, go and other competitors most of the time.
with AOT being a standard option now, getting quick startup time is easier too, along with the other improvements
You even have hardware intrinsics available to play with, and for performance-sensitive libraries such as hashing algorithms, it's typical for performance to come within spitting difference of RAM speed.
Where on Earth? I could tell you precisely where if it mattered. I'm certainly glad the team at MS has been focusing on performance now because they certainly didn't when the team I was on decided to try it. (Hey, maybe they could help out the Visual Studio team as it takes like 10-15 seconds to open the app to an empty screen).
I haven't run any tests lately (and probably never will as I'm not interested in a language that emits IL rather than machine code; or a language that uses a GC) so I apologize for throwing out the 15x number when it is probably not correct. It won't happen again.
I would wonder why some game studios (like Supergiant Games / Hades) ended up porting their C# game engine to C this year? Was it because C# was fast enough? Or maybe it was to make the game more portable to other platforms? Not sure.
i feel like a lot of people’s ideas about c# performance are from before .net framework 4 which was years and years ago
This benchmark ranking shows ASP.NET Core coming in 6th place, compared to Spring at 34th, Express at 76th, and Django/Rails near the bottom.
I can't speak to the usefulness of the benchmark used.
However, also check the definition of the rows. With Plaintext there are 3-10 entries for ASP.NET Core with different level of comfort (from "do not do that at home", to express like middlewares to "rails like MVC")
1: Drogon (c++ Framework)
2: Actix (Rust Framework)
3: may-minihttp (Rust Framework)
4: Lithium (C++ Framework)
5: Jooby.x (Java/Kotlin Framework)
6: asp.net core
So I guess that would be .NET Core 3.1
That is, any sort of astonishing improvements is often a sign of the original version being crappy, so it's also a red flag even if it's ultimately the good news.
So of course a pointy-haired boss found out about it and you end up with stupid stuff like this: https://en.m.wikipedia.org/wiki/Intel_Upgrade_Service
But also the user you are quoting, the "gamedev trick" is actually somewhat of a true story as well. But it wasn't an optimization trick. It was just different teams that each acted as if they are working on the most important thing, competing for limited old-hardware resources! Some coders, pre-version control, would just pre-allocate ram even if they didn't really need it, just so they don't have to go through the dance of asking other teams to release some. As you can imagine, when the project ended up going beyond the hardware limits causing chaos and stress to the devs, those people would descend as heroes and say "Here I was able to free 512kb!" (from their unnecessary preallocation calls)
Ah, to be old on the internet... :)
Joke's on them, software gets slower faster than hardware gets faster.
Actually, I'd argue they are fixing other people's mistakes with some of this.
A great example are the changes around devirtualization and/or removing certain branches, be it in the code level or at the CLR (.NET VM) level. 5-10 years ago, these changes would likely provide far less benefit, possibly not even worth the effort.
But thanks to Spectre/Meltdown/etc, getting rid of such things (especially near the IO layer) has become more important.
How is it a red flag? I don't quite understand your comment.
Something like: a Microsoft programmer uncommented
// PERFORMANCE_MODE = true
to make .NET fast.
His comment is just silly :-)
Perhaps not trivial, but it did have easy optimizations - within hours of it being open sourced, external people who had not worked on the codebase were making pull requests with straightforward (and in some cases substantial) optimizations. Matt Warren (author of Benchmark.NET) has tracked many of these.
I don't think I agree with this, but hopefully that makes it more clear what was meant.
It's more like there's been a few hundred small individual improvements and those provide a lot of improvement in total.
That's a question that can't be answered by comparing one version of .Net to another version. Instead we'd need to compare the performance of .Net to a rival system like the JVM. edit Or rather, a JVM.