News for hackers. Stuff that matters.
Re:Making bracket pair colorization faster by dariusj18 on Wednesday September 29, 2021 @10:20AM (#28694014)
Yes, but I feel like extensions are not considered "apps" in a way that would make people feel they should be able to write anything they want to change the editor. That way lies madness.
Re:Making bracket pair colorization faster by yaantc on Wednesday September 29, 2021 @10:37AM (#28694223)
> That way lies madness

That way lies Emacs ;)

That's the key difference between Emacs and most other editors: there's no limited API for extensions. There's a base C runtime, and all the lisp code on top is at the same level. There is no difference in access rights between a core Emacs package (coming with Emacs) and an additional, user installed package.

Of course, there are a lot of documentation, conventions and best practices to support this. And all the code is accessible.

Re:Making bracket pair colorization faster by NoGravitas on Wednesday September 29, 2021 @11:13AM (#28694779)
This article is especially interesting to me, as it shows how VS Code still doesn't have the "Emacs nature". Even though I'm a 30-year Emacs user, I do hesitate to recommend it to younger programmers because it's so alien, and VS Code has one of the essential characteristics of Emacs: the extension language and the implementation language are the same. But this article is a great example of how it doesn't — extensions are limited to using an extension API, rather than having full access to the application's internals. Maybe a good thing, if you're a mass-market product worried about malicious extensions. But I'll note that [rainbow-delimiters-mode](https://github.com/Fanael/rainbow-delimiters/) dates back to 2010, and has never noticeably slowed down loading or display of source files, even in languages with lots of delimiters like Lisp.
Re:Making bracket pair colorization faster by vbezhenar on Wednesday September 29, 2021 @12:49PM (#28696345)
I think that it's not about malicious extensions. It's about compatibility. If there's no public API, then all API is public and any code change will break something. So you either break extensions or don't change code at all. With public API you can change code while keeping public API working. And if something must be changed, the damage is limited and controlled.
Re:Making bracket pair colorization faster by db48x on Wednesday September 29, 2021 @02:27PM (#28697857)
The Emacs maintainers seem fairly conservative about changes to the Emacs runtime, but they have managed a number of extensive changes. It even has JIT compiling now.

Partly this is because the nature of the Lisp language makes these changes easier, but it is also the case that many “extensions” are actually included with Emacs. There are over a 1.5 million lines of lisp code that are included in the Emacs repository, though most of them are not enabled by most users.

Other extensions come from a wide variety of sources (and of course many users write their own code), but over the last 10 years most of them have been moved into installable packages hosted on elpa.gnu.org. There is a little over a million lines of code there.

It takes just a couple of minutes to check out both git repositories (for Emacs and ELPA), so any time you want to change something in Emacs it is quite easy to search all of that and find out exactly what, if anything, you might break.

Re:Making bracket pair colorization faster by tikhonj on Wednesday September 29, 2021 @10:27PM (#28702535)
That's true in principle. In practice, I've seen Emacs undergo non-trivial changes and yet none of my personal Elisp code has ever broken. I'm not sure how that happens—perhaps the core abstractions are sufficiently simple that they don't need to change much themselves and only higher-level things change, so code written against the core abstractions doesn't get broken.
Re:Making bracket pair colorization faster by Zababa on Thursday September 30, 2021 @07:01PM (#28712342)
VSCode being open source, I wonder if you could build an ecosystem of extensions that don't use the extension API but have full access.
Re:Making bracket pair colorization faster by dariusj18 on Thursday September 30, 2021 @09:29PM (#28713458)
I gotta say, "That way lies madness" == "That way lies Emacs" gave me a good chuckle. But your point is good, there are ways to do it, but VSCode has already started down the road of security first, and the emacs model would certainly not function in a sandbox.
Re:Making bracket pair colorization faster by sroussey on Wednesday September 29, 2021 @10:47AM (#28694372)
This is. Loser to the original Firefox extension model — pen access to everything. It later limited internal changes as internal stuff was external to extensions. It did allow powerful things like Firebug, which could not be build with todays modern and more secure locked down APIs.
Re:Making bracket pair colorization faster by sroussey on Friday October 01, 2021 @01:41PM (#28721393)
This is similar to the original Firefox extension model…

(Ug, the way autocorrect works sometimes..)

Re:Making bracket pair colorization faster by mastax on Wednesday September 29, 2021 @10:42AM (#28694297)
What happens when multiple packages want to modify the same code?
Re:Making bracket pair colorization faster by derefr on Wednesday September 29, 2021 @11:16AM (#28694840)
I have only the slightest passing knowledge of ELisp, but I believe it offers Aspect-Oriented Programming (AOP) facilities; most basically, chained decorators (i.e. replacing a function with your proxy for that function, where your definition of the function gets bound dynamically to the current definition of the function at eval-time; so the call your function makes to the “inner” function, could just be to another proxy wrapper function someone else already inserted.)
Re:Making bracket pair colorization faster by db48x on Wednesday September 29, 2021 @03:12PM (#28698443)
That is the most complicated description of it I have ever seen, but it is accurate.

In total there are ten ways to combine new advice with the existing set of methods, but the most commonly used are :before, :after, and :around. All the :before functions are called first, then the outermost :around function (which may or may not call the next :around function), then finally the :after functions.

Also it is common to define explicit hooks, which are just lists of functions that you will call at documented points. This is functionally identical to advice, except that it is also a good signal that the author intended you to do so.

The terminology is interesting too. Advice is deliberately modeled after the generic method combinators in Common Lisp. One of the authors of the Common Lisp spec, Gregor Kiczales, went on to define the term “Aspect–Oriented programming” and later developed AspectJ. Although the phrase appears nowhere in the documentation for Emacs Lisp, it is definitely appropriate!

Re:Making bracket pair colorization faster by derefr on Wednesday September 29, 2021 @07:59PM (#28701576)
I'd love to hear a more-concise description of what I just flailed around trying to describe; I'm always in the market for pithy explanations :)
Re:Making bracket pair colorization faster by db48x on Wednesday September 29, 2021 @11:05PM (#28702751)
Hmm. I don’t think concision is really the right way to go; below a certain length a description just becomes less precise and useful rather than better. I think that my own description should have had another paragraph or two, looking back at it.

Or maybe we could both be more concise by just telling people to go read The Art of the Metaobject Protocol.

Re:Making bracket pair colorization faster by NoGravitas on Wednesday September 29, 2021 @11:20AM (#28694887)
Usually packages don't modify code in core Emacs or in other packages. Often, they use package-supplied "hooks" to add behavior to other packages. Failing that, there's the possibility of 'advising' functions to add/change behavior at certain points without actually monkeypatching. I've never seen a distributed package actually monkeypatch anything, though it is something you could do in your personal config.
Re:Making bracket pair colorization faster by natrys on Wednesday September 29, 2021 @01:15PM (#28696768)
Yeah and even in personal config one could use el-patch[1], to make monkeypatching future proof.

[1] https://github.com/raxod502/el-patch

Re:Making bracket pair colorization faster by tikhonj on Wednesday September 29, 2021 @10:30PM (#28702542)
You know, I haven't thought much about this. I use a lot of third-party packages and have a lot of my own custom code, but things almost never interfere. In the few cases that crop up (for example, awkward interactions between org-mode's completion and the completion plugin system I use), it was so easy to add some code to my .emacs file to fix that problem that I had no real problems with it.
Re:Making bracket pair colorization faster by hoseja on Thursday September 30, 2021 @03:50AM (#28704076)
This is the only viable extension/modding architecture.
Re:Making bracket pair colorization faster by mastax on Wednesday September 29, 2021 @10:41AM (#28694285)
Tale as old as time:

VSCode vs Atom

WebExtensions vs XUL

Mod API vs patching game files

Vim vs emacs

Re:Making bracket pair colorization faster by w0m on Thursday September 30, 2021 @09:03AM (#28705791)
Oddly; I don't know anyone who ever did more than demo Atom...
Re:Making bracket pair colorization faster by neonbones on Thursday September 30, 2021 @11:10PM (#28714043)
I used Atom before VSCode. I'm still in love with its minimalistic design and somehow font rendering in Atom better than in VSCode (still not sure why, I tried to play with settings and stuff, but nothing changed). It was the first prominent Sublime Text alternative with JS that I use every day and quickly wrote my extensions, hack it and play with it. There were even interesting decisions like a Rust-based rendering engine[1] using graphics without HTML and DOM (the same old problem with faster text rendering with web techs).

In my opinion, the ONE big thing that killed Atom was LSP[2]. VSCode was slightly better in everything, but good performance and LSP destroyed Atom and damaged all other editors (like Sublime).

But MS plays dirty here too. In VSCode, LSP works with many inner hacks. You can't get the same experience with LSP in other editors because some features are part of the editor, not just LSP. But I think LSP is excellent and use it in Emacs and Vim too. For Rust, it's maintained by the Rust team and the default "engine" for editors.

Anyway, I'm still using Atom today with a minimalistic theme and setup to edit markdown files with code and as a text editor with a friendly GUI overall.

1) https://github.com/atom-archive/xray

2) https://langserver.org/