Windows and Elixir—An Unexpected Joy

There are a lot of reasons this post shouldn’t exist. For example, there was a point in Microsoft’s history that they were actively trying to take out Linux. Their about-face and innovative work on the Windows Subsystem for Linux is quite an impressive feat for Microsoft. Additionally, if not for the pandemic and a specific client project need, I would not have been in a position to use a desktop PC that I built instead of the MacBook Pro laptop I use for development work.

Despite the odds, day by day I’ve grown to really appreciate this Rube Goldberg machine that is Windows + Linux. It’s versatile, uses the full extent of the computer’s horsepower, and perhaps most surprisingly it is a viable and usually pleasant environment to use for building software.

In the fall of 2020, I celebrated 6 years at Gaslight. Like many pandemic celebrations, it was muted. There were a few tacos in our appreciation channel along with some kind words from my coworkers. Every 3 years, we receive a stipend for a new laptop, so the anniversary was a chance for some new hardware too. When I looked at the options for upgrade, though, the Mac lineup didn’t really bring much to the table that I was looking for. I decided to wait for a little to see how the new Apple processors work out, which left me thinking about my home computer.

I decided to build a fancy multicore machine to run games and Linux on. The reason for Linux – I wanted to play more with Elixir in environments with plenty of processor cores and RAM, to really wrap my head around its capabilities in practical terms. Because I expected to have to dual boot between Windows and Linux for games and development respectively, I bought two SSDs. I installed Windows on the first one and got everything set up for gaming with a Ryzen 3900X 12 core processor and 32 GB of RAM. This is quite an upgrade from the 3-year-old MacBook Pro I’ve been carrying around.

I’ve done some work in WSL (version 1) in the past. On a whim, I decided to install WSL 2 on the computer to see if it was worth another look. After following the guide and getting Ubuntu 20.04 installed, I went through the normal routine of setting up asdf-vm, PostgreSQL, and my favorite languages (Elixir and Ruby at the top of the list, of course), checking out personal projects and trying out some editors to see where I landed. I’m a Spacemacs user, so I tried that first and ran into a slight hiccup in that WSL 2 isn’t quite Windows, and it isn’t quite Linux, but it’s fully both. So while I had a Terminal with bash running, I had no X server to run Emacs from there even though I was fully immersed in the Windows GUI. Enter VcXsrv. At this point, I started to wonder about the complexity of the thing I was doing. It’s definitely not as easy to get started with this route vs getting started on a Mac, but I had already gotten this far and I wanted to see it through. From my work on the Nerves core team, I am also acutely aware that supporting Windows opens the door to a much wider range of people learning to write software with the operating system that came preinstalled on their commodity laptop. So I followed the work of some others pioneering this path and got everything up and running with Spacemacs.

Next, I’d heard that VS Code has some pretty awesome support for remotely developing in WSL but the editor actually runs within Windows. This seemed like the best of both worlds, and I can say after getting it running that it’s a pretty compelling development environment. When I want to go heads down and get stuff done on a solo project, I’m still 100% Spacemacs, but when I’m pairing, I often go the VS Code route to aid in the collaboration process and use an editor that most people seem to be comfortable with already.

Once I got all of my environment set up, I ran some of the build tasks for my existing project, and I was blown away. I heard that WSL 2 had some major speed improvements, but I wasn’t quite expecting what I saw. It used all of the cores and had none of the delays I’ve grown to expect on my several-year-old laptop. The real winner was in building a few custom Nerves systems for a 3D printer project I’m working on. Usually, I just kick off a custom system build on my Mac and walk away for a coffee and bio break (longer if it’s the first build with no cache). On the WSL 2 side with faster hardware, the speed improvement was marked.

Since the start of the experiment to see how WSL 2 fares, I have started using it full time in supporting a team of developers who all work within a Windows IT environment. The nuances and the complexity of WSL 2 are still a factor, but there is a solid basis for development in Elixir within Windows and WSL 2.

I’ve been so impressed with the experience that I have yet to set up the native Linux dual boot. If you know me at all, you know how big of a deal this is. The only remaining question for me is: what to do with this second SSD?

References:

Related Posts

Want to learn about the types of products we build?

Check out our projects

Like what you're seeing? Let's keep in touch.

Subscribe to Our Newsletter