Game Dev Obstacles (split from Spring developer crisis) - Page 2

Game Dev Obstacles (split from Spring developer crisis)

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by PicassoCT »

Does one of you remember sunspot? That guy did it right. He showed up one day, asked for the api, showed some code, worked for two weeks. completed his modification, Vannished again (propably due to magnetic fields changing)
sooo the point is we were all superfriendly to him.

If you proof you are willing to work (and if it is only the willingness to open paint and paint a heightmap) even smoth becomes a purring ball of niceness. And like hell, we even tolerate those who dont want to contribute anything more then social comitment to the comunity.

Maybe not everybody gatecrashing here, is always nice either. The attitude: Me CEO, you nothing, do my work. Deserves nothing else.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by Silentwings »

To be honest this is also my experience of getting involved over the last year in game dev-ing. As soon as it was clear that I was contributing stuff I got lots of help & friendliness.

My experience is that the vast majority of unhelpful response & abuse that appears on these forums comes from that strange class of people who almost never contribute any content but somehow feel they've sat around long enough to start giving orders. This is probably my #1 dislike about developing stuff, although the idiosyncracy of lua syntax is competition :P
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by CarRepairer »

Why do you insult lua syntax? I really don't get it. It is the most elegant and concise language.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by Silentwings »

For example: If then ... end is silly, If{...} is all you need; easier to read and less typing. I also like to know what types my variables are and the whole thing with 0,nil is just wtf why as far as I'm concerned - especially I dislike the treatment of types since Spring.Echo(x) can return things that don't match whats actually there (e.g. if x is a function and the wiki has not made this clear, Spring.Echo(x) can tell you x is an empty table). I also have never found a proper way to empty a table (without iterating over its whole contents). Variables being global by default seems mad. I could go on... its things like this.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by zwzsg »

If then ... end is silly, If{...} is all you need; easier to read and less typing.
"then" "end" is a bit more verbose than {} but Lua made the choice to have explicit words, instead of odd punctation signs, which in the end makes it much more comprehensible than Perl : Imo Perl and Lua are similar, except Perl has arcane syntax. So { } is shorter but not easier.

I also like to know what types my variables are
I enjoy not having to specify what my variables are. It's cumbersome to have to decice if I'll use an char, short, int, long, signed or not, every time I just need, like, an index. Lua autocasting also remove the trouble of number formatting every time I print a numnber.

Beside, if you really want to keep track of your variable types, go use some variable naming scheme with a type prefix.

the whole thing with 0,nil is just wtf
0 being truethy is a different convention from C, but once you get past that hurdle and get into Lua mindset, you realise the deal with nil is quite useful, for exemple to have default value with the (x or default) syntax or to handle variable argument number in your function calls.

Spring.Echo(x) can return things that don't match whats actually there (e.g. if x is a function and the wiki has not made this clear, Spring.Echo(x) can tell you x is an empty table)
Really? For me it prints "function" and its adress.

Sometimes I wish print / Spring.Echo would print the content of the table instead of just "table" though.

I also have never found a proper way to empty a table
Err, yourTable={}

A small annoyance is that to copy a table, you need your own function. And if that table can contains table, your own recursive function. And if that table can contains table that can contains the initial table, it gets more complex.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by Silentwings »

if you really want to keep track of your variable types, go use some variable naming scheme with a type prefix.
This does not solve the problem with an API where you have to dal with variables of prespecified and sometimes unknown types (e.g. command options).
I enjoy not having to specify what my variables are.
Fair enough, I prefer to know.
0 being truethy is a different convention from C
0 and nil being different is not a "design convention", its a historical issue that they landed themselves with through trying to do without boolean variables in early versions of lua. (According to http://lua-users.org/wiki/ExpressionsTutorial)
Sometimes I wish print / Spring.Echo would print the content of the table instead of just "table" though.
For me it will do this as long as the table only goes one-deep in terms of keys. However if I try to Echo a bitmask it usually pretends I've got an empty table. Iirc Niobium wrote a function for Echoing tables which is hiding inside some fo the BA gadgets.
A small annoyance is that to copy a table...
Etc, there are tonnes of operations on its data types, like sorting, copying, searching that lua could handle much better if you had to choose your own data types (instead of almost the current bare bones that it does have). This is no big deal for writing 200 lines of widget, but imo its a huge tool missing if I wanted to write anything bigger in lua.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by zwzsg »

Err, it was still a design choice to consider 0 as truthy, and to have another thing (initially nil, later also false) for falsy.

So far table.sort nicely handled all my sorting needs. Using well chosen keys for the tables can eliminate much of the searching needs, otherwise yeah big "for" loops. And there's the powerful regex-like patterns for searching in strings.

Having few types and few special functions is what makes Lua simple, and Lua simplicity is what makes it easy.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by Silentwings »

Lua simplicity is what makes it easy.
In my view this is the root of the problem! It's a great language for writing 200 lines, and a dreadful one for writing anything big.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by knorke »

It seems common complaint about Lua that Echo (table or even nested tables) does not print some nice output and how one has to make loops/rescursion. Is there any other language where this works?
Compare with http://stackoverflow.com/questions/1370 ... array-in-c

I think having this somewhat "easy" language is good, it makes it easier for new people to start. Maybe something else would be better for big things (debatable) but that is no use if everbody gives up in frustration during "hello world." ;)
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by gajop »

