Skip to content
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

Would you be interested in a code merge? (json-logic-engine) #119

Open
TotalTechGeek opened this issue Dec 16, 2022 · 2 comments
Open

Would you be interested in a code merge? (json-logic-engine) #119

TotalTechGeek opened this issue Dec 16, 2022 · 2 comments

Comments

@TotalTechGeek
Copy link

Hello!

I am and have been a huge fan of JSON Logic & the language you've designed.

For a while I've maintained an alternative JSON Logic implementation, and I'm curious if there's any interest in potentially doing a code merge? Introducing some of the work done for json-logic-engine into json-logic-js?

I would be happy to make efforts to ensure that any remaining differences are removed, mainly just:

  • Empty Arrays are truthy in mainline json-logic.
  • "all" with zero items evaluates to true

However, my codebase is not designed for as much compatibility as your project is (it most certainly would not work with IE8), though it should be able to run in all currently supported web browsers.

If you'd prefer for our projects to remain separate, there won't be any hard feelings 😄.

@TotalTechGeek TotalTechGeek changed the title Would you be interested in a code merge? Would you be interested in a code merge? (json-logic-engine) Dec 16, 2022
@TotalTechGeek
Copy link
Author

TotalTechGeek commented Nov 2, 2024

Hey @jwadhams, I've recently been putting some work into JSON Logic Engine, and I decided to revisit some of the compatibility differences.

I've introduced a flag in my project that applies some of the truthiness differences (empty arrays being false for both all and truthiness checks in general).

With 100% compatibility, I wanted to reach out and see if there's any appetite for merging the projects.

What JLE Introduces:

  • Asynchronous Support
  • The ability to define control structures in user space.
  • Handlebars style data traversal (you can access above state from inside of iterators)
  • Logic Compilation to enhance performance (like, in the realm of 10-30x acceleration)
  • An "optimizer" for interpreted logic -- this guy caches the execution plan of the logic so that it doesn't need to traverse any logic if it's seen it before.
  • Support to control what objects are treated as "data" and which are treated as Logic.

I've also produced some small benchmarks around the public JSON Logic tests, here are the timings of 1M iterations for each -

json-logic-js: 3.032s
le interpreted: 2.975s -- This guy has the optimizer disabled, as a way to keep things somewhat "fair"
le interpreted (optimized): 724.976ms
le built: 79.539ms
le async built: 432.778ms

If you're available, I'd love to chat about how I can contribute back to this really awesome spec you've built, and to the broader community.


I've been using JSON Logic to a ridiculous extent in other projects -- I've actually been using it as an AST for various PEG grammars and DSLs. 😅

At the risk of bragging (but also to show "Hey, I really, really like using this spec!")
In an attempt to reduce dependencies from a personal project, I wrote a PEG grammar to convert Handlebars to JSON Logic, and I was surprised to discover that it performed nearly 13x faster when optimized through JSON Logic compared to the Handlebars compiler. I've also used it for other DSLs, like this silly testing DSL experiment.

I think it would be really cool to expand the ecosystem around JSON Logic, and help consolidate some of the projects and formalize the spec a bit more.

@TotalTechGeek
Copy link
Author

Elaborating a bit,

I believe the additions in JSON Logic Engine resolve these issues -
#48, #61, #82, #91, #97, #107, #111, #116, #124, #127, #130, #134, #135,

It also differs a bit and resolves some like -
#54, #128, somewhat on #99 (and my opinions have shifted a bit since my comments on there), #35 (Since you can specify what isData or use preserve)

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

No branches or pull requests

1 participant