Why I Use Emacs

18 August 2024 | programming philosophy

I will start with some things I have been learning from sketchy lisp.

Compose

First, the procedure that made me drop out of campus:

(define (compose f g)
  (lambda x (f (apply g x))))

I had the idea for this procedure in my first year of campus as I was studying calculus. I could not for the life of me understand why I was doing calculus with pen and paper. To this day, I still do not understand why anybody would torture themselves so.

Don't get me wrong. There is a difference between rigor and shortcuts. But I'm getting ahead of myself.

The point is this. If you have a computer then why bother doing things mechanically? It would take me only a month to run through a whole 200 page A4 exercise book. This gets expensive. Assuming 8 separate units, a single semester meant 24 such exercise books. Purely for my own use. Another 8 for notes in classes.

These notes have to be then condensed again because I have to cross-reference all these notes and rough work. So at least another 8. That's what it would mean for me to do it properly. 40 200 page exercise books every three months.

What would happen in practice? I would buy 16 of these books and ignore doing it properly. I couldn't afford the books and it was a waste of time anyway because I couldn't cross-reference properly without investing in the books.

These are just exercise books. Then comes the text books. We had an outdated library. All the techniques we were being taught were beyond dated. Thinking about it just pisses me off.

The only books that were not outdated were the mathematics because and that is cause mathematics does not go out of date.

So, there I was struggling to understand why we were still using these books when we can't even afford to do it. A laptop was part of the course requirements. But they were never used. It was just something they added because we had an autocad unit which was done on the campus' computers anyway. So again, useless.

But I was still obsessed about this one laptop I had. Maybe it's because that's all I had. Maybe it's because I knew there was more potential in that laptop than in that entire library or campus staff for that matter.

As I was working through exercises for my calculus course and nothing was making sense, I snapped and just pirated some calculus text books. All the reference we were given was some 20 odd pages.

I got my hands on Thomas Calculus and was having a good time until I got to composing functions. At this point, I couldn't care less. I was tired of rewriting the same function over and over on these very expensive pieces of paper and I set out to find out how to use this computer to do my calculations for me.

Little did I know what was in store.

First, I had to get used to using Linux cause that's what all the cool youtubers had to say (Luke Smith).

I had some experience with Linux cause that's all that would run on my potato pc but I had to work much harder. I read the Linux Bible and wrote every single page down. I installed and reinstalled arch and various versions of arch - aka manjaro.

I learnt some Bash. I learnt some Vim.

And then I discovered Emacs and org-mode.

Org-mode had everything I needed to learn. I could do my cross-references. I could run code on the same page (in the same buffer) as my text. I could insert links. I could run arbitrary elisp or shell commands on any piece of text and on my entire system as a whole. I could do my work all in one place.

Now all that was left was to learn how to program.

Y-Combinator

Learning to program was harder than I thought it would be. I thought programming was about learning syntax. So I taught myself python, bash, JS, rust, some C, some Common Lisp and guile scheme syntax. But it was not enough. I couldn't solve problems.

So I tried freeCodeCamp. I could solve problems in JS at least. But I quickly realized that I couldn't solve problems in other languages. I started to understand some concepts about computer science but it was shallow.

I decided to work on the venerable Structure and Interpretation of Computer Programs. I am still working on it and some supporting texts like Simply Scheme and Sketchy Lisp. Things started to make sense. Even in other languages.

I simply cannot recommend this way of learning Computer Science enough. There is hardly a procedure I cannot read right now once I understand the syntax. It just makes sense.

I have a lot more to learn but the compose procedure from before is what I've been looking for. It took me four years but now I can read stuff like this Y-combinator:

; Step 14: name the combinator
(define (Y r)
  ((lambda (f) (f f))
   (lambda (f) (r (lambda (x) ((f f) x))))))
(define (f s)
  (lambda (a)
    (cond ((zero? a) 1)
          (else (* a (s (- a 1)))))))
; Step 14: name the combinator
(define (Y r)
  ((lambda (f) (f f))
   (lambda (f) (r (lambda (x) ((f f) x))))))

(define (f s)
  (lambda (a)
    (cond ((zero? a) 1)
          (else (* a (s (- a 1)))))))

(Y f)
#<procedure 7fc8a45799a0 at <unknown port>:15:2 (a)>
; Step 14: name the combinator
(define (Y r)
  ((lambda (f) (f f))
   (lambda (f) (r (lambda (x) ((f f) x))))))

(define (f s)
  (lambda (a)
    (cond ((zero? a) 1)
          (else (* a (s (- a 1)))))))

((Y f) 5)
120
; Step 14: name the combinator
(define (Y r)
  ((lambda (f) (f f))
   (lambda (f) (r (lambda (x) ((f f) x))))))

(define (f s)
  (lambda (a)
    (cond ((zero? a) 1)
          (else (* a (s (- a 1)))))))

((f (Y f)) 5)
120
; Step 14: name the combinator
(define (Y r)
  ((lambda (f) (f f))
   (lambda (f) (r (lambda (x) ((f f) x))))))

(define (f s)
  (lambda (a)
    (cond ((zero? a) 1)
          (else (* a (s (- a 1)))))))

((f (f (Y f))) 5)
120

Everything is done in Emacs. No context switching. I set up and emms playlist and I'm ready to go. All this is just scratching the surface.

I name my notes using denote and store them using org-roam. I even have over 130 themes to choose from thanks to doom themes and ef-themes.

I use doom emacs to configure this all.

Personally, this is a dream come true. And this is only the beginning. I have so much more to do and I look forward to doing it.

Let's not even talk about guix.

That's why I use Emacs, it literally made my dreams come true. Even this blog was created using Emacs so I can tell you all about it using haunt, ox-haunt and a feature specific to Emacs called .dir-locals.el which allows you to run arbitrary elisp on files in a directory. It allows me to auto-publish this blog on save. How cool is that?

Even the blog's git history, through magit is just a quick C-c v g away. Nuff said.