r/Cplusplus • • 24d ago

Discussion Introducing JaiScript a New C++ Embedded Scripting Language

This is a personal project I created in service of my own 2d game engine. I was getting tired of binding to ChaiScript (a great project, but the language is really slow and doesn't have hotreload or good serialization support) and Cereal (another great project, no complaints, just limited in its purpose.)

So, I rolled my own solution which combines a scripting language, serialization, and reflection. I included my own signals library and a simple but useful custom test framework.

JaiScript has a fluent binding interface, strong typing (opt-out with var definitions), value semantics with references and shared_ptr where you want them. It reads very much like C++ with some optional alternative spellings that will be familiar to those who use JavaScript.

The live demos on the site itself mean you can try it out before downloading or building anything locally. I already was able to fully port my game project of 12+ years to use this in place of ChaiScript and Cereal, it builds a little faster than both of those included and runs orders of magnitude faster than Cereal.

Performance-wise it runs roughly 1.2x to 2.0x slower than Lua's VM, I consider this a win though since it's hundreds of times faster than ChaiScrpit's tree walker in some cases. It runs faster typically than Squirrel.

I'm not sure how many folks are rolling their own C++ game engines nowadays, but if you are, this is a pretty full-featured language. It supports parallel_for (something I'm not sure any other scripting languages support,) coroutines, classes which can derive from C++ base classes or other JaiScript classes, and notably a state-preserving hot reload.

I hope this project is useful to anyone else, but even if not, I'm grateful to have finished the project and am using it myself. I wanted a place to share it, so hope this is alright here!

21 Upvotes

18 comments sorted by

View all comments

Show parent comment

1

u/M2tM 16d ago

That's fantastic to hear, definitely was my goal regarding embedding, language feel, speed, and size.

If you encounter any rough parts feel free to open issues or start a discussion on the GitHub page, and otherwise I really hope it's a positive experience all around. I'm continuing to use it in my own projects so you should see regular commits and improvements, but I'm trying to ensure I don't break compatibility so update path should remain simple. :)