Effect of LUA Scripting - Page 2

Effect of LUA Scripting

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

computerquip
Posts: 42
Joined: 28 Dec 2008, 00:42

Re: Effect of LUA Scripting

Post by computerquip »

FLOZi wrote:This argument is as idiotic and wrong-end-of-the-sticky as those saying that the lobby server should not be written in Java/Python. :roll:
It's not idiotic. It's a very arguable situation where both sides have points. And the lobby server probably shouldn't have anything to do with Java >.>
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: Effect of LUA Scripting

Post by SpliFF »

You've also got to account for the track history of C++ AIs in Spring. Most are flakey and crash when Spring is updated. When they crash they often take Spring down with them. They sometimes desync games. Few are ever really finished. This is the reality of trying to integrate external C++ projects with a constantly moving ABI.

The Lua system goes through changes as well but at least when it crashes Spring can keep running. This is a big factor in Lua's favour.
computerquip
Posts: 42
Joined: 28 Dec 2008, 00:42

Re: Effect of LUA Scripting

Post by computerquip »

Simplicity is definitely a key to Lua. But having a failing AI in C++ isn't C++'s fault. That's definitely the programmers.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Effect of LUA Scripting

Post by lurker »

Go ahead and curse the programmer of the AI when it corrupts your spring's memory, but it's not going to help you stay in the game.
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: Effect of LUA Scripting

Post by SpliFF »

zwzsg wrote:
SpliFF wrote:if not then put it in a DLL and import the DLL directly via Lua's package system.
Does not work in Gadgets, does not work in Linux and will not work in Windows, afaik.
That thread was referring to an exploit where you would create the DLL using Lua to write a binary string to a file. Loading an actual dll/so is supposed to work. I don't know of any Spring mods that actually use external libraries so it's hard to test without writing one.
But having a failing AI in C++ isn't C++'s fault. That's definitely the programmers.
How can you blame the programmer if the ABI changed? A lot of people leave mod communities. Most of the AI issues were due to the author abandoning them. The point is people still try to install them and Spring segfaults. C++ tends to break badly, often with no helpful error message. Lua fails more gracefully, that's all I'm saying.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Effect of LUA Scripting

Post by zwzsg »

SpliFF wrote:That thread was referring to an exploit where you would create the DLL using Lua to write a binary string to a file.
Creating a .dll / .so by writing a binary string to a file works both under Linux and under Windows (but only for Widgets).
SpliFF wrote:Loading an actual dll/so is supposed to work. I don't know of any Spring mods that actually use external libraries so it's hard to test without writing one.
I wrote one, tested it, and found the loading of external library was disabled in Linux builds of Spring. The .dll and widget are in Kernel_Panic_3.2.sd7. Haven't released the .so and modified widget because they don't work. When I attempt to link to the external library, I have the error message:
dynamic libraries not enabled
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Effect of LUA Scripting

Post by KDR_11k »

The kind of code you see in mods doesn't need a native code implementation. It's mostly game logic which tends to be the large and low CPU parts of the program. Using it as native code only means there's a higher chance of engine crashes since native code can't be contained like Lua and of course the very real chance of security issues, never mind the more complicated toolchain to get the code ingame. If you run into code that really NEEDS to be native you can still talk about modding the engine or something but currently the Lua is rarely using much CPU, even when a game goes laggy it's usually because of the simulation (which is part of the engine) getting overloaded rather than the game logic.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Effect of LUA Scripting

Post by Kloot »

computerquip wrote:It's a very arguable situation where both sides have points.
No, you don't have any points, just a lot of misinformed mumbojumbo.
Because they do not require a type, all variables in Lua I'm assuming allocate a large amount of space.
The fact that a language is dynamically typed (like Lua) means types are checked and assigned at run-time, NOT that every variable "uses up 100MB because it could be anything".
Also, Lua doesn't have the simple use of pointers and references
False:

Code: Select all

local function f(table_ref)
    table_ref["key"] = 123
end
t = {}
f(t)
print(t["key"]) -- guess what
This is a MUCH more effecient way of passing variables to a function instead of copying temporary variables all over the place.
It's nice that you've just learned the distinction between call-by-value and call-by-reference, but please stay out of discussions that you don't understand the arguments of.
And I'm sure there is much more that I'm missing
Yes, solid basic knowledge of the topic at hand.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Effect of LUA Scripting

Post by FLOZi »

computerquip wrote:
FLOZi wrote:This argument is as idiotic and wrong-end-of-the-sticky as those saying that the lobby server should not be written in Java/Python. :roll:
It's not idiotic. It's a very arguable situation where both sides have points. And the lobby server probably shouldn't have anything to do with Java >.>
:roll:

