Skip to main content
GameDev.net gamedev.net
🔒 Locked

Why Lua and Python are so popular?

Started by badsector Sep 6, 2004 at 5:48 AM 49 replies 14.8k views
Original Post
badsector
badsector
I have my scripting engine - NerveBreak - available at the net for around nine months now. However, until now there are only 2-3 persons who seemed interested in it (only one uses it "frequently" - all these "stats" are from forum posts and e-mails sent to me). While i'm developing NerveBreak mostly for my own use in my games (and software), i wondered why other people prefer to use Lua and/or Python, which have a worse -in my eyes at least- syntax and they're (in Python's case) too bloated, instead of using other libraries which seems -to me- better suited for C/C++ developers, such as NerveBreak, &#106avascript and AngelScript, because of their C-like syntax. So, what's your option and if you use Lua, Python or any other "famous" library with obscure syntax, why you decided to use that lib instead of anything else?
Diodor
Diodor
I use Lua.

First of all, popularity doesn't equal quality, but it brings several advantages. I can trust Lua to be well tested and to have taken into acount a lot of user feedback (particularly as there have been several versions around). I can also trust it will get updated and bugs will get fixed.

Secondly, Lua is a terrific language. Dynamic typing, excellent data description means (Lua tables _rock_), garbage collection, closures, coroutines. The syntax is brilliantly elegant and simple, and together with the light weight of the language it can obscure the fact that Lua is a very powerful language.
force_of_will
force_of_will
Besides lua is user expansive, for instance you can alter the lua language to support class :D
Rebooted
Rebooted
I use Lua and like its syntax, I can extend it, it is pretty fast, it's widely used and there are books written about it.
Kylotan
Kylotan
Firstly, I don't think it's fair to call Python 'bloated'. It is big, true, but that's because it's a fully-featured programming language. I agree that it's not exactly lightweight to embed in a host application but that matters less and less these days.

I think the mistake you're making is to assume that they have 'obscure' syntax. Lua and Python have very simple syntax - yes, they're somewhat different from C and C++, but they're simpler. This means they're quick to learn, so the difference isn't a problem. It also means non-programmers can learn it more quickly and easily, which is very important for a scripting language that is going to be used by designers and maybe even artists.

They also include high level facilities that most C-like languages won't have, such as simple uniform iteration over a structure, and associative arrays. I won't touch a scripting language without either of those because they make life a lot simpler.

Finally, people using scripting languages need a degree of support. They want to know that there are people who have experience with the language and who can offer advice. Given the choice between 2 similar languages, even if NerveBreak can offer all the facilities that Lua can, people are going to tend towards the language that has been proven (Lua has been used by Bioware and LucasArts in professional games, and more recently in FarCry and Painkiller) and which has many users able to lend assistance. Also, I don't see any documentation on your site. It's hard for someone to compare it to their needs if they can't see all the functionality.
evolutional
evolutional
I haven't used your language but I intend to at least try it at some point in the future. I don't like Lua, the stack accessing makes me mad as it feels that this sort of method should be wrapped up better. I tried GameMonkey which was ok, but again I haven't used it extensively. I'm yet to try AngelScript and NerveBreak but intend to at some point soon, after I get bored of or reach the limits of Mozilla's SpiderMonkey engine.

As a little light on why people seem unwilling to try out new scripting languages, I can almost certainly say that I have held off trying some because of a couple of reasons. With some languages (NerveBreak included), the version numbers are less than 0.2 - which instantly tells me that the language is far off being completed and is likely to have bugs or missing features. When embedding a language, I want it to work as expected and not spend hours trying to solve minor problems that are from a missing feature or a bug. Another reason I tend to hold off trying some languages is simply the lack of documentation. I want to see working examples of small embedded applications as well as demos that show more of the advanced capabilites of the language. For me, I want to be able to drop it into my game with little or no hassle, which means there needs to be examples and documentation on how to bind classes and data structures. I also need to know how to handle errors, such as how an error is reported (does it throw an exception that needs catching?).

I guess what I'm saying is that I need a language to prove itself in use. I don't care if it's big and popular, but generally if it is there will be more documentation and better community support.

That said, I will try out NerveBreak when i get time - but only in minor projects until I understand it's capabilities.

Keep chugging along at it, it sounds decent so far [smile]
markr
markr
I use Lua, but it's not because I like its syntax.

Lua is very light, well-tested, and has good embedding potential (particularly with the C++ luabind etc).

I also like using coroutines.

Spidermonkey &#106avascript I've looked at - it's pretty good really, but I don't have coroutine support or an easy C++ bindings system (I think there is one which kind-of works, but details are sketchy).<br/><br/>From a language perspective, I'd prefer &#106avascript as it's closer to C++ than the others (Lua and Python certainly). Also we are used to writing embedded &#106avascript in our web pages.<br><br>And I quite like &#106avascript - I think those people who designed it did a good job (ok, so there's a bit of legacy Netscape bloat in there like String.bold() or something)<br><br>Mark
badsector
badsector
Thank you for your replies :-).

