142 points · by earenndil · 6y ago · 89 comments
I ended up switching to Kakoune after trying it for a bit because I realized that in the two weeks of me exploring it I had entirely understood it’s “scripting language”, or at the very least understood how to use the onboard docs to write any plugin I wanted to.
Check this out [1]: kak script evaluating sh script which in turn call perl which constructs kak script commands and output them to stdout to be evaluated by kak.
Or this one [2]: same, as before, but now it's calling awk, which calls `date` binary (so it's kak → shell → awk → date → kak).
It seems that it's done this way because sh is not good programming language to use for manipulating text. Moreover, sh is not good programming language to write complicated programs, which later can be successfully maintained & tested.
For me, kak approach is past the border of unmaintainability.
Also, it raises question of why not to use embedded language like python or lua instead of creating such a limited editor-specific language.
[1]: https://github.com/mawww/kakoune/blob/25429a905b717d29bdf92c... [2]: https://github.com/mawww/kakoune/blob/25429a905b717d29bdf92c...
I do agree that sh is not a nice programing language, and forking programs all the time is not very efficient. I think that there is a tradeoff between the different approaches, and Kakoune's has proven to make quick'n'dirty very easy while being suboptimal for complex tasks.
I am okay with that tradeoff because I still believe most complex tasks do not need to be editor specific, and should be provided by separate tools written in a more maintainable language.
Another reason is that I've been trying to design Kakoune in a minimalistic way, and one thing I tried to unify was the user and scripting interface, which means I needed a command language that was easy to write interactively (`edit filename` vs `edit("filename")`). This is again a tradeoff that helps with simple things (as users already know the scripting language if they know how to use the editor), while making complex things harder.
POSIX shells languages however, are awfully designed (including zsh/fish for historical compatibility with POSIX concepts reasons).
Something close to TCL as a shell would be much better.
(Note, not considering JavaScript in the benchmarks seems like a pretty big oversight before making a conclusion of new default language.)
Why can't application developers abandon this strange habit of adding a slow "scripting" language?
Why not provide a versioned C API and be done with it?
A compiled language would allow us to use the best debugger and compiler on our systems and performance would be in the extension writer's hands and would eliminate the frustrating need to learn yet another scripting language.
How is it strange? Your suggestion sounds even more bizarro. It's not like those developers don't know about shared libs and .so files.
It's that:
a) Programming in C/C++/Rust is more cumbersome (than in a dynamic/scripting/gc language), and throws off tons of potential extension developers.
b) building extensions as .so even more so, adds different builds per OS/architecture, compilation steps, and tons of potential issues, both for setting up your extension building and for delivering it.
c) encouraging extensions written as .so in different languages, means a smaller pool of common reusuable extension code (each extension will reinvent several wheels). Whereas people could easily develop libs in the editors extension language and share them for re-use in others' extensions.
d) an issue in a C/C++/unsafe Rust etc extension will bring down the whole editor. In an embedded language that just calls API you can mitigate it easily.
f) same for memory leaks and such.
AAA game studios, which are hardcode C++ users with high performance / low latency needs, and have gone to using embedded scripting languages (with great success) and for some reason mere editor developers should abandon them and go pure C ABI?
a) I personally find using scripting languages more cumbersome in the medium to long term when I need to maintain, debug code, and optimise code. Every time I see a scripting/dynamic language, I'm turned off from extending the software that embeds it because debugability and performance will inevitably become a problem.
b) I'm not convinced of the alleged "tons of potential issues" that arise from using a compiled language. The extension can be distributed as C code (or whatever compiled language the text editor's community has decided upon). Every platform has a C compiler. I'd argue that C is the most portable language available. Extensions that don't compile will simply fade away, as do extensions in any scripting language, when they don't work. (There is no need for a complex build process or autoconf or whatever other frustrating arcane/convoluted build systems we've somehow been convinced are necessary.)
c) A dll is a shared library. By definition, that is reusable code. There's no necessity that "different languages" be encouraged, merely _a_ compiled language. Even if one extension were to be written in rust/zig and I choose to write an extension in C, is it really so hard for me to read the code I need from that extension and transcribe it for my purposes? I'm not convinced by the "reusable extension code" argument because I have not seen any statistics to justify it and I'm wary of anecdotes, including my own. How much of vim plugins or emacs extensions or vscode extensions are reused code from other extensions? Is it significant enough to raise this (that scripting language code is somehow more reusable) as an argument in defence of scripting languages as extension languages?
d) Patently false I think. (Recall also that emacs didn't successfully mitigate this case for a long time and extensions in elisp could crash the editor.) It's just as easy, if not easier, to mitigate this kind of thing in C. A loaded dll or function can be run easily in a separate process or thread or whatever else one desires. (Didn't plan9 ACME implement communicating processes, an architecture that might be suitable as mitigation of the sort you describe?)
(Also, reinventing the wheel is a bugbear that we should let go of. Attempting to reinvent a wheel is the only way by which one can truly understand how a wheel works. We shouldn't lose this ability or desire. The more we reinvent wheels, the better we get at examining fundamentals efficiently. If we don't reinvent wheels, we'll eventually lose the ability to make wheels.)
f) Claiming "memory leaks and such" is a bit too abstract for me to understand what you mean. I've seen an emacs extension gobble up gigabytes of memory and crash the editor. I suspect I can write such an extension even today. The fault and responsibility would be mine, the extension writer's. I've seen python scripts consume all of a system's memory. There is no magic bullet that solves how much memory a program needs and when the program needs the memory. The programmer has to solve these things.
I do not have any experience in AAA game studios. That said, I haven't heard of scripting languages being used extensively in recent years: A cursory glance at GDC presentations over the past 5 years doesn't reveal much emphasis on scripting languages or on the great successes you allude to. I gather from this that they've mostly been abandoned, excised from engines, or play a relatively insignificant role in the engines used for such games.
I'm not convinced that compiled languages constitute a significant barrier to entry merely because they are compiled and have low level facilities. That would only be possible if programmers somehow didn't have a working understanding of how CPUs and memory work, could only function with a garbage collector, and were unable/unwilling to run compilers like gcc or debuggers like visual studio, but such a person wouldn't meet the definition of "programmer" anyway, I don't think. My assumption is that a text editor, in particular, is being written for programmers.
Most extensions don't need raw performance, but an editor needs those extensions.
An entry barrier as low as possible is needed to reach the critical mass of third-party extensions that turn an editor into something worthwhile.
If you're not aware, Neovim is just that (although it supports vimscript as well)
I'm not sure that's a good thing.
doesn't neovim have first-party Lua scripting support?
There are other lispy languages, that are easier to embed without many of the warts of elisp. If you really want to have elisp, you have 3 ootions:
* Implementing it yourself
* Trying to break elisp and Emacs apart (not likely)
* Using guile's elisp implementation. It is complete and all that, but then you should just use guile scheme instead.Note that in my experience the biggest performance hog tends to be syntax highlighting.
Neovim changed some defaults and such, and I need to frob with my vimrc and such to spend time on it. I'm at a point in my career where I just want to build "useful stuff", and not muck about with my vimrc. For example, the default colours don't work well with my light background.
Neovim also removed encryption, which I use. Yes, I'm familiar with all the arguments for removing it and I've engaged in discussions on this in the past (so won't repeat it here): it's "good enough security" for what I use it for, and a much better UX than the alternatives. Again, more effort.
And what do I get back for it? I can't really name a single thing that would give me an immediate benefit to be honest. To be fair, I'm a "simple" user, and don't use stuff like :term and whatnot.
Also, I'm put off by the Neovim developers' attitude sometimes, things like a Neovim dev condescendingly describing VimScript2 as "BramScript" earlier today on Lobsters is ... not great, and neither is describing various disagreements as "cop outs" (e.g. t_* settings).
For non-vimmers, a good analogy is the shell: would you want to replace sh with a more robust language like lua? Few people seem to enjoy writing larger programs in sh, and are quick to jump to perl/python/ruby once a script crosses some complexity threshold. However, I doubt many people would want to give up sh for interactive use. Mainly[0] due to omitting “cruft” like parens/quotes/commas, and also pipe syntax. Minimal example:
ls -laht | grep foo
is nicer than grep(ls(‘laht’), ‘foo’)
especially when you’re doing thousands of commands of varying complexity every day.Vimscript is similar, again mainly due to omitting “cruft” like parens/quotes/commas, and also some specific sugar. Minimal examples:
iabbr cosnt const
is nicer than iabbr(‘cosnt’, ‘const’)
and s/foo/bar/g
is nicer than sub(‘foo’, ‘bar’, ‘g’)
especially when you’re doing hundreds (thousands?) of commands of varying complexity every day.Besides setting options, the vast majority of the “meat” of my config file boils down to these types of commands, and is thus much more readable with the cruft omitted, even though I only have to type it once.
This could probably be addressed with some light syntax sugar on top of lua, and I think I remember seeing some comments from the Neovim folks about this very thing, but I’m not able to find anything concrete at the moment. Does anyone know where this stands?
—
[0] Of course, another issue (for both shell-scripting and vim) is the huge amount of tools built on top of the existing language, which we may be remiss to abandon. For shells, it’s probably practically impossible. For vim, I suspect it is possible, though it would be painful enough to merit a long hard think.
From the post:
"Attempts have been made to implement functionality with built-in script languages such as Python, Perl, Lua, Tcl and Ruby. This never gained much foothold, for various reasons.
Instead of using script language support in Vim:
Encourage implementing external tools in any language and communicate with them. The job and channel support already makes this possible. Really any language can be used, also Java and Go, which are not available built-in.
Phase out the built-in language interfaces, make maintenance a bit easier and executables easier to build. They will be kept for backwards compatibility, no new features.
Improve the Vim script language, so that it can be used when an external tool is undesired.
All together this creates a clear situation: Vim with the +eval feature will be sufficient for most plugins, while some plugins require installing a tool that can be written in any language. No confusion about having Vim but the plugin not working because some specific language is missing. This is a good long term goal."
So, as I read this, his argument is that it makes sense to offer both external language support and Vimscript.
Kill vimscript adopt Lua for compatibly or Gluon for fp.
I can imagine a beautiful text centric EDSL in Haskell or a lisp that integrates tree sitter to provide syntactic hooks. I don't blame vimscript for not having this modern integration, but I do blame it for being a poorly designed language and I condemn any attempts to prolong its life. Over in NeoVim land treesitter is being integrated. Once it lands someone should write a EDSL in the Lua lisp.
Are the usual posts with comments (e.g. on some minor version release of a framework) on HN so much more interesting than a potential feature direction of a staple UNIX editor with a redesigned scripting language?
Either way, I'm happy that I saw it 1 of the handful of times it's been posted. Being a NeoVim regular, though, I'm more interested about how/if this carries over and what the gains would be there.
I never feel like it's slowing me down, and I can get everything I need from it.
Maybe it's a sign of vim's maturity that such news isn't received with much fanfare.
> I never feel like it's slowing me down, and I can get everything I need from it.
I feel the same way personally, but do you do a lot of scripting of vim? I don't, and I get the impression that that is a lot of pain points for vimmers much more experienced than I, so that that may explain why people like us don't see the need for such optimisation.
People who more into that stuff are the Vim9 benchmarks not underwhelming compared to Lua or did I miss something?
Even if neovim goes belly-up (unlikely), or totally diverges (slightly less unlikely), they’ve done a huge service to the vim community simply by existing and offering compelling, thoughtful enhancements while respecting the core spirit of vim - and being exceptionally mindful of practicality in how they approach changes.
Probably one of the best-ever examples of a fork that is Doing It Right.
Apparently that's the case, Bram did not compare against LuaJIT making the benchmarks pointless. They would quickly point out that Vimscript 2 also is, if this Reddit comment thread is to be believed: https://www.reddit.com/r/vim/comments/ejfn57/vim9/fcxi99k/ where justinmk is one of the Neovim core devs.
As an end user, Vim feels (IMO) like a dead-end. It's cool that Bram has started trying new things but he comes off as too protective of his creation, which is fine, but then it's normal for the community to move as well.
Incrementalism is powerful, even if it also takes a lot of work; breaking changes in Vim script are probably not worth it for anyone.