6 min read

GitHub Code Spaces: You can write code on any device

GitHub Code Spaces: You can write code on any device

As long as you have a browser and the internet, you can write code as if it was on a local and powerful machine.

For those of us who have access to multiple devices, work in multiple locations, or like to have the freedom to use whatever tech you want, then GitHub Codespaces is for you. GitHub Codespaces is a zero config development environment that you can run on any computer with a browser and an internet connection. It's the most portable development environment I've used in the past few years. In this writeup I'll discuss my thoughts on Codespaces after trying to build my own always on development environment, and share my perspectives through what it's like to use this at work.

A few years ago I wrote about programming on an iPad. Not to be confused with programming for the iPad. I wanted a very portable development environment that I could run on any device, and because the iPad had always on LTE, I could take it anywhere. If I needed to replace it, I could do so without impacting my workflow. However, it was just an OK experience. There were some hiccups along the way, and the rigidity of key bindings on iPad's OS were frustrating. It never felt natural and it wasn't something I continued for very long. Let me explain.

First, I had to use vim, so it wasn't that developer friendly. While I'm a big fan of vim (more recently: neovim) and use it every day, it's not everyone's cup of tea. Plus you're very limited to editors that work through a terminal. So it's vim, emacs, and their derivatives. This enforced limitations and raised barriers with the audience of the original post–I wanted to share how anyone could do this.

You had to want to use vim in order for the environment to be successful. Secondly, the remote server where you'd actually be developing required a bit of configuration. It's not a bad setup by any means, but it was an extra step and required extra maintenance.  The barrier to entry was high. If you haven't configured a server and all the accoutrements that go with it, it can be frustrating.

You have to setup the server, a development environment on it, and make sure you have the right tools installed. Don't forget about updates, patches, backups, and security so it's a safe working environment.  After all, it's on the public internet. With all of these steps – especially if it's your first time, it's easy to miss something. Imagine if you didn't have to do any of that. Imagine if you could get all the benefits of an instant on development environment with all of the above. An environment that you simply didn't have to worry about.

Codespaces is just that. It's similar to my home grown setup that I and many others configured, but it removes all of the configuration steps. Plus, it's got one of the top code editors baked right in with any extension and customization you want. Not only that, but you don't need to setup any servers, ssh, vim, or credentials. You don't need to figure out how to remap keys (like the escape key) using special software on the iPad. You just need a browser can get started instantly.

Press . to open a GitHub repo in a CodeSpace

When I originally started writing this, Codespaces was in beta. As a part of the Codespaces beta you get two different spaces allowing you to run two projects simultaneously. If you want to change projects and already have two spaces used, you sacrifice one to replace. The Codespaces come with VSCode in the browser, or you can connect it to VSCode locally on Mac/Win/Linux. Your environment variables are secure and available on any device you connect from. Your editor preferences sync along with your plugins and styles. It looks the same every time and every where you open it.

Picking up from where you left off on any device is a huge win for Codespaces. Start coding on your laptop or desktop then switch to another computer or even an iPad and resume whatever you were doing. It's very simple. Just boot up the browser and continue coding. Plus, because your code runs on the server your device doesn't get hot and it's battery stays strong. That's a huge win for your lap and for less powerful machines.

It's not all perfect, though. Sometimes the browser intercepts the keys, such as escape, causing some issues. Browser Extensions can also cause unwanted behavior when trying to edit your code. It's currently free in while in beta, and I'm not sure what it'll cost for the average developer when it's out. It may or may not be worth it, though I'd pay for it as long as it's reasonably priced.

For organizations and enterprises, it's less than $5/day for the 2 CPU plan. Though, that's if you run it 24 hours/day, which you won't because when it's suspended you're not getting charged. I imagine you'll spend less, or around the same if you want a beefier setup. At eight cores, it's about $5.72 for an eight hour day.  It's main requirement is an internet connection. If you don't have one, you're out of luck.

Codespaces makes a ton of sense for those on the go or those who want to switch devices without setting up an entire dev environment. It also seems like an amazing candidate for companies on-boarding new employees. Usually you spend some time setting up your dev environment during your first week, but if you could stamp one out easily from Codespaces, it makes life so much easier.

Schools, enterprises, digital nomads, and remote workers, are some of the first use cases that make the most sense to me. You can be anywhere, with an instant development environment, for little expense. It doesn't matter how powerful your computer is, the one that's running your code is powerful. All you need is a browser, a keyboard, and an internet connection. It's like time sharing, but with a better user experience.  


Codespaces vs the local development Environment

Docker recently announced that they'll be charging companies that make more than $10M revenue and/or have 250+ employees to use the Docker Desktop. Mostly everyone I know, who uses Docker on the mac, uses Docker for Mac, which means they'll be charged. It's not a significant expense, but considering how painfully slow Docker for Mac is when compared to running on Linux/Windows, it seems almost like a no brainer that if you must use docker, the best experience is on Linux. It's exactly what Codespaces is running and you have full access to the CLI. It's fast.

Laptops and development machines can get quite hot, especially when transpiling 40k node packages. The nice thing about Codespaces is that it's not doing that on your machine, but remotely on a server. So your legs won't burn and your battery life will last much longer.

The environment is accessible anywhere as long as you have internet. If you forget your computer, or are out and about, you're not totally hosed. You can still find a machine with internet, log in, and you're off to the races. This is such an amazing safety net for people that work on products that matter.

Cost is another factor. If you're not developing 24/7, the codespace will suspend itself and you won't be charged. Plus, you don't have to worry about the hardware. If something breaks, you'll be ok.

Onboarding for new engineers is so fast it might just change the way we think about onboarding. You don't need to setup a development environment, install stuff, and deal with whatever else like keys and downloads. You can get started within a minute as long as you use VSCode. Currently the only editor that's supported out of the box is VSCode. It'd be really nice to see support for some of the more common enterprise IDEs like IntelliJ IDEA, though I wouldn't hold your breath.

Git and the power of GitHub is baked right in. No need to mess with keys. As long as you're logged into GitHub, you're good to go.


Should you use Codespaces or build your own solution? VSCode allows you to easily connect to remote instances over ssh to develop on, so you don't need to use Codespaces, but you do get some benefits. Environment variables can be set and encrypted in the GitHub UI, settings sync works pretty well across all devices, and you get the web version for when you're on any other device without the desktop VSCode installed.

It's really cool, and I'm glad they're doing it. It seems like GitHub wants to do a lot for developers now that they have the backing of being a Microsoft subsidiary. I like where they're headed and I really like that if I'm on my gaming computer, I can still crack open some code without worrying about dual booting, switching computers, or setting up a dev environment. All I need is an internet connection and a keyboard.

P.S. If you want to try it, press . on any GitHub repo.