Yea, documentation and support is something very important. I can see that AngelScript includes a lot of code in it's site and the AngelCode forum is a very active forum with 99% of the posts being about AngelScript (from the quick look i've taken yesterday). However -according to it's creator- AS is there for one and a half year, but nobody can say that it's a "famous" library. And there is an active community too.

However that what seems that gives life to a library (and i think that this is true for any kind of library, not just a scripting library) is the community and the amount of projects that uses that library. But if you think about it, you'll see that this behaviour leads to a closed circle: the famous library is used which makes it more famous by the project that uses it, so more developer knows about it and then they decide to use it in their own projects (sometimes without doing any special search for alternatives - if at all) and the circle goes on.

And this is totally understandable and acceptable by the library users.

However, i think that there is something different that other, less known, scripting engines can offer to them: the increased ability to modify and/or define how the language will be. See, for example, the AngelScript forum, which is 2-3 clicks away from here (you can open a new navigator tab or explorer window if you prefer the evil IE way :->). There are many requiests from the users which are implemented at the next releases (WIP or not). Some of the posts even define the way the language it is. In my case with NerveBreak, the same applies too. I have done lots of additions and modifications to the engine and the language, just because i was asked for them, even if these modifications had none or a little impact on my projects for the moment.

I don't think that the same would be done with Lua or Python. I'm not 100% sure about that, i didn't asked their creators, but i believe that just because there is a big userbase, major changes to the language and/or the API are not as easy as when you have to deal with smaller, less known libraries/scripting engines.

What do you think?
Kevlar-X
Kevlar-X
I'll answer your question with a short story :)

A few years ago when the 3d graphics card wars were being waged
3DFX vs. Rendition and eventually vs. ATI, My brother and I were in the market for a video card, a really good video card for games.

We weighed the options, and we smartly thought, hey, lets go with the 'best card'.

We determined best card on best performance in games (raw FPS and looks), good user feedback, and a solid price. We assumed we had made the correct choice. A Canopus Total3d (Rendition Verite).

Time passed (only a few months), and the war was starting to come to an end.
Shortly after our purchase, not a single driver update was released for our card, and the line was discontinued.

Renditions slowly disapeared off the market, and fewer and fewer games supported them, until eventually, all support stopped.
The video card, was an excelent card.


My next video card was a very well supported, common, nvidia geforce DDR 256. To this day is still chunking away (fully supported!) in a computer.

A moral?
Support/following is king.

[edit]
Whoops, posted exacly as you did.
Heh, sorry this didnt fully address your more recent question. :)

ATI heh. my bad.
[/edit]
"1 is equal to 2 for significantly large quantities of 1" - Anonymous
fierywater
fierywater
...ATI-manufactured GeForce?
JD
JD
This is the first time that I've seen your scripting lang. being mentioned. I found all others thru google. I think you should advertise your releases here like author of squirrel. I feel I should mention that far cry modified lua so that it works faster and the result is squirrel. It's also more streamlined and allows for arrays than lua which I think is a bit bloated for game dev. That damn stack in lua/squirrel I would like to see disappear. Actually, I would love to see unrealScript knockoff. I think majority have c/c++ background that they would like to translate to scripts. Your scripting lang should also come with an ide, debugger, project spaces, etc. All those things that come with vc6 compiler. I think lua benefits here because folks have added support like this to the lang. That counts toward to whole package experience that many want.
badsector
badsector
@Kevlar-X:
I've got your point, but i don't believe that gfx cards and opensource libraries (most scripting libraries are opensource) are the same. When the libraries are developed, you have the support from the developer and the community (even if it is small). For small projects like AngelScript and NerveBreak (i mention AngelScript again and again because i really like it - if it was plain C and i knew it before i start NerveBreak, i would use that instead of developing my own - also it's a small and unknown library when compared to Lua and Python), the developer can be the best person "replace" the "supporting community".

The case with opensource libraries is that when the developer decides to stop developing a library, (s)he can pass the maintainership to someone else. And even if (s)he doesn't, then one can just take the latest released version and start a new one OR work on that one to make the modifications (s)he needs.

That's not possible with an outdated gfx card :-).

But yes, the community is important - this is why i've added a forum on NerveBreak's site (which counts the amazing number of two members - including me of course :-D).

@JD:
I post news about each NerveBreak release since 0.1.2 or 0.1.3, which is around seven months now. I don't do frequent releases, since i'm not working all my time on the language and i want to have some meaningful changes between releases (f.e. includes from 0.1.4 to 0.1.5 was a meaningful change, but the support of the C-like single-character strings wasn't - alone).

So, you've probably lost all my announcements. Btw, at the front page there is still the "new" about 0.1.5's release :-).
psamty10
psamty10
Quote:
Original post by badsector
So, what's your option and if you use Lua, Python or any other "famous" library with obscure syntax, why you decided to use that lib instead of anything else?


I use Python more than I should ;), and here are a list of reasons why:

