News for hackers. Stuff that matters.
Re:What I'd like to see in Emacs by mtlmtlmtlmtl on Tuesday December 06, 2022 @10:54PM (#33890457)
Am I the only one who thinks it's entirely obvious that JS is a bad idea for emacs? The beauty of emacs is that it's all in lisp. All of it, except a small C core which is mostly just the elisp implementation. If you don't like lisp, why on earth would you use emacs? There's an absolute fuckton of editors out there that support Javascript.

I don't even care what RMS' argument was, I think he's pretty out of touch most of the time. But putting Javascript in Emacs is just a stupid idea that would completely ruin it eventually. Let Emacs be Emacs and Vscode be Vscode.

Re:What I'd like to see in Emacs by Tistel on Tuesday December 06, 2022 @11:07PM (#33890518)
Agree. The beauty of lisp dev is that it’s a REPL that maintains state. You can edit the editor while editing. without restarting Write a defun and evaluate and it’s there. All the state persists. Most JS involves restarting the whole app on script change. I don’t use MS VS code because I can’t stand MS (if you know their history … you understand) Maybe they have the same feature now. Don’t know. The WYSIWYG editors are all web based. Maybe make a open source cloud hosted office suite? Google and MS should not have the only offering there.
Re:What I'd like to see in Emacs by oblio on Wednesday December 07, 2022 @06:44AM (#33893286)
Sorry, but this comment is so funny, it feels like I'm reading something from back in 2005, on Slashdot.
Re:What I'd like to see in Emacs by Derbasti on Wednesday December 07, 2022 @02:32AM (#33891652)
Let me be frank: ELisp is a terrible programming language. I have a number of Emacs packages (in ELisp) and Sublime Text packages (in Python), and the development effort difference between the two is not even funny.

That said, Emacs relies rather heavily on unique features such as dynamic binding, advice, and autoloads. These are more or less impossible to replicate in modern languages, so I don't think there's a reasonable path to rewriting major parts of Emacs in, say, Javascript.

But we should look at what Lua did for Neovim. There has been an explosion of development effort now that Neovim finally added a reasonable programming interface. A similar thing could happen in Emacs.

Re:What I'd like to see in Emacs by marklgr on Wednesday December 07, 2022 @03:26AM (#33891986)
> But we should look at what Lua did for Neovim. There has been an explosion of development effort now that Neovim finally added a reasonable programming interface.

It is very much debatable whether Lua is the "reasonable programming interface" causing the activity in Neovim. Vimscript has many flaws, one of them being that it doesn't look like other programming languages, but it does its specialized job pretty well. It is slow, but efforts are made in that area. Lua is well designed but it certainly has its shortcomings too, and many argue (me included) that programming in Lua is not that pleasant. The Lua bindings have been available in Vim for quite some time, but they never were popular, for some reasons.

Anyway, it is not directly related to your point, but I think that example is not that compelling.

Re:What I'd like to see in Emacs by giraffe_lady on Wednesday December 07, 2022 @09:43AM (#33894832)
Lua is a really good lure. You add it to a project and a bunch of people go "oh neat, I've heard a lot of good things about lua, I'll do this idea I've had in lua."

And then the realities of working in lua accrete over months, but then they're in too deep. What are they gonna do, learn elisp? Admit defeat and switch back to VS code?

Re:What I'd like to see in Emacs by klibertp on Thursday December 08, 2022 @04:58AM (#33906205)
> What are they gonna do

Personally, I'm using Haxe with its Lua backend. While wrapping Lua APIs is a pain, and some dynamic patterns are hard to represent directly, Haxe provides a lot of the things that Lua lacks: a gradual static type system, more familiar JS-based syntax, syntactic sugar for lambdas, sane handling of `this` in methods, control over inlining, immutable variables, generics, null safety, powerful hygienic macros, somewhat usable standard library, extension functions (Kotlin/Scala3 like), partial function application, hash and array comprehensions, functional operators on collections, limited operator overloading via abstracts, built-in LSP server, and a lot more.

