Why you should consider learning .NET (and an FAQ to get you started)
(FAQ at the bottom)
As I’m sure I have mentioned before, I spent the first 10 years of my career writing C++ code. Much of it was highly complex, mission critical work, but at the end of those ten years, the “skills” section of my CV had only 3 lines: “C++, Oracle, Unix”. I had considerable depth in my chosen domain and tech stack, but was severely lacking knowledge in others.
And that is why I spent 2013–2015 teaching myself the popular languages/stacks of the day: PHP, JavaScript, Python and Golang. Of all the languages above, the one that really resonated with me at the time was JavaScript, in no small part thanks to Node.js — a backend platform that was versatile, easy to write code in, had lot of library support, and was faster than its main competitor at the time (which was PHP). So much so that I wrote an article titled Why you should learn Node.js, which, apart from minor adjustments, remains valid to this day.
So it may come as a surprise to my regular readers that I am now writing an article titled “Why you should consider learning .NET”. Let me explain:
When .NET first entered my radar during my university days (around 2002–2003), it was a clunky behemoth pushing a new, untested language (C#) and was aggressively limited to Windows. At the time, I was happily developing server applications using J2EE (now Java EE), that investing any significant time in .NET felt like a waste. And so the status quo remained for the next 10 years.
And then in 2014, something rather unthinkable happened: Microsoft, which was almost universally hated by developers such as myself for its repeated attempts to scuttle anything open source that was not Microsoft, released an open source, cross platform version of .NET. Unfortunately, this was around the same time I was heavily investing in the JavaScript ecosystem as my primary, and Golang as secondary. So naturally I had neither time nor brainpower left over to master a third.
Then, in April of 2021, on a day I had some free time, almost on a whim, I did this (whenever I learn something new, I note down what I did in a secret Gist, so that I won’t have to re-learn it in the future):
I had the whole thing running in a matter of minutes, using a few entries on the command line (just the way I like it), and on a Mac, no less. No fiddling with Visual Studio or any of the old Windows-only baggage that .NET used to come with. The app complied within seconds, and ran with a remarkably low memory footprint, utilizing very little CPU.
This was a far cry from the .NET I ran away from years ago. More importantly, I had this persistent thought as I was working through my application: this feels like what Node.js could be, if it was compiled, natively type safe and had a rich standard library (rather than a massive node_modules folder).
Unfortunately, for the next two years, I couldn’t do much more with .NET Core because I was helping build a startup that was heavily invested in the Node/AWS ecosystem. Then in 2023, that startup, along with hundreds of others around the world, met its end due to the now notorious VC funding collapse of 2022/23.
While I was looking for fresh opportunities in the aftermath, I noticed that while JavaScript/React/Node.js jobs were on the decline (tech layoffs were in full swing at the time), the demand for .NET talent seemed relatively stable. It dawned on me that many large and medium scale enterprises outside the venture-backed startup world were built on .NET, and they seemed to work quite well. This should not come as a surprise, given that Stackoverflow, for the longest time, ran on two on-prem servers running .NET monoliths, and even now, handles 1.3 billion hits per month with just 9 web servers and 2 SQL servers.
So when I, with my co-founder Gehan, finally started our own company, we made .NET one of our preferred tech stacks. Nearly a year later, it is turning out to be not only a good investment, but a somewhat pleasurable platform to develop on. It does have its warts like any other platform, but they are all tolerable. For me, personally, the biggest pain point is having to work with GUIs, as someone used to running commands and writing scripts on *nix systems. Of course, you can write PowerShell scripts, but I haven’t mastered that skill yet.
If you’re a Java or JavaScript developer who is considering transitioning into .NET, here is a brief FAQ that can help:
How do I get started?
What’s the best way to learn C# syntax?
What’s a good tutorial to get some hands on .NET Core experience?
Follow this tutorial to create a simple Web API.
Who uses .NET?
Many large enterprises, including:
领英推荐
And of course, Bing and StackExchange.
How is C# code compiled and run within the .NET runtime?
C# code is compiled by the C# compiler (part of the .NET SDK) into an intermediate language (IL) that can run on the .NET Common Language Runtime (CLR), which JIT compiles the IL code into native machine code.
Does .NET have a standard library?
Yes. It comes with a large, comprehensive class library that covers a wide variety of functionalities including collections, I/O (disk, network, database) and built-in frameworks for web application and API development. .NET is a batteries-included platform that requires very little third-party framework usage compared to Node.js.
What is the .NET third party library ecosystem like?
.NET’s version of NPM is NuGet. If you can’t find what you need in the standard library, you can usually find it here.
How does .NET handle non-blocking I/O?
C# provides async/await functionality similar to ECMAScript/JavaScript.
Are there any popular frameworks for developing REST APIs and microservices using .NET?
How do I access a database from within a .NET application?
You can use ADO.NET for direct SQL access to databases, or you can use Entity Framework, a built-in ORM for high level access. .NET also comes with LINQ (Language Integrated Query), which builds SQL-like query capabilities directly into C#.
How do I organize my code within a .NET project?
Compared to the Node.js projects, .NET projects use design patterns and separation of concerns much more consistently. E.g. Models to represent data, DTOs to represent data in transit, Repositories to access data, Services to provide business logic, Controllers to handle requests etc.
Clean architecture, is a popular layered architecture for .NET Core projects.
What about front-ends?
Connecting React/Angular single page applications to .NET Core Web APIs is a popular approach. Or, you can develop a ASP.NET Core MVC application.
How do I test a .NET application?
For unit testing you may use libraries such as xUnit, NUnit, Moq and NSubstitute. You may use the ASP.NET TestServer for testing APIs, or you may use a tool that sends actual HTTP requests, such as Postman. End-to-end testing can be performed using your favourite tool (Cypress, Selenium, Playwright etc.)
How do I deploy a .NET application?
You may use GitHub Actions, Azure DevOps Pipelines, Jenkins or any other tool. You may either publish your applications as self-contained executables, or onto cloud infrastructure (e.g. Azure App Service, AWS) or onto IIS. You may also containerize your services and deploy them onto Azure Kubernetes Service.
What IDEs should I use?
Visual Studio on Windows, Visual Studio Code on other platforms.
Software Architect, IT Consultant, Senior Fullstack .NET/React Developer
2 个月Can you please describe several cases, where you will prefer Java stack over .NET
Software Engineer | CSE | University of Moratuwa | Java | Spring Boot | C# | .NET Core | React | Angular | AI Enthusiast
2 个月Based on Sri Lanka’s job opportunities, I have been considering migrating from a .NET Core stack to a Java Spring stack? Do you think it’s a good move to transition or should I stick with .NET Core? I’m aware that both of these frameworks are very similar.
Lead Software Engineer at Vogue Tex | Creator of ITRACK ERP
2 个月Also its comes with rich feature like native AOT, so you can build light weight cloud native Apis with intergraded with dapper like micro ORMs where minimum startup delay and HI performance required. there are lot of useful libraries like Mass transit, Mapster ,Serilog reduce lot of extra works and gives you very good development experience.
Software Architect | Integrations Specialist | Technical Team Lead | AI Enthusiast
2 个月Hasitha as always this is indeed a great write up and thanks for sharing it, with past experiences with handling abandoned .net projects with dll files and needing visual studio for development and not being friendly with Linux made my opinion different in the past, but this write up specifically with all the FAQs gave me a different perspective.
Senior Python Developer at Singapore Airlines
2 个月Thank you for sharing; it was very insightful!