I agree with the whole Lua sucks notion, but for different reasons.
I mainly hate it for not having classes and lacking libraries (limited in what you could use in Spring, and most of it also requires compilation).
It also oversimplifies things by having only one number type (a simple float, not BigDouble/BigFloat), and as you mentioned container classes are a joke and it has a poorer standard library than C.
It's also not as fast as a decent compiled language like C++/Java/C#, but that's a minor thing imo.

However the simplicity is what makes it easy for non professionals to use it and that's why it's often popular as a scripting language.

@ knorke: ye, it tends to just work with python, and even Java/C++ if you overload/create certain functions, "string toString()"/"std::ostream& operator<<(std::ostream& o)" (although C++ usually does it differently).

Besides there's no reason not to do it like that with Spring.Echo, I think I even suggested once that the official Spring.Echo gets wrapped up with what table.lua does. E.g:

Code: Select all

if type(o) == "table" then
   table.echo(o)
else
   Spring.Echo(o)
end
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by knorke »

@ knorke: ye, it tends to just work with python, and even Java/C++ if you overload/create certain functions, "string toString()"/"std::ostream& operator<<(std::ostream& o)" (although C++ usually does it differently).
Hm, but in C++ it does not "just work."
One can overload the << operator and then do cout << myCustomDataBla; and then it will work but still had to write the function yourself. Like decide in what order things get printed, what member variables even make sense to print etc. It is comperable to what one has to do in Lua.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by smoth »

Silentwings wrote:To be honest this is also my experience of getting involved over the last year in game dev-ing. As soon as it was clear that I was contributing stuff I got lots of help & friendliness.

My experience is that the vast majority of unhelpful response & abuse that appears on these forums comes from that strange class of people who almost never contribute any content but somehow feel they've sat around long enough to start giving orders.
<3

As far as LUA I take the bad with the good and find it a joy to use. On my last trip I met an older guy who had a long career as a programmer. We discussed languages and he said he really enjoys lua for what it is and actually preferred it over python. Then again, he was writing stuff in corona for fun. I didn't get around to asking him why he liked lua over python, but it was an interesting sentiment.

I would prefer lua over C++ or any other compiled language because it's very nature FORCES you to show your code. There probably is a way to compile lua into something, but with C++/C it would be required. I am glad we are not using JAVA and honestly, am indifferent about python. The lightweight and open nature of lua is a joy because it is a fairly straightforward syntax(I do find metatables a bit odd) meaning I can learn faster by reading the code of others and vice versa.
gajop wrote: It's also not as fast as a decent compiled language like C++/Java/C#, but that's a minor thing imo.
having to compile something means you HAVE TO COMPILE IT FOR EACH OS/have to have a state machine for it. It also means your code cannot be directly read.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by gajop »

Oohh, so Java/C# (other compiled languages that run on "VM"s) are bad but languages that need an interpreter get a free pass?

The main annoyance I have with compilation is that with C++ it takes time, other languages do it fast and run portable, so it's hardly an issue. If you really do need to recompile it.. well just do it, it's not that hard, can easily automate it and redistribute multiple versions under rapid for each OS/arch.

As you said, interpreted languages forcing people to show code is not true. One can compile both languages into bytecode:
Lua: http://stackoverflow.com/questions/8936 ... execute-it
Python: http://hackerboss.com/how-to-distribute ... lications/

