[lua] Default to vanilla JSON parser#12771
[lua] Default to vanilla JSON parser#12771jdonaldson wants to merge 1 commit intoHaxeFoundation:developmentfrom
Conversation
Switch the Lua target's default JSON parser from hx-lua-simdjson (C dependency) to the pure Haxe implementation. simdjson can still be enabled with -D lua_simdjson. This removes a native dependency from the default Lua experience, making `haxe --lua` work without luarocks/simdjson installed.
|
I'd like to work on improving some of the Lua FFI behavior, and I realize we're still using an old custom simd json parser. I think we should default to using basic vanilla json here, and only enable that if someone really needs the speed. If we get better FFI support for arbitrary libs, it should be dead simple for them to wrap whatever tool they want (as long as they can access FFI in their env). Mainly looking for conversation first though, that library was one of the last things I worked on before I left, and it didn't feel particularly elegant. |
|
Not long ago I did some upstream lua-simdjson work and updated hx-lua-simdjson, so I think it wouldn't be considered "old" anymore. Since we started using it, it now has good windows support and also works on arm64 mac/linux. Current repo is here: However, I think it's fair to have a conversation about this. I would assume it was added mainly to improve benchmark results: #9622. Maybe that does not justify having an additional external dependency that most users could get by without, so perhaps making it opt-in is a sensible idea. Perhaps it is also worth considering whether it should even be part of the haxe std, it could equally be an external library that shadows the std Json type. |
|
My 2 cents is that we remove it from the std lib, and spin off a separate library for code with compiled performance enhancements. It was a bad idea for me to put simdjson in std IMHO. |
|
I'm also in favor of spinning it off entirely. Keeping simdjson in std was a mistake on my part — it adds a hard native dependency for something most users don't need. Related thought: would it make sense to have a general "performance-enhanced" haxelib for Lua that bundles native-backed alternatives? Things like simdjson, potentially native regex, etc. — opt-in replacements that shadow std types when you want speed. That way the std stays clean and dependency-free, but there's a clear path for users who need native performance. |
Summary
hx-lua-simdjson(requires native C dependency via luarocks) to the pure Haxe implementationhx-lua-simdjsoncan still be enabled with-D lua_simdjsonfor users who want the performancelua_vanilladefine continues to work as before for disabling all native Lua dependenciesMotivation
hx-lua-simdjsonrequires compiling and installing a C library via luarocks, which adds friction to the default Lua target experience. For most users, the pure Haxe JSON parser is sufficient, and users who need simdjson's performance can opt in explicitly.This also makes it easier to treat simdjson as a third-party library rather than a compiler dependency.
Test plan
-D lua_simdjsonstill works when the luarock is installed