WSL is the best feature added to Windows in the last decade

1 month ago 4

When Microsoft slipped the first public preview of the Windows Subsystem for Linux (WSL) into the Windows 10 Anniversary Update in August 2016, it mostly appeared to be a niche convenience aimed at developers who missed Bash and a Linux terminal. Few outside the Insider community guessed it would grow into a fully fledged, GPU-accelerated, GUI-capable Linux environment, maintained and delivered by Windows Updates and the Microsoft Store. Yet, nearly a decade later, WSL has grown and flourished into something more, and is arguably one of the biggest features added to Windows in a long time.

The history of WSL

It all starts in 2016

Screenshot of Windows Terminal displaying a list of installed Linux distros

WSL's beta first launched in August 2016, packing a native-kernel translation layer that let Windows run unmodified Linux ELF binaries without a VM. At the time, it was relatively slow and its potential was unrealized, and lacked many features that made it a true Linux experience within Windows. At the time, you'd have been better off using a Linux VM for full compatibility, especially given that not all system calls were implemented in the first build of WSL.

In May 2020, that changed significantly with the launch of WSL2. It replaced the translation layer with a lightweight, real Linux kernel in a Hyper-V utility VM, bringing near-bare-metal performance and full syscall coverage. This enabled tools like Docker to run under WSL, with a number of improvements over running it natively on Windows. Faster Docker daemon starts from cold boot, dynamic memory allocation so it only uses resources that are needed in that moment, and so much more enables better Docker experiences on Windows... while reaping the benefits of Linux.

Since then, WSL2 has seen numerous improvements that have made it even better. It got GPU-compute and CUDA support in 2021, WSLg in 2022 (previewed in 2021), allowed X11 and Wayland desktop apps to run with full GUI support, and an update in September 2022 also brought systemd support for managing services. As time has gone on, WSL has edged ever closer to matching a true Linux experience under Windows, merging the best of both worlds, and tools like Microsoft's Windows Terminal seamlessly embed WSL as a part of the Windows experience.

Performance without compromise

It's a true best of both worlds

WSL2 manages to get close to the performance of bare-metal Linux in most tasks, yet can be interacted with in a way that feels like it's a part of Windows. It shares the Windows kernel’s memory manager, scheduler, and I/O stack, and launching a Linux shell is as cheap as spawning another Windows process. Benchmarks of file-intensive tasks such as npm install and pip install routinely match the performance of Linux under Hyper-V, which is impressive. The only noticeable slowdowns are when code crosses the Windows-Linux file-system boundary, though this is an area Microsoft has been continuously improving on.

When used in development contexts, it's even better. WSL mounted /mnt/c from day one, meaning that you could access your C drive from within WSL. It goes even further today, and it exposes Windows executables inside Linux (such as notepad.exe) and Linux commands inside Windows (wsl --exec python). Developers jump between Visual Studio Code (Remote-WSL), Docker Desktop (which now defaults to the WSL 2 engine), and native Linux build chains without context-switching or dual-booting. So, even in the case of potential lost performance, the benefits of being able to work across two operating systems at once are huge. With VS Code, for example, you can deploy applications into your WSL instance, so that you can test Linux-native applications from within your IDE on Windows and without needing to move files manually to a Linux host.

For GPU uses, it's even better. Running PyTorch with CUDA from a WSL Ubuntu prompt and editing notebooks in Windows makes data-science workflows portable. Official drivers from Nvidia, AMD, and Intel expose DirectML and CUDA cores straight into the WSL VM, so a Windows machine can train the same models as a Linux workstation. Plus, a lot of development contexts in general simply run faster under WSL2, which seems paradoxical on the surface but makes sense when you consider the differences in how Windows and Linux handle the differences in their respective file systems and even the creation of processes.

For those who primarily want to use Windows and aren't developers, WSL can still improve Windows and make it an even better experience for you. As I already mentioned, it can access Windows executables, so you can create an alias that will launch an application on Windows with just a simple command. For example, the following command will launch Sublime Text in your Windows host whenever you type "sublime":

alias sublime='"/mnt/c/Program Files/Sublime Text/subl.exe"

There's a lot more WSL can enable as well. Amazing tools like grep for searching are usable by anyone, and Linux GUI apps can run through WSL, too. Even Docker can be incredibly useful for non-developers, and WSL makes it significantly easier to deploy and use.

What other features compare to WSL?

WSL is fantastic

Screenshot of Windows Subsystem for Linux in Windows 11

In terms of some of the best features added to Windows in the last decade, there are very few that hold a candle to the capabilities of WSL and the gravity of its inclusion in Windows. The revamp of Microsoft Edge might come close, as may DirectStorage and Game Bar, though the former is for a browser that holds just over 5% of browser market share, and the latter two are significantly more niche. In the case of DirectStorage, many games don't use it, and in the case of Game Bar, many users actually disable it, especially as it used to impact performance when it was first introduced.

WSL is huge, not just from a feature standpoint, but also what it means to include Linux as a part of Windows in the first place. There are countless ways that anyone can make use of it, and tools like Windows Terminal were clearly developed with the intention of amalgamating all of the different ways you can interact with a terminal on Windows, including incorporating WSL as a part of your typical workflows. As more tools begin to leverage it as well, the benefits have been made clear when looking to the likes of Docker Desktop and the litany of AI tools that can be deployed under Linux, which can be finicky to deploy on Windows.

If you're not a developer, you can still try out WSL and mess about with it. It's a great way to get to grips with Linux and start learning how it works, and it's never been easier to get started.

Read Entire Article