3 ms·
I kind of expected to see QuickJS or Duktape here; if the author considers ‘something like javascript-ey’ to be just fine, he might as well have used JavaScript
by pwdisswordfish8 5y ago
I kind of expected to see QuickJS or Duktape here; if the author considers ‘something like javascript-ey’ to be just fine, he might as well have used JavaScript itself, with all its strengths and faults.
- germandiago 5y agoWell. I think I was a bit inaccurate. When I said javascript-ey what I meant is also familiar. Something like Squirrel and Wren do a good job. The ones you mentioned, as far as I investigated, were not dead-easy to integrate into C++, one of the top requirements. Take into account that I have to expose my own types, not just ints and basic types. The original API was coded in a natural C++ way. APIs that wrap well in that sense could be Sol2 for Lua, Chaiscript, Wrenbind... which integrate with custom types and smart pointers. With other scripting languages and their libraries you need additional work
- pwdisswordfish8 5y agoDuktape’s host API is pretty much a ripoff of Lua’s, and the latter wasn’t rejected on those grounds, so… QuickJS’s API isn’t particularly well-documented, but it’s not hard to find your way around it either if you dig into the source (the engine is very hackable, too; you might even fix some of the language’s design flaws – obligatory wat talk reference – if you’re so inclined). The host API follows the CPython model, with objects represented by pointers and explicit reference counting on the C side. There are some predefined macros to ease defining built-in classes. Some type-level hackery in C++ might ease things even further. I don’t know how much deader-easier you want it.
- germandiago 5y agoTake a look at how pybind11, wrenbind17, sol2 or Chaiscript do it. That is how easy I want it: I can expose custom types and global state easily. I do not want just ints and const char */double. These bindings do from decent to great.