Web development on the Macbook Air M1

By mstolte No comments

With the introduction of the new Macbook Air M1 Apple has a really fast and relatively affordable laptop, at least that’s what I read whilst looking into a new laptop for private use. The reason it’s so fast is that Apple has moved from Intel to their own Arm chipset. This is also the reason some tools aren’t completely ready yet as they need to be ported to this new architecture, or you need to run them using Rosetta 2, which enables running Intel binaries on Arm by ‘translating‘ them. Apparently this is quite fast, maybe even faster then running them natively on Intel..

In this post I’ll go through what’s required to get a JS/Java development environment up and running and will let you know if it’s got everything I need and is indeed fast enough for my needs.

Visual Studio Code

installing VSCode is quite simple. They ship a universal binary (explained) so you can install it directly from here: https://code.visualstudio.com/

Terminal

I use iTerm2 and I could not really find anywhere if it has a universal binary but looking at the app with ‘file’ it seems it does:

I’m also using zsh (the default shell) and have installed a lot of the zsh extras Kevin Smets describes

Homebrew

Homebrew is available natively on ARM64 but you can also still install the x86 version. This makes it possible to use things that aren’t available in the ARM64 version like MySQL.

To install the normal Homebrew version just use the default installation instructions. This will install it in /opt/homebrew.

To also install the x86 version do this, and note that the Homebrew folks made the smart choice to have this one install in /usr/local:

Note that at line 2 we’re making sure brew runs in Rosetta and I’m using ‘ibrew’ as an alias for ‘intel based brew’. Don’t forget to add this alias to your ‘.zshrc’. Most of this is compiled from instructions from stackoverflow, as none of them are 100% correct (anymore).

Anything you install using either ibrew or brew will now just work transparently, which is really cool. I installed MySQL using the ibrew alias and it works fine and quite fast.

Docker

This is of course a bit more interesting as it uses “OS level virtualization” which for a first version of an OS on a new CPU architecture is going to be a challenge.

Luckily by now Docker is already at its third release candidate. They have switched to Qemu as the default for emulation as they believe it to be more stable then the Big Sur virtualisation framework. They write that this is also to see if it really is better or if they will switch back the final release.

To install Docker you can just follow the instructions on their page and it works just fine, the only thing you have to take into account is that you run either ARM64 based images or you, and this is sometimes needed as not everything is available for ARM64, use the linux/amd64 images. As I’m using MySQL, which is only available as linux/amd64 and would probably cause a performance hit emulating the x86 architectures, I choose to do this I now use MariaDB’s ARM64 image.

Java

For Java there is already a nice Homebrew solution available explained on StackOverflow. This will install Homebrew and the OpenJDK for you. Homebrew itself is also really useful to have on your Mac for installing things so not having a DMG installer for this is not at all a bad thing I think. Note that Homebrew is natively available for the M1 now but there are still some bottles not available so some people resort to work-arounds. I have not needed those yet but I guess it’s good to know.

NodeJS

Installing NodeJS is quite easy using NVM, as explained here by Michael Baldwin. As he notes, it will compile NodeJS which I found really cool to see as it threw me back to the compiling of things I did all the time using Linux, albeit the output was scrolling by a lot faster then 10+ years ago…

As I don’t switch versions of Node too often the compile step is not a hassle and I expect to get precompiled versions as more and more people move to this architecture.

Browsers

Having browsers to test your web sites/apps in is of course useful. Safari comes preinstalled, but Chrome, Firefox and Edge are also available.

Chrome has a native M1 version available and when you go to the download page they even help you out in figuring out which Mac you have:

the download screen for Chrome helps you select the right CPU architecture

Microsoft has the same kind of help available for Edge, and being built on the same open source core (Chromium) they have already also a version available for the M1.

Firefox also natively supports the M1 but took another route: instead of letting the user decide which version to download they went the ‘universal binary’ route. The reasoning behind that and a lot of other interesting information on the process behind creating a M1 version is described on the Mozilla blog.

Keyboard

As the keyboard has this § which I don’t need and which on my other keyboards has the ~/` I used these instructions by Jan Grzegorowski to remap it.

Conclusion

For me this machine is great. It runs all the software I need, is light, small, fast, does not have fans, has a physical escape key. The cons for some people might be that it can only connect to one physical monitor (you can still connect an iPad as a second screen) and has only 2 usb-c ports (but hubs exist..).

Oh yeah.. and it has a physical escape key. For real.

Leave a Reply