can we go back to c++

Post Reply
User avatar
stormchaser3000
Member
Posts: 422
Joined: Sun Oct 06, 2013 21:02
GitHub: stormchaser3000

can we go back to c++

by stormchaser3000 » Post

i had an idea. we may be able to boost the speed of the game if we went back to having all the nodes and items for he default minetest_game mods recoded in c++ and put into the main engine. and if this is posibl can we keep the modding api in so we can still mod the game.
Last edited by stormchaser3000 on Sat Jan 04, 2014 14:48, edited 1 time in total.

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

Doesn't make much difference, other than loading times.

The only thing that slows the code down is the transition from C(++) to Lua (and back) and the Lua execution speed.

Say there is a mod called Foo. This mod only adds nodes to the game, and a few tools. No abms, no global ticks, no on_punch functions. Once the mod is loaded, the lua code will never be called again. The items in the mod are added to a c(++) table, so there is no need to go to the lua code.

However, when you add abms and global ticks, this all changes.

A year ago I made a finite liquid mod in Lua. It runs okay, but it was too slow to convert all the sea into finite liquid. This is because it is constantly running abms.

Then proller made the C(++) patch version. While it technically still uses abms, they are c(++) abms, so the transfer to lua is never made.

Minetest_game does not have any content in it that is too heavy for lua, and slows it down too much. It does not have many abms. The sort of things that might be useful having in c(++) is:
  • Mobs
  • Projectiles, entities
  • Anything that uses tons of abms and global ticks
  • Mapgen (although less important now, with voxelmanip)

So in conclusion: there is no need to transfer blocks in to c(++) code from lua; there would be no speed benefit. However transferring abms and global ticks would give a speed benefit.

Note: that I wrote c(++) rather than c++, as quite a lot of the code is in c style.
Note2: If I am wrong, please correct me :P
Last edited by rubenwardy on Sat Jan 04, 2014 20:17, edited 1 time in total.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
aldobr
Member
Posts: 316
Joined: Sun Nov 25, 2012 05:46

by aldobr » Post

what could be done is a binary modding api, making the lua interpreter one module of said api and allowing people to mod using any language...

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

aldobr wrote:what could be done is a binary modding api, making the lua interpreter one module of said api and allowing people to mod using any language...
Meh.

Maybe add a way to add C(++) .dll to the mod folder.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
xyz
Member
Posts: 450
Joined: Thu Nov 10, 2011 14:25

by xyz » Post

aldobr wrote:what could be done is a binary modding api, making the lua interpreter one module of said api and allowing people to mod using any language...
http://luajit.org/ext_ffi_tutorial.html

Notice: I was told that this is very slow. Don't use it and disregard this post.

User avatar
aldobr
Member
Posts: 316
Joined: Sun Nov 25, 2012 05:46

by aldobr » Post

its only slow when jumping from C to Lua and back (its slower if c calling lua).

but its pretty strange to have a wrapper in lua to call code in C++ for example...

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests