Page 1 of 2

Build Love with Ruby instead of Lua

Posted: Sat Apr 25, 2020 8:20 am
by Nightrains
Someone who knows how Love's source works so that instead of running Lua scripts, run Ruby, As far as I think I know, Love is written in C, and from C it compiles Lua and runs it (I think), I don't think I need to get rid of Lua completely, just add Ruby support. I need ideas or some explanation of how I can achieve this.

I have already seen the Love source code and I also know how to build it, my idea so far is to implement the Ruby interpreter and replace some functions of the Lua interpreter with Ruby.

Or maybe execute Ruby from Love without needing to recompile it?

I want to use Ruby in Love because it seems as simple as Lua and it has many similarities, but with more functions, such as classes for example. (And many other reasons)

Re: Build Love with Ruby instead of Lua

Posted: Sat Apr 25, 2020 2:41 pm
by Varkas
Good luck! While it certainly is possible to create all the library bindings for Ruby which Love2d offers for Lua, I don't understand the motivation except that someone likes Ruby more than Lua?

You can have something like classes in Lua if you want to. "Ruby has classes" is not a very strong argument against Lua.

Re: Build Love with Ruby instead of Lua

Posted: Sat Apr 25, 2020 3:25 pm
by Nightrains
Varkas wrote: Sat Apr 25, 2020 2:41 pm Good luck! While it certainly is possible to create all the library bindings for Ruby which Love2d offers for Lua, I don't understand the motivation except that someone likes Ruby more than Lua?

You can have something like classes in Lua if you want to. "Ruby has classes" is not a very strong argument against Lua.
It is not only that, I want to dedicate myself to creating a game with Love but I need a really good good language for that (Create games), Ruby is one of those, but Lua is a Language although fast and light, very basic.

Re: Build Love with Ruby instead of Lua

Posted: Sat Apr 25, 2020 3:34 pm
by Xugro
You could use something like RLua which bind Lua und Ruby together:
RLua is Ruby to Lua bindings library that features nearly complete coverage of Lua C API, seamless translation of Lua and Ruby objects into each other, calling Lua functions from Ruby and vice versa.

Re: Build Love with Ruby instead of Lua

Posted: Sat Apr 25, 2020 4:12 pm
by Nightrains
Xugro wrote: Sat Apr 25, 2020 3:34 pm You could use something like RLua which bind Lua und Ruby together:
RLua is Ruby to Lua bindings library that features nearly complete coverage of Lua C API, seamless translation of Lua and Ruby objects into each other, calling Lua functions from Ruby and vice versa.
You know how to use it? I am searching but I don't know if it could be run directly from Lua, otherwise it is not possible.

Re: Build Love with Ruby instead of Lua

Posted: Sat Apr 25, 2020 5:27 pm
by MrFariator
Besides classes (which can be done with lua) what do you need that lua doesn't offer but ruby does?

Re: Build Love with Ruby instead of Lua

Posted: Sat Apr 25, 2020 8:05 pm
by Nightrains
MrFariator wrote: Sat Apr 25, 2020 5:27 pm Besides classes (which can be done with lua) what do you need that lua doesn't offer but ruby does?
I have used Lua for a long time, I want to use something new, but still using Love, and what I would like to try is Ruby or Python, but right now I only want to be able to use Ruby.

Ruby in addition to classes has a more elegant and simple syntax, but similar to that of Lua, switch cases, operators like +=, -=, etc.

Re: Build Love with Ruby instead of Lua

Posted: Sat Apr 25, 2020 11:28 pm
by sphyrth
MrFariator wrote: Sat Apr 25, 2020 5:27 pm Besides classes (which can be done with lua) what do you need that lua doesn't offer but ruby does?
Ruby can do this:

Code: Select all

1:destroy_number(2)

Code: Select all

false:become_true()
I consider that Ruby's "Everything is a class... even variables" to be the it's most powerful attribute as a Programming Language. I don't know about other languages using this principle, but Ruby introduced me to such a beautiful concept.

Re: Build Love with Ruby instead of Lua

Posted: Sun Apr 26, 2020 12:44 am
by zorg
And lua's concept may very well be: "you only need tables as /the/ aggregate type" and i'm sure others can list similar whimsical one-liners for other languages like perl or whatever. :3

So, Löve is written in C++, and it uses LuaJIT by default to execute lua code as fast as if it were near native C code. It does not use the PuC or any other lua interpreters by default. If you do manage to recompile it somehow with a Ruby interpreter instead of LuaJIT, you will feel the godawful slowdown that will result in.

Lua's a good enough language for doing anything in it, like any other; the list of commercially released Löve games on steam is a telling supportive argument to that.
And you can implement classes in lua, there's already like 50 implementations. Along with literally anything else. Lua is basic, yes, but also flexible.






That said, if you really want to write a ruby interpreter, whether to replace LuaJIT or even just in lua, that's up to you and is in fact a more gargantuan task than if you just started coding your game at this moment. :monocle:

Re: Build Love with Ruby instead of Lua

Posted: Sun Apr 26, 2020 1:18 am
by MrFariator
sphyrth wrote: Sat Apr 25, 2020 11:28 pm I consider that Ruby's "Everything is a class... even variables" to be the it's most powerful attribute as a Programming Language. I don't know about other languages using this principle, but Ruby introduced me to such a beautiful concept.
I am aware of this quirk of ruby's, and it's an interesting one. It's not too dissimilar from lua's table shenanigans, just taken a step further ahead.
Nightrains wrote: Sat Apr 25, 2020 8:05 pm I have used Lua for a long time, I want to use something new, but still using Love, and what I would like to try is Ruby or Python, but right now I only want to be able to use Ruby.
I was wondering if there was something about ruby that made you want to use it over lua, and I guess I can't fault you for wanting to learn something new. You were curious about the how, while I was simply curious about the why.

Instead of cramming either ruby or python into löve though, I'd instead rather suggest looking into libraries or frameworks specifically made for either of those two languages. I'm not sure if ruby has its equivalent of löve (in terms of available features and maturity), but even a simple framework would at least allow you start writing a game now rather than later.