164 points · by demiol · 9y ago · 76 comments
Go seems like quite possibly the polar opposite of this, as far in the "keep it simple and understandable by literally everyone by cutting out many techniques for metaprograming and code reuse". Which perhaps is the point, but if so it seems like that point misses much of the draw of Emacs?
While this is definitely impressive technically, I think Guile Emacs is a much more plausible option.
Also, some of my projects that become bigger than 1000 LoC could benefit from static typing and (subjectively) better tooling.
By the way, I think extending Emacs in Racket would be great; just do not have an idea on how to implement that integration smoothly.
;;; -*- lexical-binding: t -*-Racket seems like a near perfect match for the domain. Start with a hacky one-off script. Augment with unit tests. Code base grows and starts becoming more stable? Progressively migrate to Typed Racket.
Mapconcat is already used inside runtime implementation: https://github.com/Quasilyte/goism/blob/master/src/emacs/rt/... (Print and Println functions).
Technically impressive, I'm sure, but will it be around for another 30 years?
If someone writes a module using this, will I be able to rely on that module keeping on working for the years to come?
There can be a backend that generates Emacs Lisp code. Not necessary optimized or idiomatic, but it could be a good starting point for rewriting.
But in general, I agree with you.
I'm far from a JS fanboy but I think your point lends credence to the idea of using JS more than it strengthens the use of Emacs Lisp.
Similarly, the package repository is not exactly inspiring. Similar patterns of many packages doing the same thing. Often not bringing new advantages to the table, so much as revising old weaknesses. Many rooted in choice of language.
Which is actually not too complain of JavaScript. I do like it. And I love that people are empowered to try things. Even if they were previously done. I do wish people knew more options, though. Including myself.
Seriosuly, is that hard to learn Emacs Lisp? Even if one is using Go or Rust (etc) at work, any programmer worth his salt should at least already be familiar with Lisp syntax.
It is one of the easiest languages to learn!!
Emacs has really good support for it which continues to improve over time.
But.. I love more than one language (and more than one Lisp for sure). Will you try to persuade me that I am wrong in that regard?
If it's just a demo then it's neat. Interesting that it can be done.
On the other hand, if it's a real push to get people scripting Emacs with Go, then I don't see the point at all. It's solving a problem people don't really have.
Isn’t "I want to script Emacs but I don’t like LISP" a problem to solve?
I don't think it's that unusual. Emacs is quite popular. If even 25% of the user base coded in Lisp, it would be ... astonishing.
Who decides they want a script-able editor, but then chooses one scripted in a language they don't like and don't want to learn?
Probably not (except those who made that project).
> Who decides they want a script-able editor, but then chooses one scripted in a language they don't like and don't want to learn?
Mostly because the scripting language is not the first thing you think about when using an editor (just guessing here; I don’t have data on that). I started using Vim because its editing capabilities are quite powerful but its scripting language is really bad. Emacs’ LISP is great, but I can’t get used to the way Emacs commands work.
I found some optimizations that are not implemented inside Emacs lapcode optimizer. If I will port them to byte-opt everyone win, right (if they pass Emacs team review, of course)?
Clearly, power is the only measure one should consider when picking a programming language. And Lisp surely has more power than Go. I'm going to guess 36.1% more power, to be exact.
>and what can be done about it
We could always start performing eugenics to get rid of them.
... Okay, I apologize for being an ass. But I hope my points aren't lost; the way you're phrasing things makes it feel like you're bitter that anyone would consider using something that's not Lisp.
Sarcasm aside, Lisp is as much as possible well-suited for the job of text and AST processing, Emacs is one of the Lisp's "killer apps" and the second best "case study" after classic old-school AI code (PAIP).
1. Use a plugin system (ecaml)
2. Transcompile to a target language (gosim and emscripten-like platforms)
3. Embed another VM inside Emacs and call its eval
There are many differences between these approaches and I am not sure one of them is objectively better as a general solution.
For the end users, all of these approaches can deliver good level of integration (they require different sets of tricks to achieve that).
I wonder about the implementation strategy -- why compile to Emacs LISP instead of doing a plugin (FFI) or RPC style setup?
Name mangling scheme preserves fully qualified package path. All goism sources live inside GOPATH (1), so nothing stops us from implementing a jump to Go definition.
For given `goism-foo/bar.baz` Emacs symbol, Go definition can be found in `GOPATH/src/foo/bar/` package. Exact location can be found by using existing Go tools (simple grep-like solution can work, too).
(1) It can change in future; see https://news.ycombinator.com/item?id=13368846 and even more relevant: https://github.com/golang/go/issues/17271
Easier to debug, simpler to trust (for the end user) and not that hard to generate.
The problem is that it is harder to implement some features of Go in terms of Emacs Lisp without going down to the virtual machine level. Best examples are arbitrary return statements (can be emulated by throw/catch) and goto.
Possible implementation (about 20 lines of code): https://github.com/Quasilyte/goism/issues/57
Not sure if "defadvice" around "byte-compile-form" is acceptable for all users.
Some S-expressions with `cl-return' can be rewritten to avoid the need of it (by the optimizer); not sure it covers 100% of the cases though.