Zed: lightning-fast, collaborative code editor written in Rust (Atom team)

2021-12-1515:0915182zed.dev

A lightning-fast, collaborative code editor written in Rust.

We think there's a better way to write code, and it starts with the following assumptions:

When you move the cursor or type a character, you should see pixels on the next refresh of your display—every time. Even sub-perceptual pauses add up over the course of a day to create unnecessary stress.

Joyful coding starts with an editor that stays out of your way.

Pull requests have their place, but sometimes you just want to code together. It's more fun than code review, builds trust between colleagues, and it's one of the best ways to distribute knowledge through a team. But it has to be easy.

If you want someone's perspective on a piece of code, it should be as easy as sending a message to pull them into your working copy and start coding.

If you want to talk about code on GitHub you have to commit and push it first, and pasting code into a chat application sucks.

By treating keystrokes as the fundamental unit of change and integrating chat into the editor, we can make it easy to have a conversation about any line of code in any working copy–whether it was committed last year or just typed ten seconds ago.

If you're living in a tool for hours every day, you want it to disappear. Every pixel must carry its weight, and the software you're creating should always be the focus. So we constantly ask ourselves how we can maximize signal and minimize noise.

Do we need an icon? Do we need a gradient? We all want to achieve mastery. Our goal is to find the most efficient way to accomplish each coding task and make it accessible. We will never dumb things down.

———

We're looking to add another engineer to the team. Want to help us build the future? Join us.

———

Rust offers expressivity and developer productivity rivaling languages that depend on a VM, while simultaneously offering the control required to fully utilize the underlying hardware.

Rust's unique ownership model is a challenge at the beginning, but once you internalize it, you can write extremely efficient multi-core code without fear of invoking undefined behavior.

It also makes it straightforward to call directly into the C-based APIs of the operating system. Rust makes it possible for a small team to build a complex product quickly, and Zed wouldn't have been possible without it.

In the past, to write software with this performant you would need to use C++. Rust, for the first time, enables us to write software at that level as a very small team.

We originally planned to use Electron as a convenient means of delivering a cross-platform GUI for Zed, while building the core of the application in Rust. But at every turn, we found that web technology was the bottleneck in achieving amazing performance. Finally, we decided to take full control and simply build a GPU-powered UI framework that met our needs.

We call it GPUI.

We took a lot of inspiration from Mozilla's Webrender project. The key insight was that modern graphics hardware can render complex 3D graphics at high frame rates, so why not use it to render relatively simple 2D user interfaces with an immediate mode architecture?

Rust's ownership model required us to rethink much of what we learned in other UI programming paradigms, but the result is a framework that's productive to use and remarkably easy to reason about.

It's liberating to control every pixel, and it's a rush to push those pixels at lightning speed.

Real-time collaborative editing presents the illusion that multiple people are editing the same buffer. In reality, each collaborator maintains their own personal replica of the buffer to which they can apply local edits immediately without network latency.

After being applied locally, edits are transmitted to collaborators over the network, whose copies may have also changed in the meantime. This means that as participants edit together, their replicas continuously diverge and reconverge. Turns out this is a tricky problem.

To solve it, we're using conflict-free replicated data types, which have emerged in the last decade as a general framework for achieving eventual consistency in a variety of circumstances.

Making Zed's buffers CRDTs allows for collaborative editing, but it also helps us reason about concurrent change so that we can push work into background threads and keep the UI thread responsive.

We plan to integrate with the Language Server Protocol to support advanced IDE features, but we also think it's important for a code editor to have a rich, native understanding of syntax.

That's why we built Tree-sitter, a fast, general, incremental parsing library that can provide Zed with syntax trees for over 50 languages. Tree-sitter already powers production functionality on GitHub, and we'll use it to deliver syntactically-precise syntax highlighting, tree-based selection and cursor navigation, robust auto-indent support, symbolic navigation, and more.

———

Excited about what we are building? Sign up for updates to follow along in our development process.


Read the original article

