Developing in WSL2
So far, our WSL2 experience has been mostly text-based—fitting for a book on Windows Terminal! While this has served us nicely so far, in this section we'll explore using Visual Studio Code as our code editor and debugger, alongside Windows Terminal.
This presents an interesting challenge. Microsoft's guidance is to prefer editing files on the Linux filesystem with Linux applications, as this has the fastest filesystem performance. We would be at a disadvantage if we tried to use Visual Studio Code from Windows 10. It might work, but it'd be a slower and more frustrating experience.
We can fix this by using Microsoft's Remote - WSL extension for Visual Studio Code. This extension automatically installs a server into our WSL2 environment, which interacts with our Linux filesystem. Visual Studio Code on Windows 10 then uses a local port to communicate with this server. This process is shown in the following diagram: