Skip to content

Comment on Show HN: Iota – a text editor written in Rustparent

Comments

gchpOP

Thanks for checking it out!

Text editors to me (a web programmer) look too intimidating to build from scratch.

Honestly, this was my thinking too before I started working on one! I, like you, work primarily on web applications and I had never really worked on "lower level" projects. I have always wanted to build a text-editor, though I thought it was much too big a task and didn't know where to even start.

Because of my background in web programming, I was most comfortable with Python and JavaScript. There were a couple of popular editors out there built with JS, (mainly brackets [0]) so I decided to try read through their source code. This helped a lot. Reading source code that I understood, or atleast could make a guess at understanding. I did some research into how brackets was built and found this sort-of useful architecture video [1].

Then, I heard about the Go language, and by accident came across a project called Vigo[0] which is a Vi clone written in Go. The codebase was pretty small, and I was able to easily implement a command for the editor and contribute it. From there I just spent as much time as I could in reading source code of different editors, and comparing them to eachother. Asking myself questions like "How does Vim handle buffers compared to Emacs?" - I have no idea, so I'd go look it up. It could take weeks to get an answer, and sometimes I couldn't figure it out. But I defintely learned Something in doing the research!

I also did some reading from the authors of popular editors like Stallman (Emacs)[3] and Pike (Acme)[4]

When I started building one of my own, I still didn't really (And still dont!) know what I was doing. If you look at the early commits of the project you'll see me totally rewriting pieces over and over until as I figured out better ways of doing it.

I wish I could point you to a single resource that helped me, but it was really a bunch of things that I did over time that helped me. I still don't know much about editors, and I'm sure there's people who can do a much better job than me, but I'm having fun doing it! And I think thats the most important part. Have fun in researching editors (or whatever you decide to build). If you're interested in it, it makes even the most boring and difficult ideas fun to work with. Feel free to reach out to me too if you need help, I'm happy to share what I've learned so far!

sidenote: I didn't know Rust before I started writing Iota, which made things even more interesting ;)

[0]: https://github.com/adobe/brackets [1]: https://www.youtube.com/watch?v=xm9kSWZyawg [2]: https://github.com/kisielk/vigo [3]: https://www.gnu.org/software/emacs/emacs-paper.html [4]: http://plan9.bell-labs.com/sys/doc/acme/acme.html

The definitive book on implementing an EMACS, as of a long time ago, is Craig A. Finseth's The Craft of Text Editing -or- Emacs for the Modern World http://www.finseth.com/craft/

Although I can't say I used it for my work on various versions of EMACS in the '80s, I just dived into code. But everything I read in it (or its first version, I think his bachelors thesis polished into a technical memo or the like) sounded right.

As for what to do now ... well, buffer implementation tradeoffs are different, maybe ones other than buffer gap should get another look.

This is also worth looking at http://www.finseth.com/emacs.html and has a literature section.

ADDED: ah, I see tatterdemalion mentioned it elsewhere in this thread.

This is an absolutely awesome answer, and in the best tradition of old school hackers. This is why open source rules.

If you have some time - would you mind writing a high level overview of architecture/design choices that go into writing an editor?

gchpOP

Sure, I could give it a go!

I've been thinking about writing a few articles on my experiences so far in writing the editor. Sorta covering what I wrote above. I could definitely work in some stuff on architecture and design choices. When I get around to it, I'll post it on my blog, and most likely submit it here too. Hopefully you'll find something useful in it!

Thats a lot for the excellent answer, Greg! Really appreciate it :)

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.