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

zaoqi
Member
Posts: 42
Joined: Sat Jan 07, 2017 12:14
GitHub: zaoqi
IRC: zaoqi
In-game: zaoqi

Re: Python as a modding language

by zaoqi » Post

ECMAScript is better.
I speak en_CN/zh_CN/wzh_ACN.
My mods: ZNM's Not Minecraft Minecraft-like Commands Crafting+/gamemode

User avatar
Hybrid Dog
Member
Posts: 2836
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: Python as a modding language

by Hybrid Dog » Post


‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

Balaji
New member
Posts: 1
Joined: Thu Aug 16, 2018 05:41

Re: Python as a modding language

by Balaji » Post

You are right about the Python, Is it worth to go for Python online training as I am not having the time to learn classroom, i would appreciate if anyone sheds light on it.

User avatar
joe7575
Member
Posts: 851
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: Python as a modding language

by joe7575 » Post

Python is my favourite language for many projects, but Lua:
- is faster
- has less footprint
- is designed for to be embedded in other C/C++ programs
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

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

joe7575 wrote:but Lua is faster
This may not be as true once you discard LuaJIT from the equation. Lua is a lot less appealing without LuaJIT, and LuaJIT is becoming more and more unusable. Python is easier for larger programs, is more well known, and is more appealing to educators. But it isn't suitable to Minetest due to it not being good at being embedded.

I still think that it would be good to have a proper Python API implemented using a Lua mod and sockets, maybe I'll work on that at some point
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
v-rob
Developer
Posts: 971
Joined: Thu Mar 24, 2016 03:19
GitHub: v-rob
IRC: v-rob
Location: Right behind you.

Re: Python as a modding language

by v-rob » Post

Recently, I learned Python and found it a very good, versatile programming language and now the programming language I use for everything besides Minetest. I now think that it would be a good programming language for Minetest.

Now, I know that the devs don't have time for this, since they already have too much they have to work on as it is. (780 issues on GitHub?) But, if someone ever started this kind of thing, I would love to help out with it.
Core Developer | My Best Mods: Bridger - Slats - Stained Glass

Skulls
Member
Posts: 108
Joined: Thu Dec 21, 2017 17:41
In-game: Skulls

Re: Python as a modding language

by Skulls » Post

rubenwardy wrote: I still think that it would be good to have a proper Python API implemented using a Lua mod and sockets, maybe I'll work on that at some point
This was the route I was playing with as well. For me it looked best to have a single call into a separate Python process called every step but with back and forth API calls between the Python process and the engine process. Without a way to share state the Python stuff would be limited to very abstract or high level logic and all of the nitty gritty implementation (place node, detect node, set animation, etc) would still have to be done in Lua. Even if you only jumped into the Python stuff when needed it would still be fluffy and need a lot of Lua glue.

Shout if you start and would like some help.

Edit: Also, any Python implementation, even as a first class scripting language in Minetest, would have to be treated as trusted code. I don't think it would be possible to get it as safe as the current Lua implementation so you would have to trust any Python mods as much as you trust the Minetest binaries.

User avatar
Lejo
Member
Posts: 718
Joined: Mon Oct 19, 2015 16:32
GitHub: Lejo1
In-game: Lejo

Re: Python as a modding language

by Lejo » Post

It would be great if insecure C++ mods were be possible.
So that you can change things in C++ using an insecure mod.
So you don't have to modify your minetest.

User avatar
aristotle
Member
Posts: 79
Joined: Wed Mar 14, 2018 23:40
GitHub: askotos
IRC: aristotle_
In-game: aristotle
Location: Currently on Melpomene, waiting for the starship to be fixed.
Contact:

Re: Python as a modding language

by aristotle » Post

burli wrote:I want to show you why python will never be added to Minetest. I made a really simple test...
Probably too simple using the wrong tools and forgetting how the Python interepreter really works, or simply running the wrong Python interpreter.
Furthermore, you should remember how the Python interpreter compiles the code just once into some op code and how the second time every script becomes quite a few times faster (the *.pyc files & co).

Furthermore Micropython might indeed be an excellent competitor with respect to Lua if you want to go as small as possible: it is able to become so small that it can be easily embedded inside microcontrollers that are branded Arduino & co, no operating system required at all!!
burli wrote:The Lua code runs on a single core, the Python code uses all 6 cores
I am not so sure I see the 6 cores used.. Where are the 6 processes and what are they doing? Are you referring to threads? What about the GIL? The global interpreter lock that makes Python stay on just one core because of how it has been implemented??? Which instructions have been run where? How many times? For what I know Python still has no real threads support when talking about the C version of Python that has been derived from the original Guido's sources... (but because I have just been building in a cave 24/7 for the last few months I might be wrong)
burli wrote: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
Talking about speed and saying Python is too slow is definitely a big mistake: you have not used it professionally at all: it's JUST FAST and that brings (as well) fast development, extensive knowledge base, easy maintainability of medium to large projects, HUGE and SO GOOD libraries, and so many solutions to make it more often than not as fast as and even faster than pure C implementations...