Java/Python are excellent choices for the lobby server. I'll make it simple for you:

C++ IS NOT ALWAYS THE BEST CHOICE OF LANGUAGE.

Anyway, Kloot wins for actually spending the time demolishing your 'argument' instead of just getting angry at another pointless and misguided thread. 8)
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Effect of LUA Scripting

Post by lurker »

Garbage collection is very valuable for servers and ingame scripts written by people that may or may not be coders, that may or may not be putting a lot of effort into it.

Lua is an extremely capable language. You can build classes with private and public members, you can store binary data in strings, you have coroutines to split up a workload, you can build functions at runtime and do very cool things with them. And the "everything is a table" philosophy is both simple and powerful. When was the last time you did this in C++:

Code: Select all

local OldToggleWidget = widgetHandler.ToggleWidget
function widgetHandler.ToggleWidget(wh, name)
   if name == "special widget" then
      SpecialBehavior()
   else
      OldToggleWidget(wh, name)
   end
end
Can't believe you compared it unfavorably to BASIC...
User avatar
TheFatController
Balanced Annihilation Developer
Posts: 1177
Joined: 10 Dec 2006, 18:46

Re: Effect of LUA Scripting

Post by TheFatController »

lurker wrote:Can't believe you compared it unfavorably to BASIC...
I'm guessing it's a simple case of rage at the use of 'if..then..end' :P
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Effect of LUA Scripting

Post by CarRepairer »

TheFatController wrote:
lurker wrote:Can't believe you compared it unfavorably to BASIC...
I'm guessing it's a simple case of rage at the use of 'if..then..end' :P
I prefer IZ..YARLY..KTHX
computerquip
Posts: 42
Joined: 28 Dec 2008, 00:42

Re: Effect of LUA Scripting

Post by computerquip »

Kloot wrote:
computerquip wrote:It's a very arguable situation where both sides have points.
No, you don't have any points, just a lot of misinformed mumbojumbo.
Because they do not require a type, all variables in Lua I'm assuming allocate a large amount of space.
The fact that a language is dynamically typed (like Lua) means types are checked and assigned at run-time, NOT that every variable "uses up 100MB because it could be anything".

Computerquip:
Also, Lua doesn't have the simple use of pointers and references
False:

Code: Select all

local function f(table_ref)
    table_ref["key"] = 123
end
t = {}
f(t)
print(t["key"])
Computerquip: Lua doesn't have pointers. I read about the references today.
This is a MUCH more effecient way of passing variables to a function instead of copying temporary variables all over the place.
It's nice that you've just learned the distinction between call-by-value and call-by-reference, but please stay out of discussions that you don't understand the arguments of.

Computerquip : Wtf are you talking about?
And I'm sure there is much more that I'm missing
Yes, solid basic knowledge of the topic at hand.
Well thanks for being an asshole about pretty much everything I've said. I'm still learning like always and there is no need for you to get pushy about it, seriously.

I understand that C++ isn't neccessary for everything. If you read the statement about the server software, I mentioned Java but I don't mind Python. It's a very useful script language. I have beef with Java for multiple reasons that are common among people who don't like Java. The main feature of Java is being cross-platform.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Effect of LUA Scripting

Post by FLOZi »

Garbage collection, a HUGE api of classes, rapid development, low maintenence code...

Dreadful language. :roll:
computerquip
Posts: 42
Joined: 28 Dec 2008, 00:42

Re: Effect of LUA Scripting

Post by computerquip »

I give up. You guys went off topic and ended up going against me in arguments I'm on your side in.

I never said Lua is a bad language. I just mentioned that there are fundamental flaws within a majority of all interpreted languages. Unreal Script, Java (kinda), Python, and Perl are just examples of this. They are ALL slow as hell in multiple occasions! I never said you SHOULDN'T code anything in Lua. I personally prefer performance and some things shouldn't be coded in Lua. I HONESTLY do not understand why you guys are such assholes about it.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Effect of LUA Scripting

Post by lurker »

We argue against our perceptions of what you say; it's the best we can manage, and you would do well to not take it personally when someone misunderstands your point or says something that you think is them being harsh.



Lua can be slow in some circumstances, but it's not possible to have machine-compiled code that will be compatible for all spring players.
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: Effect of LUA Scripting

Post by SpliFF »

If you think this has gone OT then I can at least answer your original question.

There ARE ways to do a C++ mod for Spring. Having said that the whole concept doesn't sit well with the developers for reasons that were explained in this thread. You would have a hard time getting Lua systems moved (back) into C++ unless:

a.) You could demonstrate a serious bottleneck exists, or:
b.) You write the system yourself and can demonstrate a real need, or:
c.) You fork Spring

