Skip to content

[lua] Default to vanilla JSON parser#12771

Open
jdonaldson wants to merge 1 commit intoHaxeFoundation:developmentfrom
jdonaldson:lua-vanilla-json-default
Open

[lua] Default to vanilla JSON parser#12771
jdonaldson wants to merge 1 commit intoHaxeFoundation:developmentfrom
jdonaldson:lua-vanilla-json-default

Conversation

@jdonaldson
Copy link
Member

Summary

  • Switch the Lua target's default JSON parser from hx-lua-simdjson (requires native C dependency via luarocks) to the pure Haxe implementation
  • hx-lua-simdjson can still be enabled with -D lua_simdjson for users who want the performance
  • The lua_vanilla define continues to work as before for disabling all native Lua dependencies

Motivation

hx-lua-simdjson requires 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

  • CI passes with default (vanilla) JSON parser
  • Verify -D lua_simdjson still works when the luarock is installed

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.
@jdonaldson
Copy link
Member Author

jdonaldson commented Mar 9, 2026

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.

@tobil4sk
Copy link
Member

tobil4sk commented Mar 9, 2026

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:
https://github.com/HaxeFoundation/hx-lua-simdjson

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.

@jdonaldson
Copy link
Member Author

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.

@jdonaldson
Copy link
Member Author

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.

@skial skial mentioned this pull request Mar 24, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants