Windows Subsystem for Linux

Nov 17, 2022

Windows Subsystem for Linux (WSL) just released v1.0.0, making it "generally available." WSL gives you a full Linux environment natively on your Windows computer. While releasing v1 doesn't mean that much in theory, it usually implies a more strict policy of backward compatibility and fewer (if any) breaking API changes.

As workloads shifted to the cloud, and therefore, Linux, developers increasingly needed Linux development environments to mimic their production environments. Even before that, Microsoft has shipped some sort of Unix-like environment for decades, beginning with Microsoft's POSIX Subsystem in 1993. Third-party solutions like Cygwin and MinGW also provided some level of Unix-like experience.

A brief overview of how each works.

Cygwin – a POSIX-compatibility layer shipped as a DLL and an API compatibility layer. Applications like curl would get ported to Cygwin, but the initial setup would make it appear as if you opened a bash session with all of your favorite UNIX tools. It ran natively on Windows but required tools to be ported and recompiled.

WSL 1 – A reimplementation of the Linux kernel ABI. It consists of a service that emulates the Linux kernel interface by running processes and intercepting syscalls. This means that Linux binaries can run natively on Windows without any emulation from the OS or porting of the binaries. While previous compatibility layers were mostly UNIX, WSL was special because it was Linux. Yet, at the end of the day, there's no real Linux kernel that's running. That means that processes that require special kernel modules usually didn't work. However, file i/o is near-native.

WSL 2 – uses lightweight virtualization via Hyper-V to run a real Linux kernel. That means that all kernel modules work and that GUI applications also work. It also means that it can support hardware devices like GPUs.