In previous journals we’ve discussed the intention to create a modding layer that would use Python as its scripting language. Python is slower than Lua in terms of interpreted languages but there’s nothing stopping us from having C++ source that people could use to in addition or instead of a scripting language for performance sensitive elements of a game.
With that said, let’s hear from those familiar with both on what they think of either one and why.
Let me also add that Python is a pretty standard scipting languages used in modding WoW, Civ IV, Mine Craft, etc . . .
IMNSHO, strong typing is only useful in languages that have either a powerful type system such as Ada or Haskell, or a strong OOP system like C#. C and C-derived languages, however, don't and so I'd rather have a language with dynamic typing such as Python and Lua over them.
Why? consider the following example:
Will that compile? yeah. Will that run? yep. Will that produce something coherent? no freakin' way unless they added 293 days to December last time I looked. With a powerful type system however, you could define "day" as an integer between 1 and 31 (which would still leave us with February 31 but even so), a month as a member of a specific enumeration and year, well, it depends on the range and precision your program must handle, and how picky the compiler is can be determined by you, the programmer, when designing the program.
But of course, such a system would be grossly overkill for making mods, IMNSHO again, so I still support Python.
AngelScript on the other hand is a scripting langauge.
Personally I see votes for C++ as people saying they find both Python and Lua to be a bad choice.
@legaceez:
Lua is more or less the one of the great standard scripting langages for games (and applications too). The biggest Lua example in user numbers is WoW. Civ IV is Python (Civ V switched to Lua) I think but Minecraft is modded in Java.
*snip*
Will that compile? yeah. Will that run? yep. Will that produce something coherent? no freakin' way unless they added 293 days to December last time I looked. With a powerful type system however, you could define "day" as an integer between 1 and 31 (which would still leave us with February 31 but even so), a month as a member of a specific enumeration and year, well, it depends on the range and precision your program must handle, and how picky the compiler is can be determined by you, the programmer, when designing the program.But of course, such a system would be grossly overkill for making mods, IMNSHO again, so I still support Python.
printf is part of the C Library and kept for compatability, and should not be used (though it is made safer in C++0x). And in C++ and AngelScript (which is what I support for the scripting langauge) will let you define types that can make sure the data is valid (if they are written correctly). The same thing can be done in the langauges you list as doing it better if the programmer writes bad code. To my knowledge there is no langauge that will validate data unless you define the check. Storing it in an object would allow it to be checked when it changes and then it can always be threated as valid without checking everytime you use the data.
"fortran 77"
Why not cobol, or Turbo Basic. There is turbo in the name, it sure runs fast.
My programming experience is basically in C style language: C, C++, PHP, Basic and Visual Basic. The biggest c++ project I did was "Wizardry Legacy", and I think I lost most of I hair on that project. I was doing object oriented programming, but not realy using the C++ classes. I ended the project more than 5 years ago, so things could have changed.
The biggest problem I had were:
A) Memory management: pointers and reference always seemed to create bug. I remember making a megaman clone with dynamically allocated object for the sprite and when I pushed a button to shoot my first bullet (which get's allocated on the spot and destroyed when it exits the screen) the game simply crashed.
B ) Type casting: I was probably doing it wrong. I had a base class "item" and derived class "weapon", "Armor", "Shield", etc which inherited from "item". So if I was managing Items, I simply used "Item" class references and pointers, but let say I needed to stats of a "weapon", I needed to cast my pointer to "weapon" to be able to read the stat. There was also many warning given for typing that even I had a hard time to figure out. In the end, I just randomly added and remove * until the compiler stopped complaining.
So when I learned PHP, I was amazed that all the variables management was now of the past and that I could finally code in peace. I also take a look at C# and was also amazed of all the new features they added to finally overcome all the problems with C++. Unfortunately, I don't think there is an open source compiler.
"There are libraries that help with this. Lots of them. Even some that provide a garbage collector like those in scripting langauges."
Wow! Where were you 5 years ago?
"Whitespace is merely objectionable; it is dynamic typing that is the real evil."
I never programmed in python like language and indeed I was surprised by the white space. As for dynamic typing, I don't know the real impact except for mispelling a variable. As for Lua, it seems similar to Visual basic. Still, there is probably good reasons why lua was created after python, I image it was probably to solve issues in python. As for angel script, it looks good because it has a C syntax, but I'll have to check it in details to know how good it is.
I agree that the modding should be done in 3 levels: XML -> Script -> DLL. Since the C language is not acessable to everybody. But a scripting language that has a C syntax is not bad except for a few operators which are not intuitive like "&&" and "||".
I only hope that the modding system will be very flexibile, and if I can create a new game of my own in little time, I would be more than happy.
I hope for the best
For the logical operators (&&, ||, ^^, and !), AngelScript has non-special symbol equivalents (and, or, xor, and not; repectively). Both are valid and do the same thing.
I'm going to go w/ recommending Lua. Lua easily integrates into C++. Its faster. It doesn't force objects onto you (objects are nice, but not always necessary). Finally, its easier to understand.
I would highly disagree with this statement. If you actually compare the list of game supporting Python v. those supporting Lua, you find that games tend to use Lua much more often than Python. However, this is not the same for non-game applications which seem to prefer Python to Lua. Honestly, of your examples, WoW uses a mix of Lua and XML for scripting and Mine Craft uses java. While Civ IV did use python, it also gave extensive C++ support, and as previously noted,Civ V switched to Lua and C++.
... What? Sure they are not always needed, but how do the other options force them on people (unless the API for Elemental requires it)?
I'm pretty much isolated from the WoW scene. Only interaction is having corrected some friends AddOn scripts. Looking at Python modding on WoW whom I never knew existed it seems it is an external component that needs to be installed by the user or in some cases the AddOns actually install a working Python runtime at install time. Only reason for that I can fathom is the non-sandboxed operations that can be achieved. Not exactly a plus from a security standpoint. It is moderately ingenious but also makes me remember the saying that if the only tool you have is a hammer you will see every problem as a nail.
Well, paraphrasing Kent Pitman, preference for one language over another is more of a political preference than a technical one. Whichever language you choose you are sure to alienate someone- but I am sure you are used to that by now. I would say pick whichever language feels more natural to you for writing mods in and which is easier to interface into the existing system. More important than the choice in language is ensuring that proper documentation is around for us poor not-so-smart sods who want to work on your wonderful, amazing creation. Be interesting to hear you write about the process of developing the modding interface- it might provide enough of a lesson to motivate a modder to support language 'X'.
That said, i think it would be truly cool if one could open up a listener (ala Common Lisp) and connect to a running game and do cool things like
(list-sovereigns) ;;; List of all the data structures that represent sovereigns in the game.
(create 'dragon x y) ;; Create a dragon at position (x y) on the map.
(define-quest 'my-quest ...) ;; Create new data types
(on-quest-complete 'my-quest ...) ;; Triggers
Okay, maybe I'm not that imaginative, but it certainly seems interesting to me to imagine the possibilities from having the ability to manipulate objects in a running game. Hope the modding tools can support that.
Some scripting langauges do support dynamically compiling and executing commands. One of the samples of how to use AngelScript provided in the SDK is a console app that lets the user enter commands that call functions from a script file loaded on start up. I think Python comes with an app like this so it should be do able there too.
Edit:
http://www.angelcode.com/angelscript/sdk/docs/manual/index.html
AngelScript comes with a function that does most of the work; all that would be needed would be to feed it the command.
Python is object-oriented. Lua is procedural.
Python dictates (ie: forces you to use) a specific object-oriented model, whereas Lua doesn't. Some projects are better written procedurally, rather than using objects - and vice-versa. Lua gives you the power to do both.
I prefer Python because it has better support for Crunchy Frog and Holy Hand Grenade libraries.
They are pretty much independent of each other. Besides, Python which we know today is at least 2.3/2.4, beginning its history in early 2000s. 1.x branch wasnt as successful, and generally is very different from 2.x
Python is multi-paradigm, supporting both prodecural and (semi-)functional paradigms in addition to OOP. It does not force you into anything. In fact, its one of the most flexible languages I've ever used.
I'd say most of them, actually, since interpreters already do parsing and execution on the fly, so eval() implementation is generally trivial. Python supports such interaction out of the box, with debugging modules. Introspection is one of key features of Python, after all.
I haven't used Python for 10 years (and didn't like it then) and I've never used LUA, but I think LUA would be a better choice for two reasons :
Beside that, being a C/C++/C# developer, I strongly support the possibility of using C++ to develop mods as well. Frogboy, were you thinking of using some sort of virtual machine to run C++-like scripts or to allow for linking libraries written in C++?
And just for kidding, I will add some weight for the Fortran 77 support. Nothing like some common blocks declarations with different types of data to make the youngsters realize how nice modern languages are.
To clarify my other posts
If the mod plan is something like this.
level 1. basic xml files for easy small changes.
level 2. Scripting language to allow more complex stuff
level 3. SDK
Why in the world would you choose a language for #2 that isn't drastically easier to learn than #3?
Here's my other question on this, is it supposed to be low entry? or are you simply looking for what language the most people already know? because this forum is basically full of people vying for the language they are most comfortable with and its ignoring the actual road block to new modders.. which is how easily they can jump into modding.
If my options are learn python for mid level functionality or learn C++ for much more functionality, to me learning python would seem a waste of time and effort since there are certain to be things that are outside of pythons capabilities and its still a rather complex language to wrap your head around for a non programmer.(something most popular scripting languages simply ignore is ease of use for a layman)
In a perfect world you would put ole Jon to work developing an in house scripting language for kumquat games thats designed with the idea of being as simple as possible for non programmers. Designed with mid level functionality but maximum simplicity.
Or include a scripting program of some type to help people with learning the practical applications of whichever you choose.(see nwn scripting for this.. its not that nwscript is that simple of a language its some frankenstien of C and C# but all the functions constants etc are easily looked at and dissected via the aurora toolset).
What i don't want to see is the commonly accepted modding tools of, download X runtime then you can mod it.. theres some tutorials online somewhere that will help you get started. Which pretty much leaves the user to bash his way through learning a language without any sort of idea of the practical applications of modding the particular game they are attempting to learn it for.
World isn't perfect.. and only you know what exactly you expect the scripting language to be able to accomplish. So which ever you choose.. if i do decide to slug through learning a new language on my own to mod elemental it certainly wont be level #2 unless Lua is drastically easier to learn than python or C++ or there is some actual attempt at easing someone into using the selected language.
Sorry for the long winded clarification.. back to your scheduled programming.
my drop of water would be a bias toward LUA,
but my smart suggestion would be BOTH, so that modders can work in which ever they are most comfortable in as long as it does NOT cause slowdowns, graphics glitches or memory leaks.
harpo
Lua so i dont have to deal with indents... lol.. so annoying especially when modding others mods and dealing with script online/forums that can 'change'..
Well, then I shouldn't say anything as I'm unfamiliar with both, but I'll just chime in like most others
In my opinion the main question should be "Which language makes modding easier ?".
Going by most posts, and by the comparing the numbers linked by Heavenfall in reply#1, I'd tend toward Lua.
Also
which sounds like it's made for modding, giving a natural way to say "my object is like this standard object,except ..." - but I'll defer to those fluent in Lua to say whether it is as easy as it sounds.
I also think performance is a red herring - there's work underway to make the python VMs faster.
But if this
comes true, I'd like to support the suggestion ...
Basically, I'd like to call for a C(++) API that makes it easy to integrate a scripting engine. I'd suggest that the official interpreter be integrated via this API, and that this integration be available in source code to show how it is done.
PS: I hate the quoting system - and the forum needs a preview
I believe all this talk about 'complexity' is too overrated. Actual complexity in such embedded scripting language depends on (1) DSL/API design, (2) quality of supporting tools for the engine and documentation.
Both Python and Lua (and C++, actually) can be bended in very different shapes, pretty much to anything StarDock wants. And since most of modders will use only provided DSL/API, language itself would not make any difference.
If SD provides nice interactive debug tools with introspection capabilities and built-in docs, and explain how to use these to non-programming crowd, it would be trivial for them to learn ANY of these languages.
Good example is python's (but, once again, SD will have to implement their own one anyway so it would be properly integrated with engine and support introspection and docs for DSL/API) debug/introspection/docs, like:
For C++, for example, it would make everyone's life much easier if there would be tool which would generate all needed boilerplate code so even non-programmer could use it by writing only actually needed code.
All of these langauges allow C/C++ stuff to be bound to the interpreter for use in scripts, so all that would be needed is away for the 'other' langauges to bind wrappers for their scripts to the 'main' interpreter. Or in simpler terms it makes it look like the stuff from its scripts are really native code. The main issue would be getting the scripts loaded by the proper interpreter. If they choose to make this possibe (it will require things to be structured to support it) then the choice of langauge would come down to the one best able to interface with the others.
The one that is most likely to have issues is Lua, as it could be difficult to add script objects/class as such.
Note:
Likely the interpreter of the primary scripting langauge would be used to access the functions form DLLs anyways. This is because calling functions with unknown (at compile/build time) parameters is kind of trick; especially if you want to avoid using assembly. And the interpreter will have all the needed code pre-made, which would keep Stardock from having to redo that work.
The problem with Lua would come if Stardock wants to pass game objects to script functions and allow access to the engine's data. It could still be done, but it would be harder and make things more difficult for the other interpreters.
Of course, having had more time to think about it creating wrappers for functions unknown at run-time is problematic. The simple way would be needed is an interpreter that can take 'function objects'* and have them used as functions. I do not think any of these interpreters support that kind of thing. The other option would be to provide the ability to register a dynamically generated a wrapper function in the main interperter's langauge.
* A block of data that can be used as a function.
If either Fortran or Cobol is used, then it would likely be the first time in years that the shelves of books on those langauges have a purpose.
There are many great features available to you once you register, including:
Sign in or Create Account