Bump Allocation: Up or Down? Mar 25, 2024 Back in 2019, Nick Fitzgerald published always bump downwards, an article making the case that for bump allocators, bumping “down” (towards lower addresses) is better than bumping up. The biggest reasons for this are bumping up requires 3 branches vs 2 for bumping down and rounding down requires fewer instructions than rounding up. This became the method used for the popular bumpalo crate. In this post, I want to go back and revisit that analysis. ...
Cycles all way down Feb 23, 2024 A while ago while working on Rust-based Emacs, I was loading a new elisp file and hit a stack overflow. Digging deeper I found the issue in trying to print a cyclic list (where the tail of the list points back to previous element). I knew this was a possibility, and that at some point I would have to handle cycles. So I quickly implemented a version of Floyd’s cycle detection algorithm (visualized here). ...
Text showdown: Gap Buffers vs Ropes Aug 09, 2023 I have been working on a hobby project to reimagine the C core of Emacs in Rust. On this journey, I reached the point where I needed some way to represent the text of a buffer. The simplest approach is to just use a large string or array of lines. However these each suffer from poor performance as either the size or line length of text increases. GNU Emacs has famously used a gap buffer to represent editable text. ...
Design of Emacs in Rust Jan 17, 2023 This is the third post in my series about writing an Emacs core in Rust. The first post laid out my initial observations and ideas about the language runtime. The second post focused on building a safe garbage collector in Rust using the type system. I initially stated that I wanted to reach the point where I could bootstrap bytecomp.el (the elisp byte compiler). That goal is reached1, so I am providing an update on my latest learnings. ...
A vision of a multi-threaded Emacs May 19, 2022 The Threading library Starting in Emacs 26 some very ambitious changes were added. Basic thread support was enabled, laying the groundwork for a future concurrent emacs. The docs layout this possibility: Emacs Lisp provides a limited form of concurrency, called threads. All the threads in a given instance of Emacs share the same memory. Concurrency in Emacs Lisp is “mostly cooperative”, meaning that Emacs will only switch execution between threads at well-defined times. ...
Implementing a safe garbage collector in Rust Apr 11, 2022 In my last post I introduced an Emacs Lisp VM I was writing in Rust. My stated goal at the time was to complete a garbage collector. I think Rust has some really interesting properties that will make building garbage collectors easier and safer. Many of the techniques used in my GC are not original and have been developed by other Rustaceans in previous projects. Updated: 2022-09-06 Why use garbage collection? ...
Building an Emacs lisp VM in Rust Oct 21, 2021 Updated: 2023-01-06 About a year ago I was bitten by the PL bug. It started with reading Crafting Interpreters and discovering the wonders hidden under the hood of a compiler. I am also been a big fan of Emacs, and this started to get me interested in how its interpreter works. At the same time, I was reading the Rust book and trying to understand the concepts there. This all came to a head, and I decided to write an Emacs Lisp interpreter called rune in Rust. ...
Taking org-roam everywhere with logseq May 26, 2021 Updated: 2022-08-03 I love org-roam. It lets me take notes in a way that matches how I think. It makes it easy to recall what I have learned and find connections between ideas. But there has always been one big problem with org-roam: it ties me to the desktop. When I am on the go and all I have is my phone, I don’t have access to my notes. There are some stop gap solutions to try and fix this. ...
When pure function lie Apr 07, 2021 Here is a simple question. Given the lisp function below (and that the function is not advised) what will the output be of (foo)? (defun foo () "foo") Seems pretty simple right? How could the answer be anything other then "foo"? It is just returning a constant string. Or is it? The real answer to this question is… We have no idea. It can could be any string of length 3. ...
Native shell completion in Emacs Jan 04, 2020 I am obsessed with autocompletion in shell mode. Running a shell in shell-mode instead of a terminal emulator has so many advantages. You can treat the whole buffer just like a normal Emacs buffer. You can copy and paste and edit the line normally. You can hook it into native Emacs functionality. You can even display images! However there is one big disadvantage. You lose access to the state the shell. ...