View profile

What JavaScript Can Learn from C#

What JavaScript Can Learn from C#
By Mastering JS Weekly • Issue #58 • View online
My first software engineering internship was almost exclusively in C#. Unfortunately, it taught me to dislike C#, and I spent the next decade or so with C# near the top of my list of languages to avoid.
However, I recently had the opportunity to tinker with C# again. I was pleasantly surprised: C#, and .NET as a whole, has come a long way over the last 15 years, and the overall developer experience is pretty solid. In particular, async tasks are excellent: all the convenience of JavaScript’s async/await in a statically typed language.
Here’s a couple of aspects of the C# developer experience that we’d love to see in JavaScript.

Built-in Version Management
The dotnet CLI lets you install multiple versions of the .NET SDK. One CLI, multiple versions. Plus, each project can specify what version of the SDK it targets in `global.json`, which means you can switch between two projects that use different SDK versions without reinstalling.
Microsoft creating delightful DX
Microsoft creating delightful DX
It would be great if Node.js could do this too. Instead of switching Node versions using symlinks or nvm, running `node index.js` could pick the right version of node from your `package.json` file. You can use `nvm run` for this, but it would be neat if Node could switch versions itself.
Async Function Support for HTTP Servers
C# async tasks work great with the built-in HTTP server class:
Async HTTP server in C#
Async HTTP server in C#
Unfortunately, Express still doesn’t have good support for async/await error handling, nor does Node.js’ built-in HTTP server class.
Moving On
Despite these differences, I still strongly prefer Node.js for backend development. But C# does have some neat features that make it an interesting option for backend development, most notably async tasks. It’s a viable alternative to other common statically typed backend languages, like Java or Go.
Most Recent Tutorials
JavaScript String Interpolation - Mastering JS
How to Use Websockets With Your Vue Projects - Mastering JS
How to Use D3.js in Your Vue Projects - Mastering JS
Handling POST Requests with Express - Mastering JS
The Difference Between let and var in JavaScript - Mastering JS
Other Interesting Reads
Intro to C# for Javascript Developers, Part 1 - DEV Community
How to Run multiple Versions of NodeJS with nvm | by Lương Như Toàn | Medium
Use Go Channels as Promises and Async/Await | by Minh-Phuc Tran | Level Up Coding
Did you enjoy this issue?
Mastering JS Weekly

A weekly summary of our tutorials

If you don't want these updates anymore, please unsubscribe here.
If you were forwarded this newsletter and you like it, you can subscribe here.
Powered by Revue