Home Explore Blog CI



neovim

6th chunk of `runtime/doc/faq.txt`
b8973e5b94e4910de4c5535e4742c968b12cf355d928d0000000000100000d51

==============================================================================
Design                                                         *faq-design*


WHY NOT USE JSON FOR RPC? ~

- JSON cannot easily/efficiently handle binary data
- JSON specification is ambiguous: https://seriot.ch/parsing_json.php


WHY EMBED LUA INSTEAD OF X? ~

- Lua is a very small language, ideal for embedding. The biggest advantage of
  Python/Ruby/etc is their huge collection of libraries, but that isn't
  relevant for Nvim, where Nvim is the "batteries included" library:
  introducing another stdlib would be redundant.
- Lua 5.1 is a complete language: the syntax is frozen. This is great for
  backwards compatibility.
- Nvim also uses Lua internally as an alternative to C. Extra performance is
  useful there, as opposed to a slow language like Python or Vim9script.
- LuaJIT is one of the fastest runtimes on the planet, 10x faster than Python
  and "Vim9script" https://vimhelp.org/vim9.txt.html , 100x faster than
  Vimscript.
- Python/JS cost more than Lua in terms of size and portability, and there are
  already numerous Python/JS-based editors. So Python/JS would make Nvim
  bigger and less portable, in exchange for a non-differentiating feature.

See also:

- Why Lua https://web.archive.org/web/20150219224654/https://blog.datamules.com/blog/2012/01/30/why-lua/
- The Design of Lua https://cacm.acm.org/magazines/2018/11/232214-a-look-at-the-design-of-lua/fulltext
- Scripting architecture considerations http://oldblog.antirez.com/post/redis-and-scripting.html
- LuaJIT performance https://julialang.org/benchmarks/
- Discussion of JavaScript vs Lua https://github.com/vim/vim/pull/5198#issuecomment-554693754
- Discussion Python embedding https://lobste.rs/s/pnuak4/mercurial_s_journey_reflections_on#c_zshdwy


WHY LUA 5.1 INSTEAD OF LUA 5.3+? ~

Lua 5.1 is a different language than 5.3. The Lua org makes breaking changes
with every new version, so even if we switched (not upgraded, but switched) to
5.3 we gain nothing when they create the next new language in 5.4, 5.5, etc.
And we would lose LuaJIT, which is far more valuable than Lua 5.3+.

Lua 5.1 is a complete language. To "upgrade" it, add libraries, not syntax.
Nvim itself already is a pretty good "stdlib" for Lua, and we will continue to
grow and enhance it. Changing the rules of Lua gains nothing in this context.


WILL NEOVIM TRANSLATE VIMSCRIPT TO LUA, INSTEAD OF EXECUTING VIMSCRIPT DIRECTLY? ~

We have no plans for transpiling Vimscript. It was explored in https://github.com/tjdevries/vim9jit


ARE PLUGIN AUTHORS ENCOURAGED TO PORT THEIR PLUGINS FROM VIMSCRIPT TO LUA? DO YOU PLAN ON SUPPORTING VIMSCRIPT INDEFINITELY? (#1152) ~

We don't anticipate any reason to deprecate Vimscript, which is a valuable DSL
https://en.wikipedia.org/wiki/Domain-specific_language for text-editing tasks.
Maintaining Vimscript compatibility is less costly than a mass migration of
existing Vim plugins.

Porting from Vimscript to Lua just for the heck of it gains nothing. Nvim is
emphatically a fork of Vim in order to leverage the work already spent on
thousands of Vim plugins, while enabling new types of plugins and
integrations.

That being said, reimplementing legacy plugins in Lua in order to make use of
Nvim API and to integrate with Nvim-specific features such as treesitter can
be worthwhile.

vim:tw=78:ts=8:noet:ft=help:norl:

Title: Neovim FAQ: Lua vs. Other Languages, Lua 5.1, and Vimscript
Summary
This section explains why Neovim embeds Lua 5.1 instead of other languages (like Python or JavaScript) or newer Lua versions, citing Lua's small size, performance, and backwards compatibility. It also confirms that Neovim has no plans to translate or deprecate Vimscript, as it's valuable for text-editing tasks and maintains compatibility with existing plugins, though reimplementing legacy plugins in Lua for better integration with Neovim's features can be worthwhile.