GitHub has moved away from local development environment and adopted Codespaces for its day-to-day development flow. After careful configuration, GitHub achieved a 10 seconds bootstrap time for a new environment. Additionally, now Codespaces support Emacs and Vim besides Visual Studio Code.
Codespaces provides a fully-featured, cloud-hosted development environment that aims to address common shortcomings with the overall developer experience.
The vision behind Codespaces is commoditizing development environments just like it happens with the rest of an organization's infrastructure. Commoditization is great in that nothing is unique and irreplaceable and, if something stops working correctly, it can be easily and quickly replaced. This is at odds with the reality of local development environments, says GitHub, where a constant effort is required to keep them functional.
Local development environments are fragile. And even when functioning perfectly, a single-context, bespoke local development environment felt increasingly out of step with the instant-on, access-from-anywhere world in which we now operate.
Originally created at Microsoft as Visual Studio Online before GitHub's acquisition, Codespaces leverage Visual Studio Code and makes it run inside your browser to power its remote development environment experience that includes code completion, extensions, code navigation, and the rest of Visual Studio Code features you are used to.
Codespaces can be run in a matter of seconds directly within GitHub to allow developers to start contributing to a project almost immediately.
Our goal with Codespaces is to embrace a model where development environments are provisioned on-demand for the task at hand (roughly a 1:1 mapping between branches and Codespaces.)
Adopting Codespaces and adapting it to handle GitHub's massive 13GB codebase, with over a million commits over 14 years of development, has provided GitHub with the opportunity to overcome a number of challenges and further improve its functionality and speed. Through a process of careful revision of past decisions and fixing a number of macOS-centric assumptions, the GitHub team could reduce Codespaces bootstrapping time for their repo from 45 minutes to a whooping 10 seconds.
For example, when working remotely with such a big repo as GitHub's, doing a shallow clone at bootstrap and then unshallowing the repo history in the background can have a dramatic effect. Another key decision was using a GitHub actions to nightly update a Docker image of the repo including all of its dependencies and use it to bootstrap the development environment when needed. The final performance improvement to reach the 10 seconds goal was provided by prebuilds, which are pools of fully configured codespaces waiting to be connected when a developer wants to get to work.
According to GitHub, the decision to move to Codespaces not only fixed the local environment fragility issue, but also enabled additional opportunities to improve the development experience, for example, performing setup and optimization on the development environment that would be simply too complex or require too much effort to be carried through on a single developer local environment. Likewise, developer machines can be upgraded to higher specs very simply.
As mentioned, Emacs and Vim are also now supported for developers preferring to work from the command line instead of through a browser. To make this possible, the GitHub team simply updated their pre-build images to include sshd
, their public keys, and opened port 22 for external access to the codespace.
There is much more to learn about GitHub's transition to Codespaces, what it entails and the benefits it brought, than what can be covered here. So, do not miss the official article if you are interested in the full details.