5 ms·
I’m really picky about my tools in general and latency in particular, and I give Zed a spin from time to time, it’s sweet. Clean, minimal design aesthetic, tree
by benreesman 3y ago
I’m really picky about my tools in general and latency in particular, and I give Zed a spin from time to time, it’s sweet. Clean, minimal design aesthetic, tree-sitter, tight code, it’s a nice bit of work and I dig it a lot.
But emacs 29 with the right flags and a tuned GC (no one does this! it’s got a heap-size from the 80s!) is just as snappy and has more amazing packages than VSCode.
There’s a market for people who want something snappier than VSCode but less labor-intensive to set up than emacs, and I wish them luck: I think it’s a front runner there. But I can’t imagine switching my main axe up with a holy shit moment a lot crazier than tree-sitter in 2024 and not having the render loop be in JS.
- shanusmagnus 3y ago> But I can’t imagine switching my main axe up with a holy shit moment a lot crazier than tree-sitter in 2024 and not having the render loop be in JS. I can't parse this sentence -- could you unpack it? Not being a dick, I really want to know what you mean.
- nccnm 3y agoCan you share more about your Emacs 29 setup? Thanks
- benreesman 3y agoI mentioned it above but I’m flattered by your interest (and remember your username as someone serious): my old dots were ok and are floating around but we’re putting together a multi-editor curated setup for good defaults and an emphasis on good, available-weight models as first-class citizens. It’s a 404 until I get to an RC, but aiming for March 1st on “hyper-modern.ai” for all MIT on emacs, nvim, and vscode.
- jitl 3y agoHow do you get a reasonably fancy Emacs to start up/open files quickly? Every time I try to get into EMacs after adding a few packages it becomes painfully slow to open a file for editing. Then I try to understand Emacs server, then I fail / give up and go back to vim.
- lynx23 3y agoI was about to answer "Use emacsclient", but then I realized you can't be bothered to configure it. For me, putting "(server-start)" into .emacs was always enough, but YMMV.
- PH95VuimJjqBqy 3y agoyeah, I can't deal with the emacs startup. I mean, it's not slow per se, but compared to vim it's noticeably slower so I can't deal with it.
- cyruseuros 3y agoThe way the other guy said. Then it breaks enough times, you give up, and switch to Helix. Nothing snappier out there (vanilla Vim included) and it comes with all the goodies you'd install 100 packages for (DAP, LSP, treesitter, sane default configs for dozens of languages) To each their own, but for a hardcore Emacs user (wrote a number od my own plugins) that actually tried and couldn't seriously adopt VSCode for more than a few months, Helix was such a nice surprise + change of pace. Worth giving it a shot if you're caught in that gap.
- shanusmagnus 3y agoIs there something that approximates org-mode outlining? I don't need all the other stuff org-mode does, but just the simple outliner functionality combined with all the other Emacs stuff is my golden handcuffs.
- cyruseuros 3y agoNot that I'm aware of just yet, unfortunately, so might be a good reason to stick around. For me the switch coincided with jumping on the zettelkasten train and I haven't looked back since. I miss some org mode fratures but constantly `org-refile`-ing I can do without.
- willdr 3y agoOpen it at 8am, close it at 8pm
- dataangel 3y agowhat are the right flags and gc tunings?
- benreesman 3y agoI don’t have much to add on what sibling @darthrupert said. You tweak this or that to your box but that’s an excellent guideline to start.
- manupanday1998 3y agoYes you are correct
- da39a3ee 3y ago> But I can’t imagine switching my main axe up with a holy shit moment a lot crazier than tree-sitter in 2024 and not having the render loop be in JS. Congratulations for winning HN sentence of the year before the end of January.
- benreesman 3y agoI’m glad I made a funny but it’s a lot of year to come :) And this one looks to be every bit as interesting as the last one was over-hyped.
- conartist6 3y agoIt is a great sentence, and that holy shit moment is coming: when JS gains all the expressivity of tree-sitter and uses it to render code more beautifully than it has ever been rendered before. (Spoiler: https://github.com/bablr-lang/ https://github.com/bablr-lang/)
- darthrupert 3y agoPeople are asking what settings would be useful to tweak. Check out the following: - gcmh -package and gcmh-mode and/or gc-cons-threshold variable (former should take over the latter) - read-process-output-max - jit-lock-defer-time - package-native-compile Doom Emacs sets gcmh in its initialization so tweaking that might not be needed there. You may still want to touch gcmh-high-cons-threshold and gcmh-idle-delay-factor. Here are mine currently: (setq gc-cons-threshold (* 1024 1024 1024)) (setq gcmh-high-cons-threshold (* 1024 1024 1024)) (setq gcmh-idle-delay-factor 20) (setq jit-lock-defer-time 0.05) (setq read-process-output-max (* 1024 1024)) (setq package-native-compile t) I've done nothing scientific to check out if these help at all, though, so take them with salt. With and without these, emacs seems quite sluggish at least on a Macbook, in certain modes. On Linux things seem to be a bit better.
- natrys 3y agoThe thing about gc-cons-threshold is that, too low a value and it will collect garbage too frequently. While a high value will drastically reduce frequency, but then GC pause will be big and you will likely feel whole system freeze and stutter when it happens. For me, 1GB is too high because I sorta notice the pause, I set it to 32MB but completely disable GC when minibuffer is active: (defun my-minibuffer-setup-hook () (setq gc-cons-threshold most-positive-fixnum)) (defun my-minibuffer-exit-hook () (setq gc-cons-threshold (* 32 1024 1024))) (add-hook 'minibuffer-setup-hook #'my-minibuffer-setup-hook) (add-hook 'minibuffer-exit-hook #'my-minibuffer-exit-hook) Eli Zaretskii (current Emacs maintainer) also thinks 1GB is too high, though for somewhat different reason: https://old.reddit.com/r/emacs/comments/bg85qm/garbage_collector_magic_hack/ https://old.reddit.com/r/emacs/comments/bg85qm/garbage_colle... Here is an interesting optimisation that was merged in master, but didn't make the cut for 29 in time. I thought it improved snappiness: https://tdodge.consulting/blog/living-the-emacs-garbage-collection-dream https://tdodge.consulting/blog/living-the-emacs-garbage-coll... --- Anyway, I also have these in my init (I nicked these from Doom which I don't use but they have done a lot of work to dive deep into these things, mostly around what improves start up but the following might help in general): ;; if you don't use RTL ever, this could improve perf (setq-default bidi-display-reordering 'left-to-right bidi-paragraph-direction 'left-to-right bidi-inhibit-bpa t) ;; improves terminal emulator (vterm/eat) throughput (setq read-process-output-max (* 2 1024 1024) process-adaptive-read-buffering nil) (setq fast-but-imprecise-scrolling t redisplay-skip-fontification-on-input t inhibit-compacting-font-caches t) (setq idle-update-delay 1.0)
- sooheon 3y agoEmacs still blocks input on simple things like package updates though.
- benreesman 3y agoGive straight.el (among others) a shot. Combined with use-package you don’t have to worry about that these days.
- sooheon 3y agoAh ok. Last time I used straight it still blocked input on straight-update-all, didn’t realize they changed this.
- benreesman 3y agoThere's a little tweaking sometimes. Most examples you'll see of `straight.el`/`use-package` configurations will have some version of: `(use-package something-cool :ensure t :config ...`. The `:ensure t` clause will cause it to fall back on `package-install` in the event it's not bolted into your local Cargo-style-own-the-world-and-dont-break repo mirror. Disks are big, it's like the right default now. But if you've got a package that's mis-specified in terms of where on `github` or wherever that `striaght` is supposed to find it, you can find it tapping `elpa.org` on the shoulder at a time when the UI thread is also doing blocking network IO. The `Messages` and/or `straight` buffers will have warnings about this, so it's fixable to find the offending package and it'll stay fixed, but in fairness what you're describing is possible.
- bergheim 3y agoElpaca [1] does not do this. I use it and it works a treat. 1: https://github.com/progfolio/elpaca https://github.com/progfolio/elpaca
- ungamedplayer 3y ago> But emacs 29 with the right flags and a tuned GC (no one does this! Please share how.
- pja 3y agoRipped from my .emacs: (setq gc-cons-threshold (\* 100 1024 1024) ;; GC sometime after allocating 100Mb read-process-output-max (\* 1024 1024) company-idle-delay 0.0 ;; company completions should be fast company-minimum-prefix-length 1 lsp-idle-delay 0.1) ;; clangd is fast (run-with-idle-timer 2 t (lambda () (garbage-collect))) ;; Trigger a GC after 5s of idle time This is something of a hack of course, but it works & memory is cheap. You might want to push the GC threshold back down after emacs startup - a GC that fires early is a GC that does less work per invocation & is therefore less likely to cause perceptible stutter.
- benreesman 3y agoBoth @darthrupert and @natyrys on the thread have said most of what I know. It's a little machine dependent to get the true sweet spot, but raising it from the like, megabyte (slight hyperbole) or whatever that it defaults to is the 80/20.
- dilap 3y agoi got annoyed by emacs gc pauses and just disabled the gc completely (i think). haven't noticed any downsides so far. i'm in emacs all day... ;; don't garbage collect based on cons count (setq gc-cons-threshold 10000000000) (defun garbage-collect (&rest args) (message "trying to garbage collect. probably you want to quit emacs.")) something i love about emacs is everything is implemented in the same abstraction (of a "buffer of text"). so i can manipulate and move around an embedded terminal in the same way as a normal file, etc. playing briefly with Zed it seemed like the terminal was a totally different "thing" than a normal file; i couldn't run the same text selection operations, couldn't split the window vertically or horizontally, etc. to me that loses a ton of the benefit of having a terminal in the editor in the first place. still, it's a very interesting project. i have a very love/hate relationship with emacs, so i'm always interested in alternatives...
- oblio 3y ago> (no one does this! it’s got a heap-size from the 80s!) Shouldn't the devs do this? We're in 2024, embedded systems have more RAM, IO, etc than anything from the 80s.
- benreesman 3y agoThe, uh, GNU folks, are a little conservative in some ways that surprise the mainstream developers. But there are always flags for it. Well, except stupid-ass dynamic-linking of `glibc`.
- oblio 3y ago> are a little conservative in some ways that surprise the mainstream developers Conservative is one thing, but having the default be something that's detrimental to 99.999% of your users in 99.95% of situations feels like bad defaults/design, not being conservative. My worthless 2 eurocents :-)
- estebank 3y agoYou would think that it would dynamically check the system on first run and set appropriate defaults.
- minroot 3y agoI can't still figure out how can I get Emacs not mess up indentation and auto indentation.
- benreesman 3y agoMost language modes have a `foo-ts-mode` now that uses `tree-sitter` to get a perfect* AST in the absence of errors, and almost always the most reasonable one in the presence of errors. `tree-sitter` is amazing, a real feat. It ships with 29 and it's work to find `brew` or `apt` or `nix` or anything giving you less than 29.1 these days. Have you tried a recent version? 29.1 is dramatically more accurate on everything from syntax highlighting to indention than VSCode (IMHO, they're probably either using or working on using `tree-sitter` too, those are serious people) or JetBrains stuff (they're working on their vscode clone more than IntelliJ these days). I only use `nvim` for commit messages and stuff the last few years, but AFAIK it has all the `tree-sitter` stuff too. If it's the sloppy naming of `c-basic-offset-this` vs. `py-indent-that` or whatever (I don't even remember), try a good baseline distro like Doom and tweak from there.
- kamaal 3y ago>>But emacs 29 with the right flags and a tuned GC (no one does this! it’s got a heap-size from the 80s!) is just as snappy and has more amazing packages than VSCode. That explains my whole experience with Emacs. More time is spent in making Emacs awesome than actually doing my work.
- angra_mainyu 3y ago> There’s a market for people who want something snappier than VSCode but less labor-intensive to set up than emacs, and I wish them luck Basically AstroNvim or Doom Emacs. Not a huge fan of Doom Emacs but AstroNvim got me to drop my main editors (Sublime + Atom) and I basically only use AstroNvim. One enormous advantage of Nvim is that I can run it anywhere. I run it on a Linux machine, a Mac, and a Tablet (w/ Termux) extremely easy (just clone my dotfiles, install nvim, and that's it).