Live data from Hacker News

Ask HN: If you were rewriting Emacs from scratch, what would you do differently?

news.ycombinator.com

271–280 of 340 posts

Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?

#271
post #73

Earlier quoted context omitted.

For instant startup I recommend daemon mode and emacsclient. Start emacs via emacs --daemon, open windows (in the terminal or otherwise) via `emacsclient` / `emacsclient -nc` (I use aliases for these).

Yep, warm start is the only way to go unfortunately. But I want a fast start from cold boot like classic vi.

Though trying to run Emacs like vi is a pitfall in itself. Clunking around the terminal summoning Emacs to edit files is really not a particularly effective way to use it. Emacs is not vi, and using Emacs like Emacs makes more sense. Most users explore your filesystem and spawn and monitor processes from within Emacs, rather than from a terminal.

Not that you can't work that way (and using `emacsclient` is the way to do it), but you're losing out by trying to shoe-horn usage patterns familiar from other toolchains onto Emacs. Emacs is not a text editor, it's a text manipulation platform that includes an editor - a number of editors in fact, including a vim clone.

Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?

#272
post #61
post #26

Earlier quoted context omitted.

emacs is not its keybindings. you can bind your emacs keyboard to do what you are asking for; as you said, you wrote a mode for emacs that works the way you want, and it wasn't necessary to rewrite Emacs.

> emacs is not its keybindings ... and it wasn't necessary to rewrite Emacs That's indeed true! But the premise of this question explores the scenario: What if we did rewrite Emacs from scratch?

Making modal editing with a leader key the default rather than an option it currently is, is a pretty trivial thing to bring up as the stand-out "feature" a rewrite could provide.

Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?

#273

Earlier quoted context omitted.

Do you have a concrete example of something you can do in a lisp repl like emacs that would be impossible to build into a python repl?

> Do you have a concrete example of something you can do in a lisp repl like emacs that would be impossible to build into a python repl? This is a challenging question, it's difficult to answer in a short few sentences. One practical example that immediately comes to mind is the advising system of Emacs, where you can modify specific parts of any given function, which isn't easily achievable with Python. In a Lisp RE…

I still don’t understand what advising has to do with homoiconicity. When you advise a function in emacs you’re not traversing its code as data, you’re adding some code to run at a predefined hook like :before, :after, etc., and I don’t see any reason why you couldn’t write a python interpreter that also lets you do the same thing. You could also have a repl implemented on top of this interpreter in python itself and advise and modify the running repl — just like you can with emacs.

So I’m again asking for a specific, concrete example of something you can do in emacs lisp that you couldn’t make a python interpreter do — not just waxing lyrical about how great lisp is.

Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?

#274

Earlier quoted context omitted.

> Do you have a concrete example of something you can do in a lisp repl like emacs that would be impossible to build into a python repl? This is a challenging question, it's difficult to answer in a short few sentences. One practical example that immediately comes to mind is the advising system of Emacs, where you can modify specific parts of any given function, which isn't easily achievable with Python. In a Lisp RE…

I still don’t understand what advising has to do with homoiconicity. When you advise a function in emacs you’re not traversing its code as data, you’re adding some code to run at a predefined hook like :before, :after, etc., and I don’t see any reason why you couldn’t write a python interpreter that also lets you do the same thing. You could also have a repl implemented on top of this interpreter in python itself and…

Right, advising itself on the surface doesn't seem to be inherently tied to homoiconicity, here's the concrete example in Elisp, this would print how long it took to evaluate a form.

     (defun add-timing-advice (orig-fun &rest args)
       (let ((start-time (current-time)))
         (prog1 (apply orig-fun args)
           (message "Evaluation took %f seconds" 
                    (float-time (time-subtract (current-time) start-time))))))

     (advice-add 'eval-print-last-sexp :around #'add-timing-advice)
     
While advising isn't inherently tied to homoiconicity, it is significantly easier to implement and more powerful in a homoiconic language.