1) dynamic typing
2) tuples
3) lambda forms --> this is an absolute must!
4) general ease of use, excellent library support
5) my boss told me to do so :)

Also, you mention the 'obscure' syntax of Python --> syntax is not a good enough reason to switch languages, i can adapt to any kind of syntax as long as the language suits its purpose --> and even if syntax mattered, I much prefer Python's clean, simple syntax over the so-called C-like languages..
psamty10
psamty10
BTW, do you have a feature list for NerveBreak (if you're looking for people to switch, you should have more than a few compelling reasons for them to do so)
MichaelT
MichaelT
Advertise, advertise, advertise, advertise ... (shamefully ripped from Ballmers famous (Developers, Developers .....) mantra ;) You get the idea though ;)
No no no no! :)
badsector
badsector
@psamty10:
Is this "-->" a part of Python's syntax? j/k :-) even if i programmed with Python only once just to write an exporter for blender :-).

What are "lambda forms" and "tuples" and ... actually what these features do? :-).

About the list of NB features... i know that NerveBreak is poorly documented. I'll try to change that with 0.1.6 (i've planned lots of stuff for 0.1.6, which means that either 0.1.6 will be released next year or some of them will be implemented in 0.1.7 or 0.1.8 :-P :-P :-P).

One of the hard things about documentation is writing it. I mean i don't have -much- problem with writing (i write lots of stuff everyday, including code and text :-D), but i actually don't know what to write and how to format my textflow :-).

Another reason that NerveBreak lacks good documentation is because these days i'm trying to rewrite the documentation using a newer system which takes an XML and produces HTML, PDF and PS files (using LaTeX). But i have to finish that system first...

@MichaelT:
How? How? How? How? :-)
I'm not good on that :-). Okay, i send news everytime i make a new release and i sent once a news item at programmersheaven.com. I can't think much more than these :-/.

Thanks for your replies anyway :-)
psamty10
psamty10
This should answer your questions... its an article by Chris Hecker on useful language features...
badsector
badsector
Interesting, but some of them seems too advanced for a scripting language :-)

Thanks anyway :-)
JD
JD
Oops, didn't know you advertised on here. I just been into scripting langs recently so I missed your post. On the topic of docs the way I like them to be is to have two sections. One is reference section following win32 msdn style of documenting the other section should be on how to use your scripting lang., like a tutorial. You could also have BNF specs of your lang. In the reference you could have brief major topic sections. Say one topic on arrays, what they are, etc. following with a short syntax example. Though, that could go into the tutorial as well. Take a look at .chm two sets of docs that the author of squirrel lang. wrote. In his case I would put the library section into reference and naming it library. So that I don't have to have two .chm viewers opened and tab between them. You mentioned it and I agree that once you start making things for others to use it's a whole different ballgame. You can no longer go by what you want but must go by what others want and this can cause conflict especially when you're writing the lang for your own game with intent on sharing the lang. with others. That's also why folks won't use your lang. because they expect of you to be on their schedule instead of yours. In another words, someone asks you to implement something and you say you can't because you're busy with your own things then folks don't like that. That's why there will always be a need for companies to make apps for others to use. Linux and open source has this problem. KDE is ok, but some apps don't have commercial level support, what folks want I think.
psamty10
psamty10
Quote:
Original post by badsector
Interesting, but some of them seems too advanced for a scripting language :-)

Thanks anyway :-)


Maybe they are difficult to implement, but Python provides several of those features including:

1) Advanced built-in types
2) Garbage Collection
3) Interpreter
5) Tuples
7) Type inference
12) Anon functions (using lambdas)
13) Function composition (once again, using lambdas)

(The numbers reflect the numbers on the presentation slides)

That's exactly what I'd want from a scripting language, and I think those features were thought out from a scripting language point-of-view. I don't think any 'system language' implements more than a couple of those features...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.