I do this in the context of scripting my window manager, and plan to try this with Nginx/OpenRESTY. I feel like pairing LuaJIT runtime with Haxe compilation creates incredibly powerful combination. Lua provides coroutines, tail call elimination including corecursive functions, lightweight and fast JITed VM, a package manager (luarocks), bindings to important C libraries, FFI, reflection (everything is a table anyway), and more. The integration between Haxe and Lua is not yet seamless, and Lua compiler backend is one of the least developed, but even in this state I'm very happy with the combination of compile-time and run-time features I get.

Re:What I'd like to see in Emacs by giraffe_lady on Thursday December 08, 2022 @10:12AM (#33908654)
Ha interesting, I didn't really expect a serious answer but very cool. I looked into haxe a while back when I was gearing up for a significantly complex project targeting lua 5.1.

I ended not using it mostly because of unfamiliarity and it felt like it would add a fair bit of complexity. Didn't want to pick up a whole new ecosystem for that project.

I ended up using fennel, which solves most of my practical problems with lua without really making anything harder. Doesn't help with the package ecosystem or build process but I ended up just taking that compromise.

Don't regret it, still use fennel anywhere I'm forced to use lua, including hammerspoon and mud client scripting. I think if I was going to work heavily in lua long-term I'd go back and invest in haxe for it.

Re:What I'd like to see in Emacs by klibertp on Wednesday December 07, 2022 @08:01AM (#33893853)
> ELisp is a terrible programming language.

Why do you think so? My main gripe is the lack of namespaces and proper modules, but there are many languages in Top 10 on TIOBE that share this problem. The only other problem is a clunky, decades old standard library. Lack of consensus around async processing is less important, but also irritating.

Other than that, Elisp improved tremendously in the last 5 years, and it keeps improving with every release. The stdlib is getting some long overdue cleanups and sensible convenience modules are added regularly. The language features of other languages are being readily incorporated in the form of macros. The live environment along with "self documenting" code makes for a rapid dev feedback, and tools like built-in Edebug and 3rd party packages like Paredit and EROS make editing Elisp code more pleasant than most other languages.

Obviously, Elisp has many problems, it's not ideal, but it's nowhere near "terrible" in my opinion. At least not anymore.

Re:What I'd like to see in Emacs by JHonaker on Wednesday December 07, 2022 @10:58AM (#33895846)
I agree with you! It's not really that bad. The two biggest problems for me are the lack of namespaces/modules like you said, and the default dynamic scope (with the ability to enable lexical scoping).

They're both basically just ergonomic issues at this point, with prefixing names and always setting lexical scoping being cultural norms.

Re:What I'd like to see in Emacs by klibertp on Wednesday December 07, 2022 @12:13PM (#33897026)
> They're both basically just ergonomic issues

Yes! Prefixing names as a way of emulating namespaces generally works well enough. We could get modules support the same way JS used to have them, ie. as hashes of closures. Or we could use something like the `nameless` package, which rewrites the code to add a prefix to definitions automatically. Yet nobody seems to be doing either: it's just too much of a pain with too small a gain. The situation would be different if we got first-class module support in the language, but if we're going to only emulate it anyway, then namespacing with prefixes is just the easiest way to do it that is still "good enough". Still, Racket-like modules would be great to have, can't deny that :-)