You should just look at some machine learning, scientific and computational heavy projects to understand how fast and powerful it is in practically any situation, NOT ONLY the easiest ones.

Python is very often compared to compiled languages such as C, not even C++... because of its speed!
burli wrote:I can't imagine a single usecase where python has an advantage over lua as scripting language in Minetest
I definitely can: Mesecons, Technic, mob*, ... mods extension...

Though in the course of the last few months I have started appreciating Lua, I definitely can't forget the Python object model, its operators, its great syntax, ...the pleasure you get by coding in Python, ...but many of its features come at no cost and so silently that many do not even notice them untill they miss them.

Different solutions that the MT core developers might be interested in trying are available.

So, yes, Lua is available and good for writing great mods, but - in my opinion - if you ever wanted to reinvent the MT modding paradigm and be astonished: Python should be the first option.
Happy builds & explorations! | Initiating my Creative Minetest channel on YouTube

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

Python is very often compared to compiled languages such as C, not even C++... because of its speed!
But not positively https://benchmarksgame-team.pages.debia ... thon3.html
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
aristotle
Member
Posts: 79
Joined: Wed Mar 14, 2018 23:40
GitHub: askotos
IRC: aristotle_
In-game: aristotle
Location: Currently on Melpomene, waiting for the starship to be fixed.
Contact:

Re: Python as a modding language

by aristotle » Post

rubenwardy wrote:...I still think that it would be good to have a proper Python API implemented using a Lua mod and sockets, maybe I'll work on that at some point
That would be great! :D
Thank you for even thinking of it!

There already is an interesting mod by arpruss on github to look at: raspberryjammod; though I could not make it work on GNU/Linux when I tried a few months ago when I definitely knew nothing about Lua.
Happy builds & explorations! | Initiating my Creative Minetest channel on YouTube

User avatar
aristotle
Member
Posts: 79
Joined: Wed Mar 14, 2018 23:40
GitHub: askotos
IRC: aristotle_
In-game: aristotle
Location: Currently on Melpomene, waiting for the starship to be fixed.
Contact:

Re: Python as a modding language

by aristotle » Post

rubenwardy wrote:
Python is very often compared to compiled languages such as C, not even C++... because of its speed!
But not positively https://benchmarksgame-team.pages.debia ... thon3.html
I always have some doubts about this kind of benchmarks. If it were not for the debian.net domain I would say that they just picked up a library from the bunch and called it without even realizing it was for python2 or a complete beginner's experiment.
Instead, they took the time before forking a new interpreter, thus adding the time the interpreter takes to be loaded and unloaded. I just do not think this is a fair way to time a Python script or a script in general, because this is just a way a [Python] script can be run, not the only one, the preferred one, or the most common one especially if you are not calling an OS command but you are instead calling a bunch of scripts/commands; thus I would say that this does not give us a good / complete / absolute measurement of the performances in real cases, but in one only.
I would cite the last paragraph of the comparison pages:
We want easy answers, but easy answers are often incomplete or wrong. You and I know, there's more we need to understand.


I then looked at how Lua vs Python is in this same site because Lua timings suffer in the same way from the same approach: since they are run in the same way, some comparison can be done instead.
The CPython implementation generally tends to use as MUCH memory as it can to be fast and it generally IS fast:
summing up the seconds (lua: 3014.88, python: 2155.6), Python definitely is faster than Lua in this month comparison... in a range of a few hundred seconds... 859.28! This means something! :D
And.. what about memory? In my opinion memory seems to have been better used too :D
Happy builds & explorations! | Initiating my Creative Minetest channel on YouTube

User avatar
Hybrid Dog
Member
Posts: 2836
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: Python as a modding language

by Hybrid Dog » Post

aristotle wrote:I then looked at how Lua vs Python is in this same site because Lua timings suffer in the same way from the same approach: since they are run in the same way, some comparison can be done instead.
The CPython implementation generally tends to use as MUCH memory as it can to be fast and it generally IS fast:
summing up the seconds (lua: 3014.88, python: 2155.6), Python definitely is faster than Lua in this month comparison... in a range of a few hundred seconds... 859.28! This means something! :D
That's Lua 5.3, Minetest uses luajit. Yesterday I've tested the performance of my stack and fifo implementation,
luajit was about 50 times faster. Lua 5.3 was only very slightly (about 1/15) faster than Lua 5.1.5.

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

