Whether you are just learning the quickly evolving C++ programming language, an open-source developer patching a zero-day vulnerability in a low-level C++ library, or an experienced professional writing software in C or C++ for embedded devices or enterprise applications, GitHub Codespaces and Visual Studio Code combine to significantly lower the costs associated with configuring your environment, building, and testing your code. It doesn’t matter whether your computer’s operating system is Microsoft Windows, Apple macOS, or your favorite Linux distribution, Visual Studio Code works on them all. You can even work from the web browser of your mobile iOS or Android device.
Visual Studio Code and github.dev
GitHub offers built-in support for Visual Studio Code developers via github.dev. For any repository hosted on GitHub, you can nearly instantly open an instance of Visual Studio Code directly in your web browser. In this environment, many of Visual Studio Code’s navigation and editing features are fully functional. You can search for strings in your repository or edit files and commit them to new branches. You can even install many of the great Visual Studio Code extensions from the Visual Studio Code Marketplace.
Visual Studio Code and GitHub Codespaces
Once you push changes to your repository using github.dev, any GitHub Actions that are registered for your branch will execute, including any build or test actions such as the Microsoft C++ Code Analysis action. But you might want to build and test your changes before pushing your changes up to GitHub. For this, you can create or connect to an existing GitHub Codespace directly from Visual Studio Code (including the in-browser instance loaded by github.dev) or from the normal GitHub web page for the repository. NOTE: GitHub Codespaces is currently only available to members of eligible organizations. See Known Limitations for more information.
Visual Studio Code is a First-Class Editor for C and C++
The extensibility model for Visual Studio Code is one of its most powerful features. It enables developers across the globe to produce terrific extensions. Microsoft has bundled many of the best extensions for C and C++ development into the C/C++ Extension Pack, which makes developing for one of the world’s most versatile programming languages as easy as it’s ever been. From extensions for build systems like Make and build system generators like CMake, to debugging and C++ static analysis tools and rich editor features like syntax highlighting and IntelliSense code completion, Visual Studio Code has what you need to get the job done, and it continues to improve with every release. Combining Visual Studio Code’s terrific support for C++ development with GitHub Codespaces’ ease-of-use and portability, means that it’s easier than ever before to deliver your product or solution.
True Portability with Codespaces
Since Codespaces are development environments in the cloud, they are accessible from practically any system or device with a web browser and an Internet connection. And when you disconnect from your Codespace, its state is saved so that when you reconnect, potentially from a different device in potentially a very different location, you’ll be right back where you left off. When you are relaxing on the white sands of a beach resort, you no longer need to run back to your office (or home office) in order to fix that critical zero-day bug that just read about on Reddit.
Managing Your Codespace Instances
Managing your Codespace instances can be done directly from GitHub or from within the Visual Studio Code Remote Explorer. From there, you can see the properties of your Codespaces or create, delete, or connect to your Codespaces. You can even change the machine type of an existing Codespace from the GitHub page or via the Command Palate in Visual Studio Code after connecting to a Codespace.
A machine type is a system configuration specifying the number of CPU cores, memory capacity, and storage capacity for a Codespace. GitHub Codespaces are provisioned in the cloud with the machine type you select. Depending on the organizations you are a member of, the repository a Codespace is being created for, and details about your GitHub account, different machine types might be available to you. To start, don’t worry about selecting the perfect machine type for your Codespace. You can always change your machine type later and retain all of your code changes without having to stash or commit them into the repository. Since less powerful machine types are billed at a lower rate, you can leverage this to really optimize the tradeoff between time and cost as you see fit. For instance, you might choose a powerful machine type in order to complete an initial build of your project, then switch to a less powerful machine type while you are only making changes that cause smaller, incremental builds, only to switch back to a more powerful machine when you’d like to run a compute intensive task like running a static analysis tool.
The creation of your Codespaces are also customizable with devcontainer configuration files checked directly into your repository. You can provide a custom Dockerfile to use when spinning up your Codespace, pre-install Visual Studio Code extensions, forward ports from your Codespace instance to your local machine, or even run a tool every time a connection is made to the Codespace. You can even pre-build your Codespace containers using GitHub Actions to make Codespace startup very fast!
Known Limitations
- Access to GitHub Codespaces feature is limited to users who are members of organizations on a GitHub Teams or GitHub Enterprise Cloud plan. Organization owners can enable the feature in only a few steps. Access for individual users is currently in beta, to which you can easily request access.
- All GitHub Codespace instances run various Linux distributions.
- The largest available machine type is: 32 cores, 64 GB RAM, 128 GB storage.
- Changing machine type is only allowed between types that have the same amount of storage capacity.
Call to Action
Try out the combination of Visual Studio Code and GitHub today, by going to your favorite C or C++ project on GitHub, and press the . (period) key to open up github.dev. Browse around. Experiment with the editor features of Visual Studio Code. When you’re ready to try compiling some code get started with GitHub Codespaces by accessing the Command Palate by pressing Ctrl+Shift+P (Cmd+Shift+P on macOS) and run the Codespaces: Create New Codespace command. Install the C/C++ Extension Pack and find out just how easy C++ development can be with Visual Studio Code and GitHub Codespaces. You can also follow the instructions in our example repository that demonstrates Visual Studio Code’s remote container capabilities for a quick tour of the features.
Send us your feedback
We are always interested in your feedback. If you have a use case that we haven’t thought of, we’d love to hear from you. Want to complain that something isn’t working as you expected? We want to hear that too! Already using the product and want to tell us your successes? We definitely want to hear your story! You can comment below, and you can reach us via email at visualcpp@microsoft.com or on Twitter @VisualC. For issues with the GitHub Codespaces service, you can also provide feedback directly to the GitHub Codespaces team.
While it looks interesting, it doesn’t fit any use case for Windows developers that reach out to C++, which is quite strange.
Hi Paulo,
Thanks for your feedback. So that I understand correctly, are you referencing the fact that currently, a developer can only create Codespaces that have a Linux distribution as the operating system for the Codespace VM?
If I understand correctly, then we'd appreciate further feedback on your needs. Feel free to email us at visualcpp@microsoft.com or to add comment on https://github.com/microsoft/vscode-remote-release/issues/445 and https://github.com/github/feedback/discussions/9977.
Otherwise, feel free to email us with clarifications, and we can work with you...
Hi, I am referring the fact that while this offer is interesting, it doesn't cater to the needs of Windows developers, using .NET alongside C++, MFC, ATL, UWP/WinUI in C++/WinRT, C++/CX, and Visual Studio proper.
Those tickets seem to be bound to using Visual Studio Code for headless applications, so not worthy to leave feedback, having support for Windows containers won't make the rest of the stack available.
I guess I don't belong to the target demographic.
Hi Paulo,
We see Visual Studio as our premier development experience for developers targeting applications for Windows and the Azure cloud. We are interested in the needs of users who desire isolated, repeatable build environments on Windows and are currently looking at options to deliver the type of experience that they would expect. If you would like to tell us more about your specific use-cases, please email visualcpp@microsoft.com.
Thanks for your input!