Soon the Windows May 2020 Update (20H1) will be released upon the world. This update will contain some nice UI improvements, but most relevant to me it allows Web Developers on Windows to upgrade to WSL 2. This is a significant milestone in the #davegoeswindows saga and it’s worth posting about what it means going forward.

I’ve been running WSL 2 on my 13” Surface Laptop 2 for nearly a year now and the initial results are jaw dropping:

That’s 13x faster! It’s not every day you get a 13x productivity boost for free. I got chills and a bit misty-eyed when I saw the results myself for the first time. Why was I weeping? Well, I was mostly mourning all the lost time I’ve accrued over the last ~5 years.

It’s not just blog compilations either. This improves npm installs, webpacking, file-watching, hot module reloading, server startups; nearly everything you do on a daily basis as a Web Developer is dramatically faster. It’s like owning a Mac again (or possibly better since Apple has been thermal throttling their CPUs in favor of battery life for the last few years).

Why is it so fast?

How could it possibly be a 13x delta? I wrote about it some before when I considered switching back to Mac, but the tl;dr is that disk writes and Linux stat calls were expensive operations to make due to the WSL 1 architecture. And guess what modern web development heavily relies on? Yup. When you compile the whole gotdanged planet on every file save, you do a lot of disk writes and stat calls on tens of thousands of files.

Once you learn about this bottleneck, it’s hard to un-see. Depressing psychology takes over when you hear something’s slow and then finally experience it for yourself. Your world caves in a bit and the tool you like doesn’t seem practical anymore.

Thankfully, the WSL team made a big bet and overhauled the whole WSL system. Those pain points were solved in WSL 2 by embedding a whole first-party Linux VM inside Windows and moving the file operations over to a VHD (Virtual Hardware Disk) network drive. The tradeoff is that you pay a first-time startup hit to spin up the VM, which is in the order of milliseconds and hardly noticeable to me, e.g. nothing like spinning up a docker, it’s actually fast.

Wait. Where do my files live?

To get the full benefit of WSL 2, you’ll also want to move your project files from /mnt/c/Users/<username>/ over to your new ~/ Linux home directory on your new VHD. You can see the contents of this drive on the Network by going to \\wsl$\<distro name>\<username>\home or typing the command explorer.exe . from your bash prompt.

This is your Linux filesystem and it acts and behaves as you’d expect. I made a folder called ~/projects that has all my project repos and then I open those projects in VS Code using the code . command.

Smoother web development

Installing the Remote Development Extension for VS Code is the final step in having a smooth developer experience. The Remote extension acts as a bridge for WSL and forces VS Code to do all its operations (git, command line, extension installations, etc) straight into your Linux distro. It makes it all very self-contained.

At first I was a little upset by this extension, because it kept nagging me to re-install stuff I already had installed. But now I appreciate it because it adds a layer of visualization as to which environment I’m running and where files exist. It takes some of the mystery out of the Windows web development process and using the version control UI in Code is a lot smoother.

A new era ahead

The excitement to install the next Windows Update and to get a proper, functioning, fast Linux environment up and running on my beefy gaming computer is palpable. There’s probably some problems lurking that I don’t know about yet, but following the development on the Insider Preview I know the WSL team has solved most of the initial gotchas.

And Windows Terminal is good now too! It solves all my previous gripes about lack of tabs, JSON configurability, and the ephemeral problem of “feeling cool” on Windows. It’s still weird to say it, but Windows Terminal is hands-down the best terminal on Windows.

Having been developing on Windows for 5 years, I’ve been through a lot. From not being able to install Rails, struggling with faux-bash Cygwin shells, and then sitting in the front row at Build 2016 when they announced the first version of WSL; that’s when there was a glimmer of hope that Web Development on Windows would be viable. Without a doubt, WSL 2 is the biggest improvement I’ve seen since then and it feels like a new era for Web Development on Windows.