Re:What I'd like to see in Emacs by gosukiwi on Wednesday December 07, 2022 @11:17AM (#33896140)
I don't know Emacs Lisp but didn't RMS just said in his talk that they changed the default to lexical scoping?
Re:What I'd like to see in Emacs by klibertp on Wednesday December 07, 2022 @11:58AM (#33896811)
Really? (Didn't have the time to listen to the talk.) I'd like to know if it was somehow measured, ie. how much of the Elisp code is still not adjusted to use lexical scoping and how much of such code would break by switching to lexical scoping. You can still opt-in to dynamic scoping by using defvar (and it's been a standard practice since forever), so the only scenario where old code would break would be where a called function accesses local variables from the calling function, like you would do in TCL with upvalue. I suspect that's a pretty small percentage of all the Elisp code in the wild; plus, this would be caught by the byte compiler, without the need to run the offending code. In any case: the change of the default is welcome, though not very important, as we've all already got used to putting `lexical-binding: t` at the top of every Elisp file :)
Re:What I'd like to see in Emacs by EFreethought on Wednesday December 07, 2022 @12:28AM (#33890927)
There are a lot of people who want to do everything in Javascript. Frankly I don't get why people want to do that. And Lisp is not that hard to learn anyway.

Javascript tends to ruin everything eventually.

Re:What I'd like to see in Emacs by otabdeveloper4 on Wednesday December 07, 2022 @01:00AM (#33891130)
It's the only programming language they know, since they grew out of being a "webmaster" but haven't learned properly about stacks of abstraction in computing.
Re:What I'd like to see in Emacs by sph on Wednesday December 07, 2022 @04:33AM (#33892397)
The classic phenomenon of junior engineers that have become decent at programming but unexperienced enough that they want to rewrite everything, thinking they can surely do better.

Now this is endemic in the JS world, especially because it is more ubiquitous than the previous beginner language, PHP.

Re:What I'd like to see in Emacs by theshrike79 on Wednesday December 07, 2022 @02:34AM (#33891659)
They have one tool in their toolbox: Javascript.

They don't want to have another, so they change the world around them so that Javascript can be used for anything.

Re:What I'd like to see in Emacs by shepherdjerred on Wednesday December 07, 2022 @12:50AM (#33891064)
> And Lisp is not that hard to learn anyway.

Lisp is much, much harder to learn than JS is. Aside from that JS is a very transferrable skill, but Lisp is not.

Re:What I'd like to see in Emacs by G3rn0ti on Wednesday December 07, 2022 @04:48AM (#33892492)
Here is the tree-sitter grammar of Elisp:

https://github.com/Wilfred/tree-sitter-elisp/blob/main/gramm... (approx. 200 lines)

and here is the grammar of JavaScript:

https://github.com/tree-sitter/tree-sitter-javascript/blob/m... (approx. 1200 lines)

JavaScript evolved into a language of similar complexity as Perl 5 (the corresponding tree sitter syntax table counts almost 2000 lines, currently).

Re:What I'd like to see in Emacs by shepherdjerred on Wednesday December 07, 2022 @05:24PM (#33901206)
I speak from my experience in college (~3-4 years ago) where, every year, 60% of the class dropped out of an AI class taught in common lisp because they couldn't understand it: https://catalog.harding.edu/preview_course_nopop.php?catoid=...
Re:What I'd like to see in Emacs by fiddlerwoaroof on Wednesday December 07, 2022 @01:03AM (#33891152)
You can learn lisp in half an hour. The hard part of emacs isn’t “lisp” it’s learning the libraries, just like it is in any other ecosystem. This difficulty would by present if everything was JS.
Re:What I'd like to see in Emacs by shepherdjerred on Wednesday December 07, 2022 @05:27PM (#33901245)
You really think that the bottom 50% of programmers could learn lisp in 30 minutes?
Re:What I'd like to see in Emacs by fiddlerwoaroof on Wednesday December 07, 2022 @06:38PM (#33901972)
Lisp isn’t any harder to learn than JavaScript or Python.
Re:What I'd like to see in Emacs by shepherdjerred on Wednesday December 07, 2022 @09:01PM (#33903145)
Here's my response to a similar comment in this thread

> I speak from my experience in college (~3-4 years ago) where, every year, 60% of the class dropped out of an AI class taught in common lisp because they couldn't understand it: https://catalog.harding.edu/preview_course_nopop.php?catoid=...

Re:What I'd like to see in Emacs by sshine on Wednesday December 07, 2022 @01:05AM (#33891162)
It depends on what you mean by "learn".

JS is much easier to become bad at quickly, which is not a bad thing.

Lisp is an ever-expanding paradigm, but you can learn it at a steady pace like JS.

JS is directly transferrable to similar-syntax languages, yes.

But Lisp provides insight into techniques that will expand your knowledge and understanding of all programming languages.

Does JS have a music video like this? (The Land of Lisp)

https://www.youtube.com/watch?v=HM1Zb3xmvMc

Re:What I'd like to see in Emacs by eimrine on Wednesday December 07, 2022 @09:10AM (#33894492)
> Does JS have a music video like this?

https://www.youtube.com/watch?v=jxi0ETwDvws ("Bug in the Javascript", not music video but video of musician performing vocal and harmonica parts of song)

Re:What I'd like to see in Emacs by lispm on Wednesday December 07, 2022 @01:26AM (#33891295)
Given that JavaScript has roots in Lisp/Scheme , a lot of people report that learning Lisp helped them to better understand JavaScript.
Re:What I'd like to see in Emacs by pmontra on Wednesday December 07, 2022 @01:59AM (#33891483)
I believe that you are right about trasferrability. About difficulty, it depends. If you start from C, Java or PHP then JS is easier than Lisp, at least until you get into the async stuff. If you start from vanilla Python, JS is more complicated so Lisp is not so much further away. If you start from scratch, they are both equally difficult.
Re:What I'd like to see in Emacs by fiddlerwoaroof on Wednesday December 07, 2022 @06:41PM (#33901999)
The things I learned from Common Lisp help me quite a bit in day-to-day JavaScript and Ruby development. The important transferable skills in programming are almost all language-independent, IMO.
Re:What I'd like to see in Emacs by shepherdjerred on Wednesday December 07, 2022 @05:28PM (#33901258)
Yes, I agree with this. My statement was based on most programmers learning a C-style language first. If you have experience in a functional language then lisp will be much easier to learn.
Re:What I'd like to see in Emacs by rich_sasha on Wednesday December 07, 2022 @04:16AM (#33892302)
I love emacs and don't live Elisp at all. I can use it, if pushed, but don't love it for sure.

Do i prefer JS? Probably not. But to me the draw of emacs is nothing to do with Elisp. It is instead everything to do with customisation, one-editor-many-languages, and the ability to do absolutely everything from a keyboard-based, low-clutter GUI.

Part of it is of course that good people made plugins in Elisp and maybe you'd argue that without it they wouldn't come to be, but I'm not sure.

Re:What I'd like to see in Emacs by sph on Wednesday December 07, 2022 @04:27AM (#33892356)
> But to me the draw of emacs is nothing to do with Elisp. It is instead everything to do with customisation

I keep hearing this argument but it is contradictory: the reason why Emacs is so customizable it is because it is written in a Lisp, a very versatile metaprogramming language.

You simply cannot have the flexibility of Emacs in anything less malleable than a Lisp. You'd have a regular editor with plugins.

I know many will want to prove me wrong, but where is the non-Lisp Emacs killer yet? VSCode is a great editor, but it's nowhere as flexible.

Re:What I'd like to see in Emacs by rich_sasha on Wednesday December 07, 2022 @06:58AM (#33893380)
Right; so assuming that's true (I'm not really sure either way), for me it's an enabling technology, not a feature.

If I could write plugins in Python, within the Emacs environment, I would (i believe it is sort of doable but quite wonky).

Re:What I'd like to see in Emacs by olau on Wednesday December 07, 2022 @03:20AM (#33891942)
Not everyone likes Emacs Lisp, but I think there are two main arguments - one is speed, and the other is familiarity.

Now that Emacs Lisp actually has native compilation, the speed issue is less of a problem, but it's a plain fact that a lot more people can do things with Javascript than Lisp.

I think usually if you have an application you'd prefer to reuse a programming language rather than having a language specific to the application. I think that was the main motivation for the failed port to Scheme.

Re:What I'd like to see in Emacs by celeritascelery on Wednesday December 07, 2022 @10:15AM (#33895255)
A problem with jumping over to the current popular language is that JavaScript will eventually fade in relevance, as all programming languages do. At that point Emacs would be saddled with two niche languages, and the advantage of using what is popular will be lost. Emacs is the “editor of a lifetime” and I expect it to be around for another 40 years. Best not make decisions based on what the current trends are.