DISCLAIMER: This post is NOT meant to discuss the differences or indifferences in one environment or another. There are plenty of other places to do that.
Suppose it’s your first workday in a new team. You set up your machine, clone your project’s Git repository on your drive, etc. But there are some things you’ll notice that day:
- Guidelines for development processes within the team are written with Linux/OSX in mind;
- (Probably) no one in the team can help with issues you encounter on your machine;
- There are some wonderful .sh helper scripts for the project that you cannot use.
Of course there’s Docker which also resolves many (if not all) of your problems, but I’d like to talk about something that’s also really cool..
Microsoft has introduced WSL, or Windows Subsystem for Linux. The first release of WSL would act as a translation layer so that Linux commands (or scripts) could be used on a windows machine. With WSL 2, however, a full native Linux kernel is included. With the translation layer no longer needed, the experience would become much faster.
Set up WSL
Version 2 of WSL is available with version 2004 of Windows 10.
First you will need to enable two components. Go to the start menu and type ‘windows features’. This will show ‘Turn Windows features on or off’, go there.
From here, enable ‘Virtual Machine Platform’ and ‘Windows Subsystem for Linux’ as shown below.
You will still need to set the default version of WSL to 2. To do that, open PowerShell and run the following command:
wsl --set-default-version 2
It may return a message about updating the kernel component. Follow the link (this one) to download the installer. Run the command again after installing.
Choose your Linux distribution
You can now install your favorite linux distribution from the Windows Store. In this example I am going to install Ubuntu 20.04 LTS.
After installing the distribution, open it up and set up your username and password.
That’s it, you’re done! You can already run some .sh scripts if you navigate to a folder and hold [Shift] while rightclicking inside the folder. This will show the ‘Open Linux Shell here’ option!
Docker Desktop and WSL 2
For those who are already using Docker Desktop on Windows, you may or may not have noticed that it now also supports WSL 2!
Enabling WSL 2 in Docker Desktop will greatly improve the resource consumption as it will use the dynamic memory allocation feature. See the Docker docs for more information.
Also, if you decide to run Node.js inside docker, IDE software such as IntelliJ support WSL as well. See here.
WSL is open source
But you simply cannot replace a Mac machine with a Windows machine!
It goes without saying that one still needs a Mac for native iOS development or building on iOS devices. So remember to discuss this with your future colleagues should you ever run into this situation.