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.
For all the people suggesting C++: as they say in France, "Le no." It is notoriously hard to parse correctly, which results in compilers that aren't very smart about giving good error messages -- a huge factor in a new programmer's ability to learn the language. Besides, anyone that wants to develop in C++ can already use it to build DLLs; not a lot of special support needed. I don't know much about AngelScript, but dear God. C++ has many strengths, but its syntax is not one of them.
Either Lua or Python would be a perfectly fine choice. The tradeoff there is that while Lua runs a lot faster (since it essentially "compiles" into bunch of function pointers, whereas Python becomes bytecode which is interpreted), it doesn't have much in the way of a standard library. Even for such essentials as string manipulation, you have to roll your own or find a third-party library. They are out there, but there is no "standard".
Python, by contrast, adds a big hit to your binary but that's because it includes a rich standard library. Yes, there's the "web server in 3 lines of code" stuff, but it also thoroughly covers the bases in terms of data structures & algorithms, which are useful in a wide range of situations. It also has a compiled representation of bytecode that can be written to disk, which can save you on startup time if you have a large number of scripts to deal with.
Not in its favor, though, Python is a bear to integrate, although that might have changed since the last time I looked at it. Barring that, Lua is the hands-down winner there.
I also find Python script has a high "torque ratio," i.e. you can get more done in fewer lines of code, and I second (or third, or twelfth) the "easy to learn" mantra. I recognize that some people have not found that to be true, but having taught Python to non-programmers in the past, I will say that those folks are anomalous.
IMHO, Lua works best if you are looking for a thin, dynamically-modifiable layer you can use to drive functionality exposed by the game engine. If you want to do extensive game logic, I would prefer Python due to its vast standard library. That being said, I will reiterate: either one will work.
After reading most of this thread, i have come to a most logical conclusion. Fortran and cobol are simply far too efficient. We should go with object oriented turing as the language of choice. There is simply nothing else that compares.
Shakespear.
/sarcasm
It is if you do not like having to type more than you need to. It may not be pretty, but it is short and to the point. And the ugliest stuff is saved for the things beginners should not mess with.
I would just like to throw it out there that I decided to try to learn C++ while waiting for a scripting language to be announced. Imagine my surprise when it turns out I already know the basics. Apparently I've been using a c-like scripting language for years. I'm still going through the tutorials but so far it's matching up quite well. The preprocessor and declaring data types are a new step, arrays look needlessly complicated... but all in all I think I might just stick to c++ (or angel script, it it lives up to the hype)
Hello all, it has been e long time since I last posted.
I am a developper ( c++ mainly) that has to use lua and python in big c++ projects : - first uses lua ( implementation luabind) and was real-time physical dynamic engine ( for industry) developped a french research lab - second uses python ( swig + boost:: python) and is a 3d software called Vue
So my two cents in this discussion :
The two scripts languages have both pros and cons but, more importantly, I think they have not the same use:
- Lua is better for fast scripts that run everywhere in the program but have a great need for performance, but just using the objects. For example it is very easy and efficient to make a bunch of c++ components that are linked with lua scripts, allowing to change the links dinamically. ( i have seen this for a sound engine that was connecting/disconnectign different treatment modules when treating the signal.)
- Python is better for more heavy scripts that redefined part of the behaviour of the c++ components it use. With boost:: python, it is really easy to instantiate objects from virtual C++ classes redefining some behaviour. It allows you to make very generic c++ algorithms with redefining behaviour at runtime using virtual methods. I think python ( not really used it yet for that but will soon) can be great for assembling, defining dynamic UI.
One last advice: choose carfully what implementation you use and don't choose SWIG.
Good luck
Speaking for myself, Python sounds like a PITA with the white space issue. It also sounds like Lua has more industry support. Lua sounds like it's more of an object based language like Smalltalk. Smalltalk takes a different mindset but it's not a hard language to learn once you make the mental shift.
As far as C++ goes, I don't think the idea was to replace Lua/Python with C++ but to augment it.
There are many great features available to you once you register, including:
Sign in or Create Account