-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
luajit/lua 5.1 compatibility? #291
Comments
I'm fairly new to the "Lua Universe" and thus probably do not know about some of the subtler differences/incompatibilities among the language versions. How is the general ecosystem? Which version is most popular? Are there large number of packages only working with one, but not the other version? I agree that aside from some distribution packaging issues, defaulting to Lua 5.2 probably does not make much sense. Either we should follow the latest release i.e. 5.3 or stick to 5.1 and thus support luajit. Maybe it would even be possible to use the corresponding compatibility module for Lua 5.3= The fact that Lua 5.3 added a proper 64-bit integer type might be helpful for the Lua API (see also #292). Having said all that did you encounter actual performance problems? Syntax highlighting might be the only slightly performance critical code, but so far the primitive approach used seems to be fast enough. Most of the heavy lifting (pattern patching) is performed by the Using luajit might have other benefits like the nice FFI. But again, I'm not sure how useful that actually is for providing an "idomatic" Lua API and not just a mapping to a set of C functions. The problem with adding luajit support is that it adds to the (admittedly currently mostly non-existing) testing matrix. It needs to be properly integrated into the build system, someone has to make sure it actually keeps working etc. Dropping support for the standard Lua interpreter is not an option because I'm interested in some architectures which are not supported by luajit. |
I'm new to it too. Concerning API/ABI compatibility: Most of these incompatibilities are added features as far as I can tell. LuaJIT is API/ABI compatible with Lua 5.1 As a result, the APIs between LuaJit and reference Lua are diverging more and more, and it looks like the Lua community is starting to split into two camps, the people who like Mike Pall's LuaJit and want the FFI and performance, and the people who want to use the reference implementation. That said, I believe most people support Lua 5.1+. If they want features from Lua 5.3 in previous versions, they use some form of compatibility. If you look at the TextAdept mailing list, there's a thread where they argue about it, and they end up supporting both Lua 5.3 and LuaJit, with a utf8 compatibility module for LuaJit. As for speed, LuaJit, according to their own benchmarks, is 1.5-100x faster than the reference implementation (though some of their cases are unfair, and in reality its more like an average 1.5x-5.5x speedup), so imo it's worth supporting. However, I have not actually encountered any performance problems yet. I imagine if someone is working on a very large source file (which is bad coding practice anyway), you might get some lag with syntax highlighting. If someone was interested in creating an autocompletion plugin in lua (like Vim's YouCompleteMe), it'd be much more likely. The plugin ended up being written as a separate program receiving information from Vim in a client-server fashion because it's so slow.
This isn't really a problem, you'd still be supporting Lua 5.1 In the end, it's your call :) |
The recently added code to handle digraphs uses |
In the luacompat-5.2 package I mentioned, the implementations for file:close() with those return values is at: Luajit appears to support it. |
That is not correct, neovim works both on LuaJIT and Lua 5.3 (there is compat module now in the tree). neovim/neovim#9280 |
@lluixhi What is the relationship between https://github.com/keplerproject/lua-compat-5.2 and https://github.com/keplerproject/lua-compat-5.3? Is the former subset of the latter? I have here SUSE-Enterprise-Linux 12, which has natively only Lua 5.1, and I wonder how complicated it would be to port vis to it. |
I have here this lua51-compatibility.patch, which makes
Not sure what is that about (is CORRECTION: Sorry, that was the binary from the previous version of the patch. This one starts |
I observe that many plugins now use functionality not available in Lua 5.1/LuaJIT. I am afraid that this is now a lost cause. Let’s close this. |
I'm not sure it's entirely a lost cause. Considering everything in vis still supports 5.2 I don't think it's implausible to fix compatibility with Luajit. 5.3 and 5.4 are much bigger (relatively speaking) when static linking so there is still an argument for not requiring them. On the other hand 5.1/Luajit have language bugs that will never be fixed (I don't understand Luajit's instance on inheriting things which are broken but I digress). I'm undecided on the matter. |
Hmm, when trying to build with LuaJIT ( From 06be327838384447000bdc279f638b3fe5944a5f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <[email protected]>
Date: Mon, 25 Mar 2024 15:51:22 +0100
Subject: [PATCH vis] Enable LuaJIT
---
configure | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/configure b/configure
index 0cc48a25..2566c349 100755
--- a/configure
+++ b/configure
@@ -425,15 +425,15 @@ test "$lpeg" = "yes" && lua=yes
if test "$lua" != "no" ; then
- printf "checking for liblua >= 5.2 ...\n"
+ printf "checking for liblua >= 5.1 ...\n"
cat > "$tmpc" <<EOF
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
-#if LUA_VERSION_NUM < 502
-#error "Need at least Lua 5.2"
+#if LUA_VERSION_NUM < 501
+#error "Need at least Lua 5.1"
#endif
int main(int argc, char *argv[]) {
@@ -444,7 +444,7 @@ int main(int argc, char *argv[]) {
}
EOF
- for liblua in lua lua5.4 lua5.3 lua5.2 lua-5.4 lua-5.3 lua-5.2 lua54 lua53 lua52; do
+ for liblua in lua lua5.4 lua5.3 lua5.2 lua-5.4 lua-5.3 lua-5.2 lua54 lua53 lua52 luajit; do
printf " checking for %s... " "$liblua"
if test "$have_pkgconfig" = "yes" ; then
--
2.44.0 the build failed:
|
Yes as I said above vis is using functions that are lua5.2+. Someone would need to replace those with the equivalent from older lua. For the integer functions its very likely that lua_integer is sufficient but it would need to be checked. |
I took a quick look at this. Was able to get vis compiling and running fine with LuaJIT after a few modifications. Here's what needs to change in the C code:
Only 1-4 are required to support LuaJIT. One way around 3 would be to return our own userdata type that wraps a FILE* and exposes the same functionality as a Lua file handle. I haven't looked at the implications for Lua code yet. |
luajit is significantly faster than the standard lua interpreter, and some distros like gentoo still consider lua 5.2+ unstable.
luajit is missing 5 functions you're using that are available in lua 5.2+.
lua_setuservalue
lua_getuservalue
lua_checkunsigned
lua_pushunsigned
luaL_optunsigned
luaL_setfuncs
Which you could possibly pull from here:
https://github.com/keplerproject/lua-compat-5.2/tree/master/c-api
(MIT licensed)
The text was updated successfully, but these errors were encountered: