Python as a modding language

Would python scripts be a good addition to the modding world of Minetest

yes
35
53%
no
26
39%
whats Python
4
6%
indecisive
1
2%
 
Total votes: 66

User avatar
ThomasMonroe
Member
Posts: 286
Joined: Tue Apr 04, 2017 16:21
GitHub: ThomasMonroe314
IRC: ThomasMonroe TMcSquared
In-game: ThomasMonroe TMcSquared
Location: Wherever I am at

Python as a modding language

by ThomasMonroe » Post

in looking through lua, i found alot of similarities between it and python, aside from the fact that python can do object oriented stuff and lua cant.
also python has C bindings, like lua
so ingetrating it would be just as easy as lua.
i think that if Python were added as an extension(like lua), the quality of the mods coming out would be a whole lot better bcs of the ability of creating object oriented scripts.
What do you guys think, please post and vote. :)
I don't make messes, I just, er...disturb the local entropy!

User avatar
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

Re: Python as a modding language

by Sergey » Post

I vote for Python. Great language! I like it very much. Python scripts can be executed as is, by interpreter or being embedded like in many other software (including proprietary).

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Python as a modding language

by burli » Post

I like python, but it would take a long time to add a scripting API to Minetest and I don't think that this worth it. Python is slow, compared to LuaJIT.

So even if 100 people vote for yes I think it won't happen because we don't have 100 developers to implement this.

Better to learn Lua. It's not a bad and hard to learn 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:

Re: Python as a modding language

by rubenwardy » Post

Lua can do object oriented stuff
It just uses a prototype paradigm rather than a class paradigm - which isn't any less valid

Also, Python isn't a very good scripting language due to its architecture. Whilst it can be embedded, It's not designed to be embedded like Lua is. It would be better to make python call Minetest, and then do all the mod loading itself - but this will never happen
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
ThomasMonroe
Member
Posts: 286
Joined: Tue Apr 04, 2017 16:21
GitHub: ThomasMonroe314
IRC: ThomasMonroe TMcSquared
In-game: ThomasMonroe TMcSquared
Location: Wherever I am at

Re: Python as a modding language

by ThomasMonroe » Post

all of you guys are right, i just had an idea thats all
I don't make messes, I just, er...disturb the local entropy!

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Python as a modding language

by burli » Post

I have concerns about the performance of OOP in Lua. I think it won't be as fast as a procedural approach (but it will still be magnitudes faster than Python)

If I have time I will make some experiments

User avatar
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

Re: Python as a modding language

by Sergey » Post

