Earlier quoted context omitted.
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-…
Your lambda example is a fair point, but will that apply to things that have already been byte-compiled?
Ask HN: If you were rewriting Emacs from scratch, what would you do differently?
291–300 of 340 posts
Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?
#292Earlier quoted context omitted.
Your lambda example is a fair point, but will that apply to things that have already been byte-compiled?
I'm not exactly sure what you mean, tbh.
Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?
#293Earlier quoted context omitted.
I'm not exactly sure what you mean, tbh.
I mean, if a function that uses lambda has already been parsed and compiled, I’m guessing it won’t magically be updated to use the new definition of lambda. Not sure if I’m correct about that.
1. Read:
- In Python, the read phase must parse text into an intermediate representation (AST) that is distinct from Python's data structures. During the read phase, Python using built-in tokenizer and parser, parses its infamous indent-based syntax, handles literals, identifiers, keywords, operators, decorators, docstrings, comments, etc. Finally, it builds an AST.
- In Lisp, the read phase produces a data structure (s-expressions) that is directly usable as code. The syntax and the abstract syntax tree are essentially the same thing. Lisp uses built-in Reader - parses s-expressions while handling special syntax elements - quotes, backticks, commas, hash-quotes, handles reader macros, parses numbers strings, other literals, comments. But! No need to build an AST - the code already is.
2. Eval:
- Lisp can evaluate the s-expressions directly. The code is data, and data is code. That's where macros get expanded before the evaluation, function calls are resolved, symbols are looked up, tail calls optimized, byte-code compilation is available but not mandatory.
- Python must compile its AST into bytecode before execution. Python uses stack-based VM, figures out scoping and class namespaces, special forms (if, for, def) handled by specific bytecode instructions. Decorators are applied, reference counting and GC, tail call optimization (if runtime has it, standard CPython doesn't). It always has to compile bytecode before execution.
- Lisp macros operate on the code structure directly, allowing for powerful metaprogramming. Python's metaclasses and decorators are more limited in comparison.
3. Print:
- Elisp's printed representation of data is often directly readable as code. What you see is what you can evaluate. Eisp has built-in circular structure handling, Python doesn't. Elisp's printing is more focused on producing readable/evaluable Lisp expressions
- Python's printed representation, especially for complex objects, is often not directly executable code. Python's object-oriented approach allows for more customization through methods
4. Loop:
The Loop phase in both cases ensures that the REPL continues to accept and process input, making interactive development and experimentation possible.
- In Lisp, you can easily manipulate the environment, even the REPL itself, using the same language constructs.
- Python's REPL is more of a black box from the language's perspective.
Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?
#294Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?
#295I'd make cursors be positioned within the document instead of on the screen. Currently, Emacs does not support off-screen cursors. If you attempt to scroll a cursor off screen, it will move within the document to stay on screen. This behavior is contrary to all modern text editors, and there is no good workaround. I once made a serious effort to start using Emacs, but ultimately stopped because of the annoying cursor…
Curious, why would it matter that the cursor stays where you were when paging down?
Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?
#296Earlier quoted context omitted.
I mean, if a function that uses lambda has already been parsed and compiled, I’m guessing it won’t magically be updated to use the new definition of lambda. Not sure if I’m correct about that.
In this case it would't care. Since it's basically redefining what (lambda) means to the Reader. That is where that notorious distinction of Read-Eval-Print-Loop comes to play. 1. Read: - In Python, the read phase must parse text into an intermediate representation (AST) that is distinct from Python's data structures. During the read phase, Python using built-in tokenizer and parser, parses its infamous indent-based…
Not generally: in compiler-only implementations this is not provided.
Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?
#297Use 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…
Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?
#298Earlier quoted context omitted.
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 REP…
I don't think it makes sense. One can build programmable editors in many interactive languages. The language for an editor doesn't need to be Lisp. It could be Python, JavaScript, Ruby, PERL, Forth, ... Typically a form of EVAL or compile/load is enough to do so.
Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?
#299Earlier quoted context omitted.
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…
GNU Emacs is tied to Elisp. But Emacs is a much wider family of editors written in a multitude of languages.
> Yet somehow, in over forty years nobody has succeeded in dethroning Elisp from ruling Emacs
That might have several reason. Maybe few people are interested to reimplement GNU Emacs in a different language. Like nobody has succeeded in dethroning C from the Linux kernel, using Lisp.
Re: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?
#300> If you were rewriting Emacs from scratch, what would you do differently? UI: Electron, of course. Json to represent the edit buffer in RAM. Each utf8 code point base64 encoded, in a json array, it itself, as a blob, base64 encoded. Now, before you complain that that is gonna blow up the data too much, don’t forget that 1. “Ram is cheap” and 2. “gzipped base64 is about the same size as binary”. So, of course, we’ll…
Are you sarcastically describing VSCode, I don't get it?