News for hackers. Stuff that matters.
Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by musicale on Saturday October 12, 2024 @06:00PM (#41823081)
I don't care that much about the implementation, but I would like to see an emacs environment with:

- instant startup

- blazingly fast scrolling

- minimal keypress-to-display latency

I have written a lot of elisp (and had to deal with with buffer variables, dynamic scope, etc.), but aligning with modern scheme or lisp (if it can be kept compact and efficient) probably makes sense at this point. (Current emacs should provide backward compatibility as needed.)

Since so many people use emacs as an IDE, I think having an official emacs co-project/subproject focusing on a standard, extensible IDE framework (perhaps for other apps as well) would make sense.

It still seems like a pain to display graphics in emacs in various terminal apps. This should be easy, fast, and standardized.

As others have noted, supply chain attacks against open source are rampant, so vetting and sandboxing packages seems to be more important now.

Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by lysace on Saturday October 12, 2024 @06:16PM (#41823197)
I'm confused. On the modern devices I've recently used emacs on (including very low-powered raspberry pi devices), all of your three criteria are already true.

What kind of HW are you running emacs on where this isn't the case?

Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by musicale on Saturday October 12, 2024 @06:45PM (#41823383)
This is from 2015, but emacs still has higher typing latency than vim in 2024.

https://pavelfatin.com/typing-with-pleasure/

If you have better numbers and comparisons for emacs keypress-to-pixel latency, etc. I'd be interested.

Note classic vi started up faster than vim.

Device makes little to no difference: Raspberry Pi 5, MacBook Pro M1, ThinkPad P1, etc. - emacs is clunky on all of them. I like emacs and it's my daily driver. But it isn't fast.

see also:

"Computer latency: 1997-2017" https://danluu.com/input-lag/

"Measuring keyboard-to-photon latency with a light sensor" https://thume.ca/2020/05/20/making-a-latency-tester/

Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by znpy on Sunday October 13, 2024 @05:11AM (#41826381)
I have often see some fellow coworkers start up their fairly complex vim/neovim/other-vim setups and quite frankly… they ended up recreating a poor emacs implementation.

Yeah it’s faster at starting up but it’s worse in pretty much everything else.

Oh and they end up typing Ctrl-this Ctrl-that anyway.

Might as well use gnu emacs.

Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by arghnoname on Saturday October 12, 2024 @06:27PM (#41823267)
Emacs pauses are almost always due to some operation blocking in the main thread. It's pretty annoying and is mostly a consequence to a lot of things effectively being single-threaded. Stock emacs doesn't do this very often, but third party packages that might do expensive tasks often do
Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by lysace on Saturday October 12, 2024 @06:30PM (#41823282)
Ah. A case of "don't do that, then".
Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by iLemming on Monday October 14, 2024 @12:10AM (#41834090)
a) Build it with native-compilation flag

b) Use https://github.com/blahgeek/emacs-lsp-booster

c) Tweak GC vars, see: https://emacs-lsp.github.io/lsp-mode/page/performance/

d) Use plists for deserialization (described in the previous link)

e) Learn how to use built-in profiler and don't hesitate to launch it, sometimes simply disabling some minor-mode in specific setting is all it takes

f) Current state of Tree-sitter in Emacs is a mixed bag - for some modes you get huge improvements, for others it's the opposite. YMMV.

Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by hollerith on Saturday October 12, 2024 @08:48PM (#41824170)
Receiving output from a process, as is done for example by shell mode and (I guess, but have not verified) compilation mode, is slow in Emacs because all output is run through comint-carriage-motion and ansi-color-filter-region (which does nothing but throw color information away IIRC) which are written in Elisp.

If you don't run the output through those 2 functions, then non-printing characters remain in the output that severely undermine legibility.

C programmers tend to develop the ability to glean information from the voluminous output of build processes as it goes whizzing by on a terminal, so they find compilation mode frustratingly slow. Or at least that is my guess as to what happens.

Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by wging on Saturday October 12, 2024 @07:03PM (#41823500)
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).
Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by perihelions on Saturday October 12, 2024 @07:24PM (#41823641)
I wrap my slow .emacs loads inside #'run-with-idle-timer so they run when I'm not looking, and not likely to notice.
Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by andbberger on Saturday October 12, 2024 @10:03PM (#41824574)
what is this point of this, when would you not be using emacs?
Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by perihelions on Sunday October 13, 2024 @12:04PM (#41829119)
Only needs a few seconds of idle time to load libraries.
Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by musicale on Saturday October 12, 2024 @07:09PM (#41823531)
Yep, warm start is the only way to go unfortunately. But I want a fast start from cold boot like classic vi.
Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by rbc on Saturday October 12, 2024 @08:28PM (#41824070)
I think running daemon mode has significant advantages. You can have frames running on multiple virtual desktops for different uses. You can also step away from a buffer, and return to it, maybe from some other location on a different computer.
Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by sping on Monday October 14, 2024 @01:22PM (#41839654)
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 wo... by stackghost on Sunday October 13, 2024 @12:29AM (#41825146)
The solution to "this text editor takes too long to start up" is poorly addressed by the solution to "just leave it running in the background all the time".
Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by dokyun on Sunday October 13, 2024 @02:12AM (#41825599)
It really is not poorly addressed, as it's a reasonable solution to the issue which also brings about it's own benefits. If you have your system configured such that the Emacs server starts up when you log in, by the time you actually start Emacs it will long have already loaded completely. If you actually use your Emacs for several things throughout the day, including but not limited to reading and editing text and documents, then it is likely you will have it always running during that time with several files open, and will find it useful to be using Emacs in the same state it was in the last time you opened it.

As an aside, having it running in the background was actually the way the original EMACS that ran on ITS was intended to be used: When you C-x C-c out of it, it does not kill the program, it simply puts it in the background, and the next time you invoke EMACS it brings it back up. This is similar in effect to hitting C-z, then using 'fg' to bring it up again, but this only really works in a terminal. The Emacs server achieves the intended effect better, especially on a graphical display.

Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by iLemming on Monday October 14, 2024 @12:17AM (#41834127)
It's not a "solution"; you still need to solve your undesirably slow startup, but if you're having to kill and restart Emacs multiple times a day, something is wrong with your workflow. Normally, Emacs doesn't require restart - for weeks and months in some cases.

emacsclient is useful on its own. For example, I use it to edit just about any text, in any input box in any app, delegating the task to Emacs, or when I want to open some URL in Emacs, while browsing a web page in my browser, or to send some selected text to Emacs.

Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by stackghost on Monday October 14, 2024 @07:46PM (#41843447)
This has strong "you're holding it wrong" energy.
Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by iLemming on Monday October 14, 2024 @08:53PM (#41843824)
Well, if you see someone launching a browser, visiting website, then quitting it, and then later launching it again to visit another webpage, you'd tell them it ain't right, no?
Re:Ask HN: If you were rewriting Emacs from scratch, what wo... by iLemming on Sunday October 13, 2024 @10:02PM (#41833517)
> instant startup

My config is Doom-based. I use about 300 different third-party packages, and I don't even know how many built-in ones. It takes about 1.3s to start. Wishing for it to start even faster is like wanting my microwave to warm my tortilla in 5 seconds instead of 30. I don't restart Emacs every day, nor do I eat tortillas daily. Use a modern package-manager, and defer the loading of packages, it will start very fast - just like 'emacs -q' does.

> minimal keypress-to-display latency

A lot of times, setting keyboard rate is all it takes to make it nice,

On Linux: xset r rate 170 80

On Mac:

defaults write NSGlobalDomain KeyRepeat -int 1

defaults write NSGlobalDomain InitialKeyRepeat -int 10