Comments

  • By kubb 2021-12-1515:512 reply

    I agree that everything written there makes sense but I can't get hyped for trailers anymore. No release date, no screenshots, let me know when it's ready :)

  • By soggybutter 2021-12-1516:164 reply

    > The key insight was that modern graphics hardware can render complex 3D graphics at high frame rates, so why not use it to render relatively simple 2D user interfaces with an immediate mode architecture?

    While I appreciate this approach and think it's a great idea over using something like Electron, this almost comes off as some kind of obvious discovery they've made. Nothing about this is new or even interesting, as this has basically been the status quo in games for ages now.

    Edit: I realized this comes off as attacking the project itself. The project _is_ interesting because it seems like most "advancements" in text editing recently have been locked up in web technologies. I only mean their approach to rendering is not that interesting or exciting, which honestly might be a good thing

    • By bsder 2021-12-160:41

      > this almost comes off as some kind of obvious discovery they've made

      Except that it's not?

      We are currently in a weird path-dependent state for GUIs. Because GUI toolkits are such a pile of detailed work, it takes a lot of effort to create good general ones. The ones we currently have were all designed prior to ubiquitous 3D performance, have a strong dependency on object orientedness, and were often designed around constrained CPU and memory.

      None of this holds today. However, we still use the same toolkits.

      The immediate-mode GUI stuff is interesting, but throws away all OS integration which means accessibility is right out the window. Responsive GUIs (see: every DAW (digital audio workstation)) all throw away GUI toolkits and implement their own.

      Not to mention that 2D rendering with 3D hardware is NOT a solved problem. The NV_path_rendering extension is not available in Vulkan or DirectX, as far as I know. Text shaping is decidedly video card unfriendly. The number of "vector" renderers can be counted on one hand--and you don't need any hands at all to count the 3D native ones.

      I welcome all the experimentation in this space. I just really hope we get some convergence to something interesting soon.

    • By masklinn 2021-12-1518:091 reply

      > While I appreciate this approach and think it's a great idea over using something like Electron, this almost comes off as some kind of obvious discovery they've made. Nothing about this is new or even interesting, as this has basically been the status quo in games for ages now.

      That it's been the status quo in games is not really relevant.

      What is probably more so is this is not the first project to go in that direction (e.g. alacritty is a GPU-accelerated terminal), and while the isolation from the platform and handling of everything tends to be a bonus point for a game which is rather isolated from the system it can be more problematic for other programs, especially heavily text-based ones (like... an editor).

      • By dralley 2021-12-161:031 reply

        >the first project to go in that direction

        Unless you count web apps running in Firefox! WebRender is built around exactly this concept.

        • By masklinn 2021-12-166:13

          Did you misread my comment?

    • By eyelidlessness 2021-12-1517:082 reply

      I agree it seems like a strangely ho hum realization. And I’m definitely not attacking the project, I just signed up for the waitlist.

      Just wanted to add that it’s an especially odd framing, given that this appears to be Atom’s successor, and VSCode—the editor which many Atom users adopted—is both Electron and heavily reliant on GPU rendering.

      • By eggy 2021-12-1517:17

        Yes, I use Raylib for toy games, and for toy apps. Raygui, the Raylib gui library, is an immediate-mode-gui. It doesn't seem to hog any resources for the frame updates, but I lower it for apps where I don't need very high refresh rates on state changes such as moving stuff around or changing an input in a dialog or text box. I've been playing with immediate-mode-guis for years (nuklear, imgui, etc.), so I wasn't sure what was novel about this. There are tricks to store scenegraphs and only update what changes, which pushes you away from true immediate mode anyway. I am more curious about how you render fonts at scale. Do they implement sub-pixel rendering or SDFs to achieve variable resolution clarity?

      • By mistersys 2021-12-1517:46

        I think the point here is that we've worked ourselves into a corner with web technologies. The web is very reliant on GPU rendering, but when building an app with DOM + CSS, you don't have direct access to all that power. You have to be very careful to construct your application in such a way that it can be efficiently rendered, and actually use that GPU power.

        Basically, they're getting rid of the middleman: the web. Think about most modern web frameworks (React, Angular, etc.), they're basically immediate mode GUI frameworks, but we do "virtual diffing" in order to translate our immediate-mode-like code into DOM (a retained mode UI framework), then the web renderers the DOM via immediate-mode-like patterns again. Pretty strange if you think about it.

        Our stacks of technology are getting in the way of creating good software. So yeah, it's on old idea, but in light of the state of the art in IDEs and Text Editors today, this is an interesting approach.

        Note, this is a problem in the first place because of how good the web is. The web has so much tooling, cross-platform support, and documentation / learning resources that it's being overused in places where it's very inefficient, simply due to momentum and mindshare. When you have a hammer...

        Now, one of the biggest reasons for the success of the web is cross-platform support, but it's not just cross-platform support. It's the only write once run anywhere platform, truly. Most other cross-platform frameworks require you to think about the native environment at some point, but it's very rare on the web because of the robust standard library including Media access, Networking and even more rarely used APIs like WebMIDI. Not to mention that web design culture allows you to ignore the ui patterns of the native OS you're targeting, allowing more cross-platform savings.

        If we can somehow manage to throw away the DOM + CSS (except, perhaps, for decoration) and replace them with immediate mode frameworks, combine that with WebAPIs for interfacing with hardware, and decouple those from JS (maybe via WebAssembly), then we have a competitor to the web for complex cross-platform software that is actually interesting. Perhaps Zed and their Rust-based GUI framework could help push us in that direction.

        Edit:

        Another aside, the performance of immediate mode GUI. You could argue that retained mode UI can be made to have better performance than immediate mode, but I think the right combination of caching and framework-level optimizations to allow for partial updates are the solution.

        You might say "that's not immediate mode though?", and sure, but what we care about here is fast applications that are easy to build. We've discovered that writing code via declarative patterns has huge benefits over "object-soup", so our goal should be to make those patterns as fast as possible. I think the DOM and retained-mode GUI is a just a result of the Java style of Object Oriented obsession.

  • By hiptobecubic 2021-12-1516:511 reply

    A text editor.

    A website dedicated to introducing a text editor that hasn't even been written yet.

    .... with a "waitlist."

    This is peak HN.

    • By whalesalad 2021-12-1516:53

      We are all just children playing house. Let them have their fun.

HackerNews