https://blog.devgenius.io/6-net-myths-dispelled-celebrating-21-years-of-net-652795c2ea27?gi=7ef0cf441b4f Home Notifications Lists Stories --------------------------------------------------------------------- Write Dev Genius Published in Dev Genius Charles Chen Charles Chen Follow Jan 28 * 9 min read 6 .NET Myths Dispelled -- Celebrating 21 Years of .NET According to Wikipedia, .NET will be celebrating it's 21st birthday this year on February 14, 2022. [1] It's been around for so long that I think many myths and misunderstandings about .NET from the early days persist; modern .NET is very different from the .NET Framework that started the whole journey. In celebration of .NET reaching Minimum Legal Drinking Age here in the US, grab a cold one and let's dispel 6 common myths about .NET! 1. .NET is for Windows 2. It's slower than Node/Python/Go/Rust 3. It's a legacy platform 4. The tooling is expensive 5. .NET isn't open source friendly 6. It's for boomer enterprise development (Note: there's some debate on whether it's 20 or 21 years, but Microsoft's Professional Developers Conference in October, 2001 definitely already referenced .NET in production systems) Myth 1: .NET is for Windows This myth persists from the early days of the .NET Framework. Indeed, it was true: the .NET Framework was initially built for Windows and in its internals, had many references to the Win32 APIs via P/Invoke which barred it from being cross platform and this persisted even while the Mono project was started by Miguel de Icaza to bring .NET to Linux. It wasn't until Microsoft got serious with .NET Core in 2016 did they start to address many of the gaps in Mono and the lingering dependencies on the Win32 APIs. Those early days of .NET Core vs .NET Framework were a mess, but thankfully, that's all in the past with .NET 5 and now .NET 6. Today, .NET 6 -- the most current .NET -- runs on Windows, Linux, and macOS with support for x86, x64, Arm32, and Arm64. [0] Microsoft ships SDKs and runtimes for multiple platforms. This means that, yes, you can build .NET applications on the latest M1 MacBooks: [0] Building a simple console app from the command line on a 2021 MacBook Pro M1. And run them on the latest AWS Arm-based EC2 instances. Microsoft's official Docker images includes builds for all major Linux platforms: [0] Microsoft's Docker Hub listings for .NET include multiple flavors of Linux. This also means that you can build .NET in your CI/CD pipelines on Linux whether you're using GitHub, GitLab, or other CI/CD tools. Myth 2: It's Slower than Node/Python/Go/Rust In reality, .NET 6 is extremely high throughput and in web workloads provides many times the throughput of any of the frameworks running on Node and Python. Where this myth may have started is with earlier versions of ASP.NET. You see, ASP.NET and .NET have always supported asynchronous programming models (what we know today as async/await), but it was somewhat awkward to use and inaccessible to developers in the earlier days (using asynchronous delegates) and thus rarely (and I mean very, very rarely) ever used by most developers. Without asynchronous programming, blocking I/O becomes a key constraint, even in a multi-threaded runtime. In the TechEmpower Benchmarks, Round 15 from February 14, 2018, you can see that ASP.NET actually trails Node.js: [1] 2018: Node.js at #8, ASP.NET Core at #13, Express at #28, Flask at # 57, Django at #61 But by Round 20 in February 8, 2021 -- just 3 years later -- it is absolutely crushing Node (teal-green) and Python (blue): [1] 2021: ASP.NET Core at #8, Node.js at #56, Express at #94, Flask at # 111, Django at #118 What seems insane is that .NET scores 3x higher on JSON handling than Node and scores an order of magnitude higher in plaintext handling. Just what are these benchmarks? Are they somehow biased towards .NET? Here's the code for Express: [1] Line 36 is the JSON benchmark and line 38-39 is the plain text benchmark. And here's the code for .NET 6 (to be benchmarked in round 21): [1] Line 15 returns the plain text response "Hello, World!", as does line 20 in JSON. If we look at the chart above, there is an order of magnitude in scale between Express and .NET in these two actions (JSON: 105,747 vs 1,242,834 and text: 140,585 vs 7,022,212) and I expect the raw numbers to widen with .NET 6 in round 21. Don't be fooled by the visual position in this chart; I've filtered to only JavaScript, Python, Rust, and Go runtimes. Overall, Node is in 56th position while Express is all the ways down at the bottom in 94th with no Python based framework higher than 61st. In gRPC benchmarks, .NET is also crushing it (an order of magnitude greater throughput than Node): [1] If you're doing gRPC, don't even think about Node or Python. If I told you that there was a way to achieve multiples of your current application throughput using a well-supported, mainstream, mature, open source, mutli-platform runtime, and a language that looks an awful lot like TypeScript -- on your current infrastructure or cloud budget -- wouldn't that be worthwhile to seriously consider? At scale, this delta in throughput can equate to a significant delta in cost. It's not just in web benchmarks. In fact, .NET even trounces Go in raw compute. (See Alex Yakunin's series on Go vs C# for a much deeper dive.) Of course, there are cases where .NET will lose to Go, Python, and Node. This is especially true when it comes to "cold starts" because of the nature of the just-in-time compilation to machine code (plus other nuances of how .NET processes start) and thus making it unsuitable for certain types of applications such as CLI tools or serverless functions that require near instant response for a single request. However, it's not nearly as bad as it once was. Tai Nguyen Bui has a great set of benchmarks that show how .NET cold starts can be reduced in AWS Lambda with very little effort and the Microsoft team is working on an improved native ahead-of-time compilation ("native AOT") for .NET 7. With additional improvements and a focus on performance with each release, I have no doubt that .NET will continue to get faster. Myth 3: It's a Legacy Platform To be fair, .NET would now be considered an adult here in the US so it's easy to see it as a "legacy" platform with the new cool kids being Go and Rust. Yet I find this assessment of the platform to be misaligned with reality. In 2010, .NET shipped with the Dynamic Language Runtime (DLR) and in doing so, ushered in an era of rapid and continued innovation with respect to the runtime and supported programming languages as it allowed dynamic languages and dynamic language features to be incorporated on top of .NET. Here's a blog post I wrote in 2009 showing how to implement the Visitor pattern using double dispatch in C# 4.0. As .NET has evolved, it has also adopted many functional programming techniques. Today, it is possible to build using a mixture of object-oriented and functional techniques in .NET. The runtime supports: * pattern matching * discards * deconstructing and tuples * expression-bodied members It has lambda closures, generics (which Go is just getting around to ), extension methods, anonymous types, record types, local functions, channels, and more! With LINQ, C# looks an awful lot like JavaScript: [1] TypeScript/JavaScript array functions up top and LINQ extensions in C # below. It should be no surprise that C# and TypeScript bear a striking resemblance because they were both designed by Anders Hejlsberg of Microsoft: TypeScript: [1] TypeScript code listing with an interface, class, and inheritance. C#: [1] The same listing in C# (If you like Nest.js, chances are you'll probably like .NET Web APIs because of how congruent the two frameworks are.) C# -- the most dominant language on .NET -- continues to evolve and add features. And as Microsoft continues to invest in F#, C# will inherit many of the dynamic, functional elements of F#. Myth 4: The Tooling is Expensive (via u/swalpaExtraChutney) Like many myths about .NET, this likely formed based on early tooling in Visual Studio which was indeed, quite expensive (in the thousands of dollars!). These days, not only does Microsoft provide a free, pretty much fully featured Community Edition of Visual Studio, there are other options to choose from as well: * JetBrains Rider with paid and free licenses * Visual Studio for macOS * and of course, VS Code These days, I do most of my C#/.NET in VS Code on a 2021 MacBook Pro M1: [0] C# in VS Code on a 2021 MacBook Pro M1 with the OmniSharp extension for language features. And it works (mostly) flawlessly. Even fully featured Enterprise Visual Studio is reasonably priced nowadays for the productivity that it provides. Myth 5: .NET Isn't Open Source Friendly Like many .NET myths, this one originates from the days of Microsoft under Steve Ballmer. Since Satya Nadella has taken the reigns, Microsoft's entire trajectory with respect to open source has shifted. .NET itself is governed by the .NET Foundation, the .NET compiler along with many other internals are all in GitHub public repos, and since 2015, it has been certified for Red Hat Enterprise Linux. While the usual suspects dominate GitHub's language charts, C# pulls in at a respectable 9th place. [0] C# has pretty much always been in the 2-4% range While the Nuget package repository doesn't have nearly as many package options as NPM, I find that the key packages that matter are all very stable, well written, secure, and well documented; I've rarely felt lacking in open source options for the applications I've built. What's more is that Nuget tends to have less "filler". This is a side effect of a much richer set of standard and base class libraries for .NET. Having a deep set of first party libraries written and maintained by paid professionals is an incredible asset. Myth 6: It's for Boomer Enterprise Development (via u/similarintrests) .NET is one of the most versatile platforms to build on, full stop. Very few languages are as accessible as C# while being able to build applications for virtually any use case from desktop to devices to web servers to 3D games. The Unity game engine natively supports C# and a ton of games are built on Unity including Cuphead, Hearthstone, Rust, and Escape from Tarkov! Tutorial by Charger Games showing how to use C# to script games in Unity. .NET can also be used to build cross-platform apps using a number of frameworks like: * Microsoft's own Multi-platform App UI * The Uno Platform * and Avalonia With .NET 6 minimal APIs, Microsoft moves .NET closer to the realm of "simpler" language runtimes such as Go, Python, and Node.js and makes it far more approachable for hobbyists and weekend hackers. Here's a .NET 6 minimal Web API: [1] C# .NET 6 minimal style REST API Compare that to Express (JavaScript): [1] JavaScript Express.js REST API Or Fiber (Go): [1] Go Fiber REST API Or Flask (Python): [1] Python Flask REST API My hope is that as .NET turns 21, this post helps dispel a few of the long-standing myths about .NET which continue to be prevalent in the development community. The reality is that .NET and C# are an extremely versatile and highly performant runtime and language to work with while providing many additional benefits for developers, teams, and enterprises; the platform and language continue to evolve and innovate. Especially for teams considering TypeScript on Node.js web frameworks like Express or Nest, .NET and C# should definitely be evaluated given the tremendous advantage in throughput that can be achieved! (For more discussion, check out this Reddit post) 416 416 6 More from Dev Genius Follow Coding, Tutorials, News, UX, UI and much more related to development Read more from Dev Genius More from Medium [1] Clean Thoughts Before diving into the code, I would like to tell a story when I begin learning to develop. I asked one of my co-workers what language was... [0] Building a Video Sharing Website: Part 6 Adding a Video Search Bar [0] How to configure ZSH on MacOs This article exists because I'm tired of having to research and remember this very basic action whenever I need to help a friend use... [1] Developing An Autonomous Racing Car: Interview With Roborace's Chief Engineer [1] How to run DataFlow jobs on Cloud Composer (With Cloud Composer set up steps) [1] MYSQL MySQL is an open-source relational database management system (RDBMS) My Istio adoption lessons learned -- part 2 Istio is really life saver when we are talking about securing K8s services. We just defining which namespace is controlled by Istio... [0] The SOC 2 Report Explained for Normal People The hard part about this topic is making the subject material interesting. So here's my attempt. Reports and "certifications," such as the... Get started [ ] Charles Chen Charles Chen 85 Followers A Guy That Codes # Currently obsessed with C#, .NET 6, TypeScript, Vue.js, NoSQL, and serverless! Follow Related [1] This is how Variadic Arguments could work in C# [0] 3 and a Half Ways to Store Configuration for Microservices in .NET [1] Const vs Readonly vs Static Readonly in C# Understanding the Difference between Const, Readonly, and Static Readonly in C# [1] Let's Learn Blazor: Blazor Server with SignalR Help Status Writers Blog Careers Privacy Terms About Knowable