top | item 28082632

(no title)

lasagnaphil | 4 years ago

A question: would it be too much work to port Love2D to a different embedding language? (I'm currently having looks at Squirrel (http://www.squirrel-lang.org/) I always thought Lua was tightly coupled with the framework, but what you've mentioned seems to imply that's not the case.

discuss

order

nonbirithm|4 years ago

Having attempted this myself, the answer is "a lot of work." Even with the classes and bindings separated, there is still a lot of C++ code used in the binding layer, and some of the C++ code is tightly coupled to Lua data structures. If a transition to a C API were to be made, that C++ code has to be put behind a corresponding C wrapper, so basically opaque pointer types to all those classes and functions/methods have to be wrapped to fully support using LOVE as a standalone library.

I still think that a C API would be a better option than trying to fork the project to replace Lua with Squirrel or some other language, so that at least others can have a chance to write bindings for their favorite languages without having to do all the porting work again.

Here is the tracking issue: https://github.com/love2d/love/issues/1640

nikki93|4 years ago

I don't think it's "too much work" if you really need it or are really interested in doing so and the approach results in incremental benefit vs. one big blob of benefit at the end. It would be quite a bit of work and not super automatic, probably. You have to implement all the files named 'wrap_*' in the Love codebase, kind of. It's definitely possible to start working on a game project to test with and do it incrementally, which is probably strategically the best path and also fun, which can make it worth it. Something like:

- Get direct Love C++ project working without Lua

- Make some level of test cases with it to get a sense of C++ API usage

- Embed squirrel interpreter into test

- Start binding API to squirrel and testing more and more of API incrementally from squirrel

- Port more and more test cases till it's all covered (or prioritize based on need of game(s))

The nature of the thing you are increasingly covering in Squirrel could be a particular game or a set of demos (maybe both).