Over the past few days, I’ve switched from VSCode to using Zed for a few reasons. Zed is a code editor written in Rust, very lightweight, and its interface is similar to VSCode in many aspects. However, Zed still has its own differences and follows its own philosophy. Personally, I’ve used Zed since its early days; my first impression was that it was very fast and smooth. That said, many features I was used to in VSCode were missing in Zed, so I only stopped at the level of experimentation.
One feature I use very frequently is debugging with breakpoints: selecting positions and observing the data flow in the system. VSCode is a popular editor, so enabling debugging is much easier. It usually takes only a few steps, and especially if you use a framework, you can easily find guides online. In general, VSCode does a very good job of simplifying things for users.
Therefore, after switching to Zed, I also needed to set up debugging. At this point, the question arose: is setting up debugging in Zed the same as in VSCode? Of course not, since they are not made by the same people. So why are they different? Have you ever wondered why some editors support debugging while others do not? And in cases where there is no editor at all, is there still a way for us to debug? It turns out all of these questions can be answered if we understand the core of debugging techniques.
First, let’s talk about the programming language side. Most languages implement an integrated debugger in their core, which can be activated in some way, such as adding a --debug flag, or for Node.js, --inspect. After enabling it, you may need to add a few lines of code to signal stopping points (similar to setting breakpoints), then use commands to listen to data at those points. For some languages, people have also created tools to make debugging easier through graphical interfaces, such as node-inspector or devtools-frontend, which is built into the Chrome browser engine. But if each language creates its own tool, would code editors then have to create separate debugging interfaces for each one?
Fortunately, the answer is no, because people came up with something called the Debug Adapter Protocol (DAP) — a standard protocol for communication between the editor and the debugger server. When both sides implement this protocol, interaction between them becomes much simpler. The editor does not need to create a debugging interface for each language, and the language only needs to provide a debugger server that conforms to the standard; put them together and they just work.
In short, Zed has implemented DAP, and of course Node.js also has a debugger server that follows DAP, so debugging can be done easily. DAP is just a protocol — a way for the editor and the debugger server to talk to each other. As for the interface and configuration, those are decided by the editor. However, from observation, there are still certain similarities among them. In the next article, I’ll continue with this part.