Java or C# instead of Lua for mods, tradeoffs?

User avatar
Neuromancer
Member
 
Posts: 793
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

Java or C# instead of Lua for mods, tradeoffs?

by Neuromancer » Thu Jun 21, 2012 18:20

I'm just wondering about the tradeoffs of using Java or C# as a modding language vs. Lua. My impression is that Lua would perform less well because it isn't compiled. It seems like C# and Java are much more powerful languages and I know that C# 4.0 has now support to be a much more dynamic language. Granted you would have to then require deployment of the .NET or Java runtimes/frameworks with the mods. You would also have to compile your mod code. But wouldn't the performance and the power be worth it? Plus aren't there tons of devs out there who know Java & C#? For deployment, I'm thinking you could just dump a .NET .dll in a folder and it would work, with some tricks in the C++ code. I'm not saying Minetest should dump Lua, I'm just trying to understand why Lua is so popular for modding and Java and C# are not. Plus I'm thinking it would be much easier to debug Java or C# mods. Heck you could run n-Unit and j-Unit if you wanted to.

How hard would it be to make this possible?
Last edited by Neuromancer on Thu Jun 21, 2012 18:30, edited 1 time in total.
 

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

by xyz » Thu Jun 21, 2012 18:45

Neuromancer wrote:But wouldn't the performance and the power be worth it?

No
 

User avatar
Calinou
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou

by Calinou » Thu Jun 21, 2012 20:35

No, just no. Java and C# both suck.
 

cosarara97
Member
 
Posts: 180
Joined: Tue Nov 01, 2011 18:53

by cosarara97 » Thu Jun 21, 2012 21:45

Java is ok for mobile devices and that kind of thing, but not for game mods. C# is .NET, and .NET is an evil thing :)
:D
 

User avatar
Neuromancer
Member
 
Posts: 793
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

by Neuromancer » Thu Jun 21, 2012 21:47

Calinou wrote:No, just no. Java and C# both suck.

C'mon, it makes total sense to me to write games in C++ it performs well, a ton game developers know it, and cross platform is easy. I get that. But for a modding language, there are just so many more resources (training, open source libraries) out there for Java and C# than Lua. Developer productivity is really high in these languages. I just think it would be easy for people to write really powerful sophisticated mod's in Java and C# that would perform much better than Lua and be less buggy.

I want to know why you guys think Java & C# suck as a modding language. What's the downside? Like I said, I don't see anyone replacing lua in Minetest, but I'm just trying to understand the why of it.

When I first installed Minetest it really ran fast. Then I installed 4 mods (animals, nature_pack, farming, sethome) went running around the world for a few days, and suddenly the only thing that would render was a 30x30 area, with just huge chunks of un-rendered stuff that looked like sky. I would sit there for minutes and it wouldn't render. I had to redeploy minetest and I could put the mods back in and then everything rendered really quickly again. Something fishy going on, and I'm suspecting its the Lua, or maybe the mods are just dumping so many objects into the world that the lua can't handle keeping track of it all anymore.
Last edited by Neuromancer on Thu Jun 21, 2012 21:53, edited 1 time in total.
 

cosarara97
Member
 
Posts: 180
Joined: Tue Nov 01, 2011 18:53

by cosarara97 » Thu Jun 21, 2012 22:12

Adding lots of nodes in lua shouldn't slow down the game, but things like animals mod, in which lots of objects (entities?) are controlled are really slow.
:D
 

Switch5681
Member
 
Posts: 36
Joined: Sat Sep 24, 2011 03:28

by Switch5681 » Thu Jun 21, 2012 22:14

What about working with mono for Linux compatibity?
 

User avatar
Neuromancer
Member
 
Posts: 793
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

by Neuromancer » Thu Jun 21, 2012 23:48

cosarara97 wrote:Adding lots of nodes in lua shouldn't slow down the game, but things like animals mod, in which lots of objects (entities?) are controlled are really slow.