I regret. I hoped MT will use Python in future.
:-(

User avatar
ThomasMonroe
Member
Posts: 286
Joined: Tue Apr 04, 2017 16:21
GitHub: ThomasMonroe314
IRC: ThomasMonroe TMcSquared
In-game: ThomasMonroe TMcSquared
Location: Wherever I am at

Re: Python as a modding language

by ThomasMonroe » Post

same here Sergey, same here :-(
I don't make messes, I just, er...disturb the local entropy!

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Python as a modding language

by burli » Post

I want to show you why python will never be added to Minetest. I made a really simple test

a simple python loop with sinus needs on my PC 42 seconds

Code: Select all

import math

for i in range(1,100000000):
	x = math.sin(i)
	y = math.cos(x)
	if x == y:
		x = 0
the same loop in lua needs ~ 15 seconds

Code: Select all

local sin = math.sin
local cos = math.cos
for i = 1, 100000000 do
	local x = sin(i)
	local y = cos(x)
	if x == y then
		x = 0
	end
end

But if I run this code with LuaJIT it needs just 8 seconds

User avatar
ThomasMonroe
Member
Posts: 286
Joined: Tue Apr 04, 2017 16:21
GitHub: ThomasMonroe314
IRC: ThomasMonroe TMcSquared
In-game: ThomasMonroe TMcSquared
Location: Wherever I am at

Re: Python as a modding language

by ThomasMonroe » Post

wow, i didnt know the diff would be that much
I don't make messes, I just, er...disturb the local entropy!

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Python as a modding language

by burli » Post

ThomasMonroe wrote:wow, i didnt know the diff would be that much
And I think it is more with "normal" functions because in this example most time is spend in the math functions

I randomly picked fannkuch-redux from this benchmark and run it with Lua, LuaJIT and Python3 on an AMD FX6300 hexacore CPU.

The Lua code runs on a single core, the Python code uses all 6 cores

This is the output from normal lua. I add a function to measure the runtime. The last number is the time in seconds

Code: Select all

markus@morpheus:~/dev/lua$ lua fannkuch-redux.lua 12
3968050
Pfannkuchen(12) = 65
1363.03
This is the output of the python version. As you can see on the screenshot it really uses all 6 cores.

Code: Select all

markus@morpheus:~/dev/lua$ python3 fannkuch-redux.py 12
3968050
Pfannkuchen(12) = 65
373.94084000587463
And this is the output of LuaJIT
Spoiler

Code: Select all

markus@morpheus:~/dev/lua$ luajit fannkuch-redux.lua 12
3968050
Pfannkuchen(12) = 65
99.183862
If you divide the Lua time of 1363 by 6 you get the time a multicore version of Lua would need. And now divide the LuaJIT time by 6...

Any questions?
Attachments
Bildschirmfoto vom 2017-04-13 22-42-40.png
Bildschirmfoto vom 2017-04-13 22-42-40.png (178.35 KiB) Viewed 1387 times

User avatar
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

Re: Python as a modding language

by Sergey » Post

Lua is very narrow-specilized — to embed in other software, and therefore it is not standalone. (well, I read it can be standalone, but it is not its purpose). While Python is general purpose language that can do anything with very-very rich included library. And it can be embeddable as well. Python is always in Top-5 of most popular languages, while Lua is... 26 according to TIOBE ratings.
Last edited by Sergey on Fri Apr 14, 2017 19:46, edited 1 time in total.

User avatar
ThomasMonroe
Member
Posts: 286
Joined: Tue Apr 04, 2017 16:21
GitHub: ThomasMonroe314
IRC: ThomasMonroe TMcSquared
In-game: ThomasMonroe TMcSquared
Location: Wherever I am at

Re: Python as a modding language

by ThomasMonroe » Post

i think the question we need to ask is what type of computer are we saying is the average:
because if you are using a single or dual core computer lua is great, but once you get into the higher cores, python can really take the lead bcs it can maximize the use of all the cores.
I don't make messes, I just, er...disturb the local entropy!

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Python as a modding language

by burli » Post

Did you open the spoiler?

User avatar
ThomasMonroe
Member
Posts: 286
Joined: Tue Apr 04, 2017 16:21
GitHub: ThomasMonroe314
IRC: ThomasMonroe TMcSquared
In-game: ThomasMonroe TMcSquared
Location: Wherever I am at

Re: Python as a modding language

by ThomasMonroe » Post

nvmd i read it wrong
I don't make messes, I just, er...disturb the local entropy!

User avatar
xeranas
Member
Posts: 162
Joined: Fri Feb 05, 2016 11:06

Re: Python as a modding language

by xeranas » Post

Performance isn't everything. You need feel passionate about language also. It's expecially true for open source projects. According recently published stack overflow survey lua was neither popular neither wanted. Personally I do dislike lua myself, feels limited and ugly language.

User avatar
ThomasMonroe
Member
Posts: 286
Joined: Tue Apr 04, 2017 16:21
GitHub: ThomasMonroe314
IRC: ThomasMonroe TMcSquared
In-game: ThomasMonroe TMcSquared
Location: Wherever I am at

Re: Python as a modding language

by ThomasMonroe » Post

burli wrote:
ThomasMonroe wrote:wow, i didnt know the diff would be that much
And I think it is more with "normal" functions because in this example most time is spend in the math functions

I randomly picked fannkuch-redux from this benchmark and run it with Lua, LuaJIT and Python3 on an AMD FX6300 hexacore CPU.

The Lua code runs on a single core, the Python code uses all 6 cores

This is the output from normal lua. I add a function to measure the runtime. The last number is the time in seconds

Code: Select all

markus@morpheus:~/dev/lua$ lua fannkuch-redux.lua 12
3968050
Pfannkuchen(12) = 65
1363.03
This is the output of the python version. As you can see on the screenshot it really uses all 6 cores.

Code: Select all

markus@morpheus:~/dev/lua$ python3 fannkuch-redux.py 12
3968050
Pfannkuchen(12) = 65
373.94084000587463
And this is the output of LuaJIT
Spoiler

Code: Select all

markus@morpheus:~/dev/lua$ luajit fannkuch-redux.lua 12
3968050
Pfannkuchen(12) = 65
99.183862
If you divide the Lua time of 1363 by 6 you get the time a multicore version of Lua would need. And now divide the LuaJIT time by 6...

Any questions?

you also have to take into account that lua is not a very extensive language, python is.
and the reason for that is this:
Sergey wrote:Lua is very narrow-specilized — to embed in other software, and therefore it is not standalone. (well, I read it can be standalone, but it is not its purpose). While Python is general purpose language that can do anything with very-very rich included library. And it can be embeddable as well. Python is always in Top-5 of most popular languages, while Lua is... 26 according to TIOBE ratings.
and this:
xeranas wrote:Performance isn't everything. You need feel passionate about language also. It's expecially true for open source projects. According recently published stack overflow survey lua was neither popular neither wanted. Personally I do dislike lua myself, feels limited and ugly language.
I don't make messes, I just, er...disturb the local entropy!

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Python as a modding language

by burli » Post

You can write desktop apps in Lua, you can write webapps in Lua...

But for game modding is Lua the best choice

User avatar
ThomasMonroe
Member
Posts: 286
Joined: Tue Apr 04, 2017 16:21
GitHub: ThomasMonroe314
IRC: ThomasMonroe TMcSquared
In-game: ThomasMonroe TMcSquared
Location: Wherever I am at

Re: Python as a modding language

by ThomasMonroe » Post

i have no doubt that lua is not great, but python is more popular of a language.
and those facts doesnt mean that python would not be bad for modding
I don't make messes, I just, er...disturb the local entropy!

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Python as a modding language

by burli » Post

You can use it for simple things. But for simple things you don't need a language like python. And for things where performance is important python is useless because it is to slow

I can't imagine a single usecase where python has an advantage over lua as scripting language in Minetest

User avatar
ThomasMonroe
Member
Posts: 286
Joined: Tue Apr 04, 2017 16:21
GitHub: ThomasMonroe314
IRC: ThomasMonroe TMcSquared
In-game: ThomasMonroe TMcSquared
Location: Wherever I am at

Re: Python as a modding language

by ThomasMonroe » Post

maybe a bigger mod like mesecons, one that has a big amount of computation
I don't make messes, I just, er...disturb the local entropy!

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Python as a modding language

by Byakuren » Post

Since we're talking about this we should have support for some easily-embedded flavor of Scheme.
Every time a mod API is left undocumented, a koala dies.

User avatar
ThomasMonroe
Member
Posts: 286
Joined: Tue Apr 04, 2017 16:21
GitHub: ThomasMonroe314
IRC: ThomasMonroe TMcSquared
In-game: ThomasMonroe TMcSquared
Location: Wherever I am at

Re: Python as a modding language

by ThomasMonroe » Post

what is Scheme?
I don't make messes, I just, er...disturb the local entropy!

User avatar
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

Re: Python as a modding language

by Sergey » Post

ThomasMonroe wrote:what is Scheme?
I think that's what he is talking about.

User avatar
ThomasMonroe
Member
Posts: 286
Joined: Tue Apr 04, 2017 16:21
GitHub: ThomasMonroe314
IRC: ThomasMonroe TMcSquared
In-game: ThomasMonroe TMcSquared
Location: Wherever I am at

Re: Python as a modding language

by ThomasMonroe » Post

hmmm.... idk, it looks a whole lot like lisp, not very user friendly i dont think
I don't make messes, I just, er...disturb the local entropy!

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests