Page 1 of 1

Love in C++

Posted: Sun Mar 27, 2016 2:03 pm
by ZacGarby
I noticed that Love was written in C++. Is there a way to make games in Love using C++?

Re: Love in C++

Posted: Sun Mar 27, 2016 2:38 pm
by anastasiaorosegirl
I'm pretty sure that since C++ is a superset of C, I think it's definetely possible for you to use C++ in the engine. Now, can you use all of C++? I'm not sure; honestly the last time I checked, you had to do a work around to get it to work ( though this may have been for the Source Engine and may not be indicative of LÖVE ). Now, I am aware there is a snippet called the "psi2love" that converts .psi files that creates Lua source code for it, but that's more of a transcompiler than an outright example of LÖVE using C++.

Honestly though, there's kind of not a point to it unless you are doing something low level which requires the use of C++ like messing with the OS or working with low level OpenGL. Even then, there's really no need for it; LÖVE is a bit more lighter than most engines and you're just better off using Lua. Lua is a very simple language to understand and has a small footprint in general. I'm also not sure of overhead problems or anything like that so you're mostly on your own on figuring this stuff out. I guess in short, probably? Though, not a good idea in my honest opinion.

Re: Love in C++

Posted: Sun Mar 27, 2016 4:26 pm
by Tanner
Yeah, the build process outputs a liblove library that you can link against.

Re: Love in C++

Posted: Sun Mar 27, 2016 4:30 pm
by slime
There's a bit of discussion about that here: https://bitbucket.org/rude/love/issues/ ... -c-library

Re: Love in C++

Posted: Sun Mar 27, 2016 4:36 pm
by anastasiaorosegirl
slime wrote:There's a bit of discussion about that here: https://bitbucket.org/rude/love/issues/ ... -c-library

So, to paraphrase: "Yes but no"? I mean, it's an interesting proof-of-concept but I doubt it's exactly the best course of action. Definitely, however, something cool to try out ( and according to the post, it has ).

Re: Love in C++

Posted: Sun Mar 27, 2016 6:45 pm
by marco.lizza
ZacGarby wrote:I noticed that Love was written in C++. Is there a way to make games in Love using C++?
What the point would be?

I mean, if I'm going to write a game in C++ I will probably use a scripting language (Lua?) and a graphic library (SDL?) which is pretty much what LOVE does... but I will also end in definining my entry-point and peculiar features that goes beyond a general-purpose framework such as LOVE and code a custom game-engine.

Re: Love in C++

Posted: Mon Mar 28, 2016 1:24 pm
by ZacGarby
marco.lizza wrote: What the point would be?
The point would be so it's easier to do classes.

Re: Love in C++

Posted: Mon Mar 28, 2016 2:38 pm
by ivan
Zac, once you move to C/C++ it's a whole different ballgame.
- No more quick prototyping - you have to rebuild every time you make a minor change.
- No cross platform support unless you provide a build for each target platform.
- No more automatic memory management and no garbage collection
- No more nice Lua error messages, your program will crash in much nastier ways.
- Programming your game logic in C/C++ will be harder and more complicated.
- No longer a clear separation between your game logic from the engine.

C/C++ has a lot of cool libraries, but then you might as well export the functionality you need via something like FFI.
The only good reason IMO to move to C/C++ would be if you want to render things in a vastly different way than Love2D.

Re: Love in C++

Posted: Mon Mar 28, 2016 7:26 pm
by marco.lizza
ZacGarby wrote:The point would be so it's easier to do classes.
That's odd. Although Lua does not support classes right out-of-the-box, I don't feel this to be something that important. Complex class hierarchies is something far too over-hyped in the programming scene. Composition is a far better approach (which is something we already used back in the days when programming in assembly), and Lua is perfect for this.

I do write my own C++ game-engines, but LOVE fast-and-easy prototyping is something that makes me not to regret avoiding to use C/C++ for my (smaller) projects.

Re: Love in C++

Posted: Mon Mar 28, 2016 10:50 pm
by zorg
Besides, if the only reason you want to code with löve in c++ is that c++ has classes, then that's kind of a bad reason. lua (and by proxy, löve) has more than enough libraries that implement classes in similar (or maybe even better?) ways.

If you know that you want to do something that lua would be slow to do, or could not do, then there's always LuaJIT's FFI, from which you can define C-like stuff (but not C++, though someone did try to implement a C++ FFI as well, it's somewhere on github), including code, and execute it. In that direction, it's fast.

*Magical Crosspost Edit*: This might be of some use, even if it only serves as placebo :3