So yeah, it can be done.

As for why people are being "assholes", I can explain that too. It's because you started out by telling us you've been researching Lua since "yesterday" and then went on to make assertions about it that were demonstrately false, vague or irrelevant. Basically to argue the case that Lua is "too slow" and "a bad version of BASIC" or something like that. If you'd just listened instead of being a smartarse there would be no reason for anyone to get upset.

Instead, when your false assumptions were challenged you went on to make counter-arguments that were also demonstratively false like Lua "not being used very often" and "in NO way efficient enough for large projects".

Forgive us if we're assholes for pointing out that you, with your entire day of experience in the matter, are simply wrong. Lua IS used a lot, including in games that require even higher framerates than Spring. There's Dawn of War, Supreme Commander, Stalker, World of Warcraft, Simcity 4, Warhammer Online, Farcry and Crysis, Impossible Creatures, Homeworld 2, Heroes of Might and Magic V, Freedom Force, and plenty more. You wouldn't argue these games are slow, and you wouldn't argue that they represent a "fringe" market either.

Yes they aren't written entirely in Lua, but then neither is Spring. The Lua parts are very carefully chosen to ensure critical loops remain in the engine itself. That's the whole reason communication is handled via a limited number of callbacks rather than exposing every single variable and function.

Your argument, taken to its extreme, would have us all writing software in Assembly. We can agree that Lua isn't good for everything but by the same token neither is C++. You have yet to demonstrate that Lua is having any negative impact of Spring mod development so there's no point complaining about it.

If you want to use C++ that's fine, if you want someone to write you a C++ interface for mods that's less fine. If you want us to accept your assertions about Lua i'm afraid that birds already flown.
computerquip
Posts: 42
Joined: 28 Dec 2008, 00:42

Re: Effect of LUA Scripting

Post by computerquip »

I don't remember being a smartass. I remember being told smart ass remarks to insult me in a post not too far away from this though. And my argument is that because Lua is an interpreted language, it can in certain situations be slow and clunky. And I also mentioned that it felt like learning a bad version of BASIC which is an opinionated remark made by me that you guys are calling wrong even though that also isn't your place. And no I wouldn't have everyone writing in Assembly. My original argument is that in some places Lua is in places where probably shouldn't be. And relatively, compared to other script languages, Lua ISN'T used a lot or should I say isn't very known?

YOU GUYS are the ones that started the argument. Instead of simply giving facts, you gave back by talking mess to me for absolutely no reason because I admitted at assuming something and was wrong.Apparently I can't express a few matters that I'm concerned about with learning a new language without getting bitched at for it.
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: Effect of LUA Scripting

Post by SpliFF »

computerquip wrote:And my argument is that because Lua is an interpreted language, it can in certain situations be slow and clunky.
That's not an argument. It's a statement of the obvious. It isn't something that has a rational response unless you want to tell us exactly which pieces of code or situations are bothering you. However it seems more than likely you don't even know.
computerquip wrote:And I also mentioned that it felt like learning a bad version of BASIC which is an opinionated remark made by me that you guys are calling wrong even though that also isn't your place.
Sure it is. You've been researching Lua for a day and you clearly haven't learnt enough about it to judge its merits with any validity. I'm guessing you know even less about BASIC.
And relatively, compared to other script languages, Lua ISN'T used a lot or should I say isn't very known?
You shouldn't say either. Lua is used in many more games than Python or Java. Just like ASP is relatively unused outside of websites. Or Perl outside of text processing. Or Bash outside of shell scripts. Lua is considered to be the language of choice for game scripting by people who are involved in these things.
computerquip wrote:YOU GUYS are the ones that started the argument. Instead of simply giving facts, you gave back by talking mess to me for absolutely no reason because I admitted at assuming something and was wrong.Apparently I can't express a few matters that I'm concerned about with learning a new language without getting bitched at for it.
We gave you facts. You disputed, and apparently continue to dispute many of those facts. Why shouldn't we jump down your throat when you appear to be wasting peoples time.

In short, if you have a question, ask it and accept the answers. If you have a statement or opinion then make some attempt at justifying it with specifics or your remarks have no value to anyone. In short you don't know enough and people here ARE trying to help you and in return you call them arseholes. Now you think you're a martyr. :roll:
computerquip
Posts: 42
Joined: 28 Dec 2008, 00:42

Re: Effect of LUA Scripting

Post by computerquip »

I didn't / don't dispute any of those facts. I just didn't like the assumptions you made about me. It was uncalled for so I retaliated. When did I not accept those facts? :roll:
Post Reply

Return to “Engine”