Windows Subsystem for Linux

As of 2018, I'm using Fedora, and will probably not keep this up to date.

I've been using the Windows Subsystem for Linux (WSL) for most of 2017. It's both a nice improvement for development and a bit of a pain in the butt.

About the weird name: the NT (Windows) kernel has had a variety of environment subsystems: POSIX, OS/2, and now a Linux one.1 It's a Windows Subsystem and it's for Linux.2 I've also seen unverified suggestions the naming pattern is because of a trademark issue.

Architecture

The WSL works with unmodified Linux binaries by offering an environment that executes Linux system calls by translating them into native Windows syscalls (or sometimes by directly handling the syscall). I know very little about Windows internals, but there's a series of blog posts from Microsoft, covering the architecture, the lightweight Pico Processes that differ from ordinary NT processes, and how system calls are translated in order to emulate the Linux kernel.

Enabling WSL

Installation instructions.

You can also get prerelease builds, though the entire process is confusing. There seems to be two sets of build numbers, one around 1600, and around 16000. Major features accompany public releases with names like "Windows 10 Fall Creators Update".

Compatibility and Completeness

Emacs hangs when I run list-packages or try to load installed packages. Versions of GHC starting with 8 are unusably slow: Issue 1671, which should be substantially better in the version being released in Fall 2017. Using stack, LTS-6.35 is fine, later versions are bad.

Another issue is that the WSL doesn't have OpenCL or CUDA support.

Otherwise, I haven't had trouble, and it seems like progress has been pretty rapid.

Using the Windows Subsystem for Linux with Xfce 4

TODO

Where does my code go?

Linux and Windows have different models for file IO and permissions. The upshot is that writing to the Linux filesystem from Windows is unsupported, and may give you files that the WSL can't handle, but the reverse is ok. So you should edit your code in windows, then run it under Linux. But that seems to mean you have to maintain two environments, once to build and run, another for editor support, etc?

I actually write inside of the WSL using emacs in a terminal, but not having package support is painful. There is apparently a workaround using XWindows (why involving X matters, I don't know).

Docker

Linux containers can run on Windows Server, but Docker doesn't run on the ordinary WSL.

Background tasks

Daemon tasks must be started from an interactive shell. Boo!

Interix

Interix was a Windows NT subsystem that supported recompiled Unix applications. It started in 1995 and was eventual acquired by Microsoft. Its founder, Stephen Walli, wrote about that history when WSL was released. He wrote about the story of Interix: Part I, Part II. It goes by very quickly at the end of Part II, but the Interix subsystem shipped all the way through Windows 7, which shipped in 2009, and wasn't replace until 2012.


  1. DOS itself is not an environment subsystem, though I saw someone referring to it as one.

  2. Thanks to a HN comment I can no longer find.