Here's a different (not related to advising) example of redefining core macro, introducing code that "writes code":

    (defmacro lambda (args &rest body)
      `(function (lambda ,args 
                   (print "Lambda called!")
                   ,@body)))
                   
Now every lambda expression will print a message when called.

To implement something like that in Python, you'd have to modify the parser and complier, alter the runtime, reimplement core language constructs, but most importantly, you will have to change Python's syntax to make all code easily representable as data structures. Which then will become not Python but entirely different language.

Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?

#275
post #44

Use python instead of lisp.

Dear Cooking Show, I really liked your recipe for the shrimp-avocado salad, and I tried to make it, but since I was out of avocados I just substituted them with potatoes. Also, it turns out I didn't have any shrimp, so I just used some hot dogs I found in my freezer. OMG, this recipe is amazing. You just made my day. --- That's what using X instead of Lisp to make "a better Emacs" sounds like, okay? Emacs is a Lisp-m…

Don't be an ass.

Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?

#276
post #275

Earlier quoted context omitted.

Dear Cooking Show, I really liked your recipe for the shrimp-avocado salad, and I tried to make it, but since I was out of avocados I just substituted them with potatoes. Also, it turns out I didn't have any shrimp, so I just used some hot dogs I found in my freezer. OMG, this recipe is amazing. You just made my day. --- That's what using X instead of Lisp to make "a better Emacs" sounds like, okay? Emacs is a Lisp-m…

Don't be an ass.

What? I'm not trying to, I'm trying to be funny. Sorry if you read it in your head differently.

Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?

#277
post #275

Earlier quoted context omitted.

Don't be an ass.

What? I'm not trying to, I'm trying to be funny. Sorry if you read it in your head differently.

> Don't be stupid, stop saying stupid shit like "python instead of lisp".

Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?

#278
post #44

Use python instead of lisp.

Dear Cooking Show, I really liked your recipe for the shrimp-avocado salad, and I tried to make it, but since I was out of avocados I just substituted them with potatoes. Also, it turns out I didn't have any shrimp, so I just used some hot dogs I found in my freezer. OMG, this recipe is amazing. You just made my day. --- That's what using X instead of Lisp to make "a better Emacs" sounds like, okay? Emacs is a Lisp-m…

I do understand that for you Emacs is a Lisp development environment first, not a text editor.

Can you imagine people enjoying the user experience of Emacs while simultaneously preferring languages that are not Lisp?

Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?

#279
post #62
post #44

Use python instead of lisp.

I agree. Maybe it's just personal preference, since I think it's easier for me to think in python over lisp (which I've known for longer, but I still fumble through) I do think python would make emacs more accessible to a wider audience.

> I do think python would make emacs more accessible

It would not be Emacs anymore. Emacs is specifically tied to Lisp. Emacs is not a text editor that uses Lisp as the configuration language. Emacs is a Lisp machine that has a text editor built into it.

An "Emacs-like" editor built on Python might be interesting, but it wouldn't be a "better Emacs" or even "like Emacs", it would be a completely different thing.

You may dislike Lisp, you may even hate Lisp, but the fact remains unchanged - there is an emerging class of applications that is significantly more difficult to build around non-homoiconic languages. Emacs is one of them. Stop fetishizing your favorite programming language as the quintessence of Emacs. The best one can do is to build a compiler/transpiler to spit out Lisp code, and people have tried that. Yet somehow, in over forty years nobody has succeeded in dethroning Elisp from ruling Emacs.

Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?

#280
post #278

Earlier quoted context omitted.

Dear Cooking Show, I really liked your recipe for the shrimp-avocado salad, and I tried to make it, but since I was out of avocados I just substituted them with potatoes. Also, it turns out I didn't have any shrimp, so I just used some hot dogs I found in my freezer. OMG, this recipe is amazing. You just made my day. --- That's what using X instead of Lisp to make "a better Emacs" sounds like, okay? Emacs is a Lisp-m…

I do understand that for you Emacs is a Lisp development environment first, not a text editor. Can you imagine people enjoying the user experience of Emacs while simultaneously preferring languages that are not Lisp?

> I do understand that for you Emacs is a Lisp development environment first

It's not "for me", it is what it is. Emacs first and foremost is a Lisp machine, with a text-editor built into it, not the other way around, it's not a text-editor that uses Lisp as its configuration language.

"user experience of Emacs" is to be able to send any expression and sub-expression without any preceding ceremony directly to the REPL. Everything what Emacs does stems from that. No, Python doesn't have the same REPL. Every single stage of it in Python is different. Lisp's Read, Eval, Print, Loop - they all have slightest differences. Those differences are possible because of Lisp's homoiconic nature. Because of that you get Lisp macros, because of that you get advising functions, because of that you can do source blocks in Org-mode that can interact with and modify their own execution environment. Lisp's homoiconicity allows code to be treated as data and vice versa, enabling powerful metaprogramming capabilities. This means you can:

1. Manipulate code at runtime

2. Create domain-specific languages easily

3. Extend the language itself

In Org-mode, this translates to source blocks that can:

1. Dynamically generate and execute code

2. Modify their own content or other blocks' content

3. Interact with the Emacs environment seamlessly

This level of flexibility and power isn't achievable in Python's REPL due to its more rigid separation between code and data. While Python is highly versatile, it lacks the deep introspection and self-modifying capabilities that Lisp's homoiconic nature provides, making Lisp uniquely suited for certain advanced metaprogramming tasks and interactive development paradigms.

So the bottom line is: you can imagine really hard, but it would remain just an imagination, if you want to build something like Emacs - a REPL that has a built-in text editor, you need a Lisp, because non-homoiconic languages DO NOT HAVE exactly same REPLs. Now, do you want me to get seriously pedantic and explain how every step in ReadEvalPrintLoop differs in Lisp and Python?

Post reply on HN