You can also very easily decompile some languages, especially those that produce bytecode such as Java and C#:
http://stackoverflow.com/questions/2725 ... lass-files
C++ makes it a lot harder, and IDA pro is the most used decompiler, but that often produces unreadable code.

The problem with Lua is that a lot of Lua libraries require you to compile C/C++ code, so you are back at square one. I don't like reinventing the wheel each time I start working at a problem.
User avatar
Cheesecan
Posts: 1571
Joined: 07 Feb 2005, 21:30

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by Cheesecan »

Today OpenJDK + JSR223 Scripting for Java Platform would be a viable option. There are ScriptEngine implementations for quite a few languages, including several for lua.

There's no right or wrong here. You also need to look at the historical perspective, the decision to adopt lua was taken many years ago. Options were fewer back then.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by smoth »

gajop wrote:Oohh, so Java/C# (other compiled languages that run on "VM"s) are bad but languages that need an interpreter get a free pass?
Nope.
gajop wrote:As you said, interpreted languages forcing people to show code is not true. One can compile both languages into bytecode:
Lua: http://stackoverflow.com/questions/8936 ... execute-it
Python: http://hackerboss.com/how-to-distribute ... lications/
I said it is probably possible. Also it is NOT required like C++.
gajop wrote:You can also very easily decompile some languages, especially those that produce bytecode such as Java and C#:
http://stackoverflow.com/questions/2725 ... lass-files
C++ makes it a lot harder, and IDA pro is the most used decompiler, but that often produces unreadable code.
key point. Variable names are lost etc.

I think you ignored my key points. readability, open and simple to read. There are people who believe in optimizing code so strongly it becomes obfuscated to the point of being difficult to read and maintain. on something larger than "200 lines" readability is king to me.
User avatar
Cheesecan
Posts: 1571
Joined: 07 Feb 2005, 21:30

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by Cheesecan »

smoth wrote: I think you ignored my key points. readability, open and simple to read. There are people who believe in optimizing code so strongly it becomes obfuscated to the point of being difficult to read and maintain. on something larger than "200 lines" readability is king to me.
Names of variables are maintained when you decompile Java class files, unless they are obfuscated.

Writing code that is difficult to read is possible in any langage.

With JSR223 you could use say, groovy, here's an example groovy script:

Code: Select all

println "Hello, World!"
You would then type /jvmui reload or somesuch and have them reloaded immediately just like /luaui reload of today.

The key difference is that JSR223 would allow you to run groovy + lua + ruby + anything else you can implement.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by gajop »

smoth wrote: I think you ignored my key points. readability, open and simple to read.
I didn't, I just decided to ignore C/C++ because that's a special language, more similar in it's design goals to Lua than Java/Python/C# imo.

To prove a point I took my Java AI's jar and decided to see how it would looked decompiled, and here's a comparison:
Image
Left is decompiled, Right is original, pretty similar, don't you think?

Btw.. There are certain parts of Java that are overly complicated and really lack a simple version, and even if they are too powerful/good for rapid development they tend to confuse newcomers (think SOAP/WSDL/ORM/EJB stuff).

Still most of the time I'd rather learn the overly complex version which will save me pain later.
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by Pxtl »

A big thing Lua has going for it is how easy it is to embed securely and sandbox to behave *exactly* as you need it to behave. Lua may not be the easiest language for game-devs to code with, but the ease of engine-developers coding to it is a whole other situation.

I mean, do you know if you could produced synced simulation code in C#? Python? Do you know if you could sandbox them? Sandboxing Python has had a long and nightmarish history.

In Lua, it's trivial for engine developers to control access to whichever functionality they want you to have.

Lua is far from a perfect language, but it's the right tool for the job. Probably the only real competitors in this space would be languages you'd like a lot less - Scheme-based languages, or javascript ones.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by zwzsg »

gajop wrote:I mainly hate it for not having classes
Well, you can have classes by using metatable and the :

As for library, yes, no languages has as many libraries as C++, but Lua still can have libraries.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Game Dev Obstacles (split from Spring developer crisis)

Post by FLOZi »

lua is ideal for what we use it for. I too disliked the abuse of 'end' coming from Python, Java and C but now it doesn't bother me in the slightest.

Pxtl covered the engine dev side of it pretty well, and Smoth the game dev side of it. Must we really descend into the internet's 50 billionth programming language discussion. :regret:
Post Reply

Return to “Game Development”