User avatar
aristotle
Member
Posts: 79
Joined: Wed Mar 14, 2018 23:40
GitHub: askotos
IRC: aristotle_
In-game: aristotle
Location: Currently on Melpomene, waiting for the starship to be fixed.
Contact:

Re: Python as a modding language

by aristotle » Post

Well I would say that I do not agree with some of their statements and that others should be further investigated (since Python gets faster and faster, better and better, cleaner and cleaner every day): just look at how some statements needed further explanations / debate and those could still go on and be added almost anywhere else on that page.
I will cite a statement on that page too:
Please let's not start a flamewar here.
It is easy to start one when you make assertions and that they easily fail when you use them when referring to Python whose gory details are always moving so fast and - more often than not - so silently.
BTW, assertions are there and here to fail: they allow to understand the community, its goals, its knowledge base, ... its expectations, its direction. :D
Happy builds & explorations! | Initiating my Creative Minetest channel on YouTube

User avatar
aristotle
Member
Posts: 79
Joined: Wed Mar 14, 2018 23:40
GitHub: askotos
IRC: aristotle_
In-game: aristotle
Location: Currently on Melpomene, waiting for the starship to be fixed.
Contact:

Re: Python as a modding language

by aristotle » Post

Hybrid Dog wrote:... That's Lua 5.3, Minetest uses luajit. Yesterday I've tested the performance of my stack and fifo implementation,
luajit was about 50 times faster. Lua 5.3 was only very slightly (about 1/15) faster than Lua 5.1.5.
Sure. And that was CPython 3.7, though other Python implementations might be tried and compared: they just were the latest plain vanilla interpreters.

What I meant to underline is that assertions generally fail at some point: that case simply tells us that asserting Lua is faster than Python, Lua has a lower memory footprint, ... is oversimplification: probably choosing Lua today over Python, Python over Lua, having both Lua and Python at the same level, ... is not a simple matter, but probably a more philosophical one - LOL - than it might have been in the past (if we take away the development and maintenance costs!).
Happy builds & explorations! | Initiating my Creative Minetest channel on YouTube

User avatar
aristotle
Member
Posts: 79
Joined: Wed Mar 14, 2018 23:40
GitHub: askotos
IRC: aristotle_
In-game: aristotle
Location: Currently on Melpomene, waiting for the starship to be fixed.
Contact:

Re: Python as a modding language

by aristotle » Post

rubenwardy wrote:... But [Python] isn't suitable to Minetest due to it not being good at being embedded. ...
Hmm... because a lot of effort should then be put again into the core C++ engine to make Python a true brother of Lua.

EDIT: deleted a couple of words that would/might have made my comment sound a provocation and removed three links that might have enforced that because that was not the intention!
Last edited by aristotle on Sun Aug 19, 2018 15:08, edited 3 times in total.
Happy builds & explorations! | Initiating my Creative Minetest channel on YouTube

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: Python as a modding language

by hajo » Post

aristotle wrote:a lot of effort should then be put again into the core C++ engine to make Python a true brother of Lua.
There are many things on the todo-list of minetest that could use 'a lot of effort' more urgently,
and/or for better end-user-effect.

Also, how many (mod-)developers would we gain, who can't work with lua ?

User avatar
aristotle
Member
Posts: 79
Joined: Wed Mar 14, 2018 23:40
GitHub: askotos
IRC: aristotle_
In-game: aristotle
Location: Currently on Melpomene, waiting for the starship to be fixed.
Contact:

Re: Python as a modding language

by aristotle » Post

hajo wrote:
aristotle wrote:a lot of effort should then be put again into the core C++ engine to make Python a true brother of Lua.
There are many things on the todo-list of minetest that could use 'a lot of effort' more urgently,
and/or for better end-user-effect.

Also, how many (mod-)developers would we gain, who can't work with lua ?
Sure. I agree. Definitely.

And.. as pointed out in a linked page of a rubenwardy's previous post, then users and developers would start arguing which language is better/easier/more concise/more expressive/faster/... and would start duplicating stuff instead of adding and improving together.

This said, it does not mean that some Python interface would not be appreciated anyway. :)
It might just be a teaser to make others come and join the community like arpruss's raspberryjammod has done for me! LOL

EDIT: just added the italics to emphasize the concept
Happy builds & explorations! | Initiating my Creative Minetest channel on YouTube

User avatar
v-rob
Developer
Posts: 971
Joined: Thu Mar 24, 2016 03:19
GitHub: v-rob
IRC: v-rob
Location: Right behind you.

