Context about Emacs and me
I used a few text editors (with vim key bindings) lightly for a number of years and I started wanting more.In 2016, I first stumbled upon Spacemacs and got hooked for a while. That was my first Emacs experience. Spacemacs was so user friendly that I didn't have to learn Emacs at all.
In 2017, I moved on to VSCode (with VSpaceCode) as it got popular. In 2019, I moved to [Neo]vim (with SpaceVim) mainly because of the better performance and it was a natural transition as I also started using Tmux and I started to refuse leaving terminals.
In 2021, I moved from SpaceVim to my own configuration as I continuously being drawn to optimizing performance of my tools and Neovim's potentials just exploded recently (after v0.5), so I took advantage of it. I'm very happy and quite productive with current setups thanks to Neovim and great plugins!
Very recently (April 2022) though, somehow I became curious about Emacs again and I realized I know nothing about it really (I'm still fresh off the boat!). So I opened Spacemacs again and I wasn't really satisfied with the performance and I discovered Doom Emacs - reading docs in Doom Emacs is a joy, I appreciate the transparency and the style - and I could see it fits more of my style than Spacemacs as I became more "advanced" and picky now. After this point, my curious brain had to play with Emacs even though I'm not in a situation that I need a better text editor just yet. I'm just in a mode of needing to know about what Emacs really is and how it survived for so long and how customizable/extensible really is.
So I'm learning and playing with it and customizing it to my liking slowly. I quickly realized I need to write things down as I learn, hence this gist.
By the way I still keep all the configurations of the editors that are mentioned above at my dotfiles (why not!) if you are curious to take a look.
- Doom Emacs Configuration
- it also includes interesting links
- my emacs configurations
- First Steps with Nix - Building emacs
https://www.emacswiki.org/emacs/GccEmacs enables native compliation and Emacs 28.1 brought this to upstream.
Are you not a fan of better performance?
Wait, it actually comes with a cost trade-off, too (at least the way I use Emacs now with doom sync
) as compile time could be quite long depends on your system spec and the complexity of the pacakges, when you add new ones, as well as resource consumptions.
There is a talk from the developer and the key image to me is below.
The slide is captured from https://european-lisp-symposium.org/static/2020/corallo-nassi-manca-slides.pdf
((emacsPackagesFor (emacs.override { nativeComp = true; }))
.emacsWithPackages (epkgs: [ epkgs.vterm ]))
Byte compiling for Emacs is explained at https://www.gnu.org/software/emacs/manual/html_node/eintr/Byte-Compiling.html. More generic information is found at https://en.wikipedia.org/wiki/Bytecode.
Native code refers to the compiled code that is only targeting for a specific architecture (i. e. x86_64
, aarch64
), once it's compiled, it only runs for that arch so you need to compile for each arch if your computers run on different CPU architectures. This additional step enables running your code close to the metal which enables the highest potential on performances.
Can you speak your second language faster than your native tongue? Probably not, same goes for how our programs talk with computer hardwares.
In Emacs' case, the result of this file's extention is eln
(el
is for human readable Elisp file and native compliation compiles el
to eln
)
While native compilation of Elisp on Emacs is relatively new, byte compiling seems to be a thing that's been around for a while. when you byte compile, the result is elc
(from your el
). This is not (supposed to be) human readable and has performance adavantage as the purpose of it is to optimize how it runs compare to raw el
. However it is still being intepreted at runtime so not as fast as native compilation. But elc
is more portable as its compiled code shouldn't be different for different CPU architectures.
As I learned, I needed to make a note here and all these note might make me sounds like I know about what I'm talking about but that might not be the case as I literally just learned these things around the time of writing. So even if this might be helpful for you to orient with these concepts, don't blindly trust what I say as I consider myself a layman on both this subject and Emacs.
refer to tips.org