I think this might be proving my point. I haven't gotten Minecraft, so I don't know this for sure, but it handles all kinds of 3D entities/mobs creepers, pigs, sheep, etc, but because they are handled in Java, I'm guessing that they perform much better than the 2D Minetest animal mod because it is Lua. And so even though the Minetest engine is written in C++ it performs worse than Minecraft because the mobs are created in Lua rather than in Java. I hope this isn't the case :(
 

cosarara97
Member
 
Posts: 180
Joined: Tue Nov 01, 2011 18:53

by cosarara97 » Fri Jun 22, 2012 10:32

I think that if we wanted to make mods in a fast language it would be better to make them in C++, using shared objects like in some plugin systems.
Java is not really fast (my PC runs MC at 5 fps), and both Java and C# would mean a big amount of new dependencies needed by minetest. With java you'd need to install the java virtual machine, and for .NET you'd need .NET in windows and mono in Linux, and mods should run on both... so I think that if a new language were added to minetest it wouldn't be C# or Java.
:D
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Fri Jun 22, 2012 13:00

Java -> not easy to integrate in C++
C# -> Only Win
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
Neuromancer
Member
 
Posts: 793
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

by Neuromancer » Sat Jun 23, 2012 15:00

cosarara97 wrote:I think that if we wanted to make mods in a fast language it would be better to make them in C++, using shared objects like in some plugin systems.
Java is not really fast (my PC runs MC at 5 fps), and both Java and C# would mean a big amount of new dependencies needed by minetest. With java you'd need to install the java virtual machine, and for .NET you'd need .NET in windows and mono in Linux, and mods should run on both... so I think that if a new language were added to minetest it wouldn't be C# or Java.

I thought that C++ might be a good idea for mods too (because it would offer the best performance and integrate the easiest), but what made me dismiss it is that it has always been possible to write C++ code to modify Minetest, and yet hardly anyone ever did. It wasn't until celeron enabled modding with Lua that there was an explosion of contribution and mods to Minetest. My impression was the reason that happened is that Lua is much easier to learn than C++. I looked at Java & C# as dumbed down versions of C++ that were more accessible, you don't have to worry about pointers and the like. Still you do have to compile but I thought that building/compiling would be quicker and easier than in C++.

Here's the other thing, there is no shortage of people writing mods for Minecraft in Java, but that may just be because 6.3 million people own Minecraft, and so there are bound to be some folks in that group that can handle Java. Next to Minecraft, Minetest does have the most vibrant contributing user community, but it is orders of magnitude smaller. How many copies of Minetest have been downloaded? I've been curious about that. It's kind of amazing to see someone buy a copy of Minecraft every 5 seconds.
 

cosarara97
Member
 
Posts: 180
Joined: Tue Nov 01, 2011 18:53

by cosarara97 » Sat Jun 23, 2012 16:20

Neuromancer wrote:
cosarara97 wrote:I think that if we wanted to make mods in a fast language it would be better to make them in C++, using shared objects like in some plugin systems.
Java is not really fast (my PC runs MC at 5 fps), and both Java and C# would mean a big amount of new dependencies needed by minetest. With java you'd need to install the java virtual machine, and for .NET you'd need .NET in windows and mono in Linux, and mods should run on both... so I think that if a new language were added to minetest it wouldn't be C# or Java.

I thought that C++ might be a good idea for mods too (because it would offer the best performance and integrate the easiest), but what made me dismiss it is that it has always been possible to write C++ code to modify Minetest, and yet hardly anyone ever did. It wasn't until celeron enabled modding with Lua that there was an explosion of contribution and mods to Minetest. My impression was the reason that happened is that Lua is much easier to learn than C++. I looked at Java & C# as dumbed down versions of C++ that were more accessible, you don't have to worry about pointers and the like. Still you do have to compile but I thought that building/compiling would be quicker and easier than in C++.

Here's the other thing, there is no shortage of people writing mods for Minecraft in Java, but that may just be because 6.3 million people own Minecraft, and so there are bound to be some folks in that group that can handle Java. Next to Minecraft, Minetest does have the most vibrant contributing user community, but it is orders of magnitude smaller. How many copies of Minetest have been downloaded? I've been curious about that. It's kind of amazing to see someone buy a copy of Minecraft every 5 seconds.


Before the lua api there weren't mods, just patches you had to apply to the game, and you had to rebuild every time. I'm talking about using .so/.dll's as you do in, for example, pcsx for plugins.
:D
 

User avatar
Neuromancer
Member
 
Posts: 793
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

by Neuromancer » Sat Jun 23, 2012 17:08

cosarara97 wrote:Before the lua api there weren't mods, just patches you had to apply to the game, and you had to rebuild every time. I'm talking about using .so/.dll's as you do in, for example, pcsx for plugins.

You might be on to something. I think that it would be best to keep the ability to do mod's in Lua and just add the ability to also do c++ mods. That way for the folks who find c++ too difficult, they could keep writing mods in Lua, and all the code that has already been created won't be lost, but then for those who can do c++ they could write mods that performed better than the Lua mods.

Is there any reason why this would be a bad idea?
 

neo
Member
 
Posts: 56
Joined: Fri Jun 15, 2012 07:50

by neo » Sat Jun 23, 2012 22:53

very interesting.

Any way to code a mod in the 2 formats and bench them ?

i've already cut-off the animal pack from my test-platform, but i've also seen strange behavior of the engine with the nature mod.

i don't coding, so i don't understand if it come from the coding language or the code itself.

But this thread is very interresting. imao.
 

hijera
Member
 
Posts: 36
Joined: Sun Jun 19, 2011 13:04

by hijera » Sun Jun 24, 2012 09:09

maybe better use LuaJIT, which will compile lua to bytecode?
 

User avatar
Neuromancer
Member
 
Posts: 793
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

by Neuromancer » Sun Jun 24, 2012 16:08

hijera wrote:maybe better use LuaJIT, which will compile lua to bytecode?

Holy %#&^$!

This could really boost performance of lua mods!
http://luajit.org/performance_x86.html

"LuaJIT is API-compatible with Lua 5.1. If you've already embedded Lua into your application, you probably don't need to do anything to switch to LuaJIT, except link with a different library:"
So is this saying that Minetest c++ would need a minor tweak to make this happen?

"LuaJIT offers more performance, at the expense of portability. It currently runs on all popular operating systems based on x86 or x64 CPUs (Linux, Windows, OSX etc.) or embedded systems based on ARM (Android, iOS), PPC or MIPS CPUs. Other platforms will be supported in the future, based on user demand and sponsoring."
Would Minetest lose any portability by doing this? (I'm thinking like maybe game consoles)
 

jpenguin
Member
 
Posts: 46
Joined: Wed Jun 06, 2012 00:19

by jpenguin » Sun Jun 24, 2012 18:26

ell, let's think about this...

I don't ever see this getting on the big 3 (xBox 360, PS3, Wii) -but I think those are all PPC-based

The GP32X is some custom Samsung CPU

OpenPandora- ARM® Cortex™-A8 superscalar microprocessor core

The EVO linux consol (don't know if it's even around anymore) used an AMD 64 CPU
 

neo
Member
 
Posts: 56
Joined: Fri Jun 15, 2012 07:50

by neo » Sun Jun 24, 2012 18:29

where is the bad side-effect precisely ?
 

jpenguin
Member
 
Posts: 46
Joined: Wed Jun 06, 2012 00:19

by jpenguin » Sun Jun 24, 2012 18:38

This is an interesting console

http://www.envizionsinc.com/evo2.html

I hope we never use C#!
Last edited by jpenguin on Sun Jun 24, 2012 18:40, edited 1 time in total.
 

User avatar
monty_oso
Member
 
Posts: 44
Joined: Wed Jun 20, 2012 05:44

by monty_oso » Tue Jun 26, 2012 01:40

Neuromancer wrote:
hijera wrote:maybe better use LuaJIT, which will compile lua to bytecode?

Holy %#&^$!

This could really boost performance of lua mods!
http://luajit.org/performance_x86.html

"LuaJIT is API-compatible with Lua 5.1. If you've already embedded Lua into your application, you probably don't need to do anything to switch to LuaJIT, except link with a different library:"
So is this saying that Minetest c++ would need a minor tweak to make this happen?

"LuaJIT offers more performance, at the expense of portability. It currently runs on all popular operating systems based on x86 or x64 CPUs (Linux, Windows, OSX etc.) or embedded systems based on ARM (Android, iOS), PPC or MIPS CPUs. Other platforms will be supported in the future, based on user demand and sponsoring."
Would Minetest lose any portability by doing this? (I'm thinking like maybe game consoles)


This makes sense.
My English sucks very hard (TM).
I'm very interesting in mesecons stuff.
 

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

by xyz » Tue Jun 26, 2012 09:39

Neuromancer wrote:
hijera wrote:maybe better use LuaJIT, which will compile lua to bytecode?

Holy %#&^$!

This could really boost performance of lua mods!
http://luajit.org/performance_x86.html

"LuaJIT is API-compatible with Lua 5.1. If you've already embedded Lua into your application, you probably don't need to do anything to switch to LuaJIT, except link with a different library:"
So is this saying that Minetest c++ would need a minor tweak to make this happen?

"LuaJIT offers more performance, at the expense of portability. It currently runs on all popular operating systems based on x86 or x64 CPUs (Linux, Windows, OSX etc.) or embedded systems based on ARM (Android, iOS), PPC or MIPS CPUs. Other platforms will be supported in the future, based on user demand and sponsoring."
Would Minetest lose any portability by doing this? (I'm thinking like maybe game consoles)

Some random links — lua 1 2, luajit 1

Somebody care to test that? For me (as you can see) it just slows everything down.
 

neo
Member
 
Posts: 56
Joined: Fri Jun 15, 2012 07:50

by neo » Tue Jun 26, 2012 18:36

walkthrought ? : )
 

User avatar
Neuromancer
Member
 
Posts: 793
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

by Neuromancer » Wed Jun 27, 2012 14:47

xyz wrote:
Neuromancer wrote:
hijera wrote:maybe better use LuaJIT, which will compile lua to bytecode?

Holy %#&^$!

This could really boost performance of lua mods!
http://luajit.org/performance_x86.html

"LuaJIT is API-compatible with Lua 5.1. If you've already embedded Lua into your application, you probably don't need to do anything to switch to LuaJIT, except link with a different library:"
So is this saying that Minetest c++ would need a minor tweak to make this happen?

"LuaJIT offers more performance, at the expense of portability. It currently runs on all popular operating systems based on x86 or x64 CPUs (Linux, Windows, OSX etc.) or embedded systems based on ARM (Android, iOS), PPC or MIPS CPUs. Other platforms will be supported in the future, based on user demand and sponsoring."
Would Minetest lose any portability by doing this? (I'm thinking like maybe game consoles)

Some random links — lua 1 2, luajit 1

Somebody care to test that? For me (as you can see) it just slows everything down.


That's really unfortunate. I read somewhere that it might be the communication between Lua and C++ that can cause performance problems with LuaJit. I think you have proved that getting LuaJit to work with Minetest is more grief that what it is worth. Adding the ability to use C++ to create mods and keeping the ability to continue to do Lua mods is probably the best way to go. C++ mods would perform much better than LuaJit even if it had worked as claimed. Thanks for taking the time to do the performance analysis. It was worth a shot.
Last edited by Neuromancer on Wed Jun 27, 2012 14:49, edited 1 time in total.
 

neo
Member
 
Posts: 56
Joined: Fri Jun 15, 2012 07:50

by neo » Wed Jun 27, 2012 18:01

Have we got an example of mod to compare between lua and c++ version ?
 

hijera
Member
 
Posts: 36
Joined: Sun Jun 19, 2011 13:04

by hijera » Wed Jun 27, 2012 20:11

Neuromancer wrote:
That's really unfortunate. I read somewhere that it might be the communication between Lua and C++ that can cause performance problems with LuaJit. I think you have proved that getting LuaJit to work with Minetest is more grief that what it is worth. Adding the ability to use C++ to create mods and keeping the ability to continue to do Lua mods is probably the best way to go. C++ mods would perform much better than LuaJit even if it had worked as claimed. Thanks for taking the time to do the performance analysis. It was worth a shot.

maybe http://en.wikipedia.org/wiki/Squirrel_(programming_language) ? It's like c++ and has a jit compiler
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 59 guests

cron