Re: Python as a modding language

by v-rob » Post

hajo wrote:
aristotle wrote:a lot of effort should then be put again into the core C++ engine to make Python a true brother of Lua.
There are many things on the todo-list of minetest that could use 'a lot of effort' more urgently,
and/or for better end-user-effect.

Also, how many (mod-)developers would we gain, who can't work with lua ?
It's not that we can't work with Lua, but we prefer to work with the more powerful and better Python. I could do so many more things with Python that I couldn't (at least not with more effort that it's worth) in Lua.
Core Developer | My Best Mods: Bridger - Slats - Stained Glass

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

aristotle wrote:
rubenwardy wrote:
Python is very often compared to compiled languages such as C, not even C++... because of its speed!
But not positively https://benchmarksgame-team.pages.debia ... thon3.html
I always have some doubts about this kind of benchmarks. If it were not for the debian.net domain I would say that they just picked up a library from the bunch and called it without even realizing it was for python2 or a complete beginner's experiment.
Instead, they took the time before forking a new interpreter, thus adding the time the interpreter takes to be loaded and unloaded. I just do not think this is a fair way to time a Python script or a script in general, because this is just a way a [Python] script can be run, not the only one, the preferred one, or the most common one especially if you are not calling an OS command but you are instead calling a bunch of scripts/commands; thus I would say that this does not give us a good / complete / absolute measurement of the performances in real cases, but in one only.
I would cite the last paragraph of the comparison pages:
We want easy answers, but easy answers are often incomplete or wrong. You and I know, there's more we need to understand.


I then looked at how Lua vs Python is in this same site because Lua timings suffer in the same way from the same approach: since they are run in the same way, some comparison can be done instead.
The CPython implementation generally tends to use as MUCH memory as it can to be fast and it generally IS fast:
summing up the seconds (lua: 3014.88, python: 2155.6), Python definitely is faster than Lua in this month comparison... in a range of a few hundred seconds... 859.28! This means something! :D
And.. what about memory? In my opinion memory seems to have been better used too :D
What is, in your opinion, the most accurate and up to date benchmarks making meaningful comparisons? For example LuaJIT vs PyPy might be a useful comparison because they are both speed-optimized JIT-compilers.
Every time a mod API is left undocumented, a koala dies.

User avatar
joe7575
Member
Posts: 851
Joined: Mon Apr 24, 2017 20:38
GitHub: joe7575
In-game: JoSto wuffi
Location: Germany, in the deep south

Re: Python as a modding language

by joe7575 » Post

In Minetest there are a lot of forth and back between C++ and Lua.
That means the performance of the wrapper between C++ and Lua/Python should be measured.
I guess the Lua wrapper is thinner and more efficient than any Python wrapper.
It should be possible to measure this by means of a simple example like the call to a Lua/Python function with a few parameters and an additional table with optional parameters and a call back into the C++ environment.
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.

sofar
Developer
Posts: 2146
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Python as a modding language

by sofar » Post

aristotle wrote:the pleasure you get by coding in Python, ...but many of its features come at no cost ...
This is not the Aristotle that wrote about Logic and philosophy, that's for sure.

If you use a nickname of a great thinker, try and not do the name so much bad justice.

sofar
Developer
Posts: 2146
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Python as a modding language

by sofar » Post

aristotle wrote: I would cite the last paragraph of the comparison pages:
We want easy answers, but easy answers are often incomplete or wrong. You and I know, there's more we need to understand.
This is the same arguments that antivaxxers and flat earthers use. It misrepresents the abundance of information available as "dubious" and because scientists always claim that there is more to be learned, they interpret that as an admission of incompleteness. In fact, the science is only going to refine the knowledge and make it more complete, and it's entirely incorrect to assume that the next published paper undoes the previous works of hundreds of professionals.

Astrobe
Member
Posts: 577
Joined: Sun Apr 01, 2018 10:46

Re: Python as a modding language

by Astrobe » Post

ThomasMonroe wrote: 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.
No, changing languages or paradigms does not magically make you a better programmer. Especially when you switch from a language for noobs to a language for even-more-noobs.

Switching to "object oriented scripts" won't help if they are written by people who have no clue about what are the SOLID principles.

What makes better quality mods are CS training, rigor and discipline. Everything else is snake oil.

/thread.

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

You can do object orientation in Lua - inheritence and polymorphism are fairly cheap in LuaJIT using meta tables. Other things may need changing the __index function, which is less cheap :)

I've written a few chapters on my thoughts on good practices:

Automatic Error Checking (LuaCheck)
Intro to Clean Architectures
Automatic Unit Testing
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests