Sign in to follow this  
Eamonn Dev Rea

Is Python underestimated with what it can do?

Recommended Posts

I've read various articles, blog posts, etc on Python: All of which list it's pros and cons, though they tend to either say it's slow or good. It's said to be a good beginners language: And I whole heartily agree. Any programmer can admit Python is a great beginner language. It sets a good example for OOP and encourages people not to use D&D Programs. But, alas, it is said to be bad as well.

 

Python not for game development? Panda3D, Unity of Command, Frets on Fire, Toontown, EVE Online

 

But, a lot of people argue that you should not use Python because of speed. Some say it's too slow for anything, others say it's good at some things.

 

So, my question is: Is Python underestimated? From what I can tell, it seems to be a fairly good language, and it being so simple to pick up makes it a great language. Google Chrome is partially written in Python. Some of Linux is written in Python.

 

Obviously Python would not be capable of a high-end Call of Duty clone, but really, the only language suited for that is C/C++ simply due to it's speed.

 

So, what is Python's limits? Is it as good/bad as people make it out to be? I recently finished a programming tutorial series on Python 2.7.2, and it's really got me into Python.

 

A lot of programmers start with Python now-adays, but they tend to only start with Python.

 

I'm not sure if it's true, but I've heard of some viruses being written in Python as well. I've heard you can do a man-in-the-middle attack with Python, using a certain library. I wouldn't like to do this; not only because it's illegal, but because I believe there are other languages better suited toward this. Also, I'm not so sure it'd be easy to cover your tracks in Python.

 

Python is also meant to be quite good at making the GUI's, and letting another language like C or C++ do some of the heavy work.

 

All in all, this is just to satisfy my own curiosity. In my opinion: Python is a great language! I often use it to test some ideas for game development quickly. It's fast at prototyping ideas, I'll give it that.

 

Also, I'd like to point out that Gimp was written in C/C++, and it's quite slow at responding a lot of times. I find that writing GUI's in Python is actually quite fast(for the coding of it and for the response time). So I guess some of it depends on how efficient your program is.

Share this post


Link to post
Share on other sites




Obviously Python would not be capable of a high-end Call of Duty clone, but really, the only language suited for that is C/C++ simply due to it's speed.

 

When people say python is "slow", this is what they mean.  Lots of people go into gamedev thinking they're going to make the next CoD, or that learning anything that won't go towards eventually making the next CoD is a waste of time.

 

It's great for certain classes of tools (e.g. the ones that don't involve heavy GUI development, like a map editor or something -- I'd use C# for that), for scripting and for embedding into other games to write code more productively.

 

It's not very fast.  However, that's not something that should be examined in a vacuum.  The only important question is whether a language is "fast enough" for your needs.  for 99% of the people working in gamedev in any way, shape, or form, python is "fast enough".

 

There are certainly gripes I have with the language.  I think it's hard to work with on projects of scale.  I think it's slow for certain classes of projects, and it's very hard to actually optimize it for speed when you have to due to the heavy abstractions in the language (though you can always convert stuff to C).  However, I think most people recognize python as a vital tool, and really, along with Lua, C#, C++, and Java, it's one of the most popular languages for gamedev, so I don't realy think it's "underestimated" at large.

Share this post


Link to post
Share on other sites

Obviously Python would not be capable of a high-end Call of Duty clone

Some parts of call of duty ARE written in a slow, interpreted language... So actually, python definitely could be used to replace those particular parts of the COD code base.
AAA games are made using many languages, exploiting the strengths and mitigating the weaknesses of each of them.

Share this post


Link to post
Share on other sites

Some very interesting replies. Python will never replace C or C++, but it doesn't need to. You can write C in Python, and C is pretty much as fast as Python. I think you can also write C++ in Python, though you might need a library or something. I've never looked into it(mostly because I'm not too fond of C++, and just really don't want to look into C Python until I've learned a lot more of Python(e.g. How to parse XML and JSON and such)).

 

It's fast prototyping makes it a valuable language, as a few people mentioned.

 

It's good to know there are efforts to make it faster. I saw a benchmark somewhere, and it said that Java 7 was slightly faster then Python, but Python's catching up. Java is a good language for game development(at least IMO), so does this mean if Python gets "much, much" faster, it would get as fast(if not faster) than Java? Either way, if it's almost as fast as Java, that's proof enough for me that Python is underestimated and under-ranked.

 

I'd also like to say that Python might not be good for writing games entirely, but maybe as a scripting language for games. For example, World of Warcraft was written in C/C++, but uses Lua for scripting.

 

Another thing: Python is faster than Lua, I think. I saw a benchmark somewhere comparing Lua, Python, Java and C#(C# won, By the way). This is strange, because Garry's mod is mostly(if not entirely) written in Lua. I've briefly played Garry's Mod, and I didn't see any performance issues. At the very least you can write add-ons in Lua, but even then they are very responsive. I'm not sure about this, and haven't seen anything to back this up, but apparently the guy that wrote Garry's Mod made a language based on Lua to code it. What leads me to believe this is false is that when the game is loading, I see it says "loading *.lua". If it was written in Lua, and Python is faster then Lua, then could you not write a game like Garry's Mod in Python? AFAIK Lua is interpreted too. I did get a little side-tracked, but it's still got to do with Python.

 

If Python got faster then Java, it'd be the ultimate beginners language because:

 

1) Easy to learn

2) It'd be fast -- Assuming we're in the future when it's "much, much faster"

3) You could write basic 3D games in it(Panda3D)

4) You could write an awesome 2D game(PyGame, PyGlet, Cocos2d)

5) It can be used as a scripting language in games

6) Kids can learn it easily, helping young people get into code the right way(not using GameMaker or anything)

 

Also, CoD games are usually not written in a language at all from the developer, from what I've heard. If they are, it's usually C/C++, but not often. They usually use Game Makers like Unreal Engine or UDK or something. Maybe this is false, but I thought'd I'd put that out there.

 

Don't get me wrong: I love Python, I really do, but I just wish it could be used for more uses and people saw how much of a good language it is - For beginners and Experts alike.

Share this post


Link to post
Share on other sites


I think it's hard to work with on projects of scale.

 

I agree with most of what you've said, except for this statement. Although I don't know understand exactly what you mean by "projects of scale", I'm going to guess that you mean "large projects". Feel free to correct me if that is not what you meant. If it is what you meant, this is simply not true. OpenStack, for example, is written in Python: http://www.openstack.org/. I would consider this to be a large project, anyway.

 

As a side note: Python is great for scripts, one-off tools, and quick-and-dirty prototypes, but anyone who says that's the _only_ thing that it's good for has probably never written a significant application with it. (Source: In my day job I develop on an open-source seismic hazard assessment engine, which can run regional and global scale calculations and is entirely written in Python. See http://openquake.org/.)

Share this post


Link to post
Share on other sites

Some general comments about "speed". Disclaimer: I code (mostly) in Python as a full time job.

 

First of all, performance isn't just about language choice, but also algorithm choice. An inefficient program written in a "fast" language is still inefficient. So I don't think it makes sense to just label a language as "slow". As others in the thread have said already, sometimes just "fast enough" is sufficient.

 

Second, you have to take into account speed of _development time_. I realize that this is more of an economic measure, and that most everyone in the thread so far has been focused on speed of _performance_, but do not underestimate the value of this. If the need for development speed is greater than the need for sheer performance, a higher-level language, if it is just "fast enough", is a good choice.

 

Third, and this is a comment specifically about Python, many of the standard and third-party libraries available have parts of them written in C, thus they can be quite performant. This is a really nice feature in my opinion. The combination of high-level interfaces and the option to write extensions in C to address your worst computation bottlenecks is a pretty good combination and makes Python a good choice for a wide variety of applications.

Share this post


Link to post
Share on other sites

All languages seem to get degraded, lets just call it language insecurity or e-religion, I mean if you compare the language comparison threads with theological comparisons you would actually be quite amused on how similar they are, which would probably explain why some people are obsessed with defending their language of choice while criticising others and religiously sticking with it lol.

 

The important thing is that you are learning / increasing your knowledge, it doesn't matter if its C, Python, C++, C# or even assembly, the more you practice the better you get (providing ofc you are actively learning and not just assuming stuff in other words making mistakes) and the closer you will get to your compiler God.

Totally agree with this. I think that instead of discussing "what makes language X is better than language Y, Z, etc.", I think it's more worthwhile to discuss "what makes language X good", period. Otherwise, it's just religion, complete with witch hunts and stoning. =P

Share this post


Link to post
Share on other sites


You seem to be missing the fact that Python is already a hugely popular and successful programming language:
EVE online (among other games), is written largely in Python.
A good chunk of Google's infrastructure is written in Python.
Python is the scripting language of choice for content creation packages like Maya.
TIOBE ranks Python as the world's 8th most popular programming language.
And so on...

 

A few more specific examples of "popular" applications that I know of:

 

- OpenStack

- Blender (for scripting, not the application itself)

- The backend for yelp.com

Share this post


Link to post
Share on other sites

We use Python for our build server and it works great, as for games, it is certainly a powerful scripting language but we prefer lighter alternatives such as using native C++ (which the rest of the game is written in anyway) for (compiled) game scripts. Less effort needed for writing binding layers and there are very little speed issues ;)

 

One great example of where python was used was Vampire the Masquerade Bloodlines. It allowed the community to fix the bugs and expand the game, long after support was dropped by Troika Games (RIP). If I was writing a heavily scripted RPG game, then python could possibly be a great choice because I personally find Lua a little too light on standard functionality (i.e it can be fantastic but only if effort has been spent creating i.e maths libraries for it).

Edited by Karsten_

Share this post


Link to post
Share on other sites

I often thought "Well, if you can write C in Python, does that not mean you can write a game library in C and call it from Python? Then, really you're using a C library, but with the beginner friendliness of Python!". A great example of this IMO is PyGame: Basically a very thin wrapper of SDL for Python. I, personally, don't like SDL, and maybe that's why I dislike PyGame. You have to do a LOT of stuff yourself e.g. function intervals(for an update/draw function), you have to check for key presses yourself, etc. For C++ I think SFML is a great choice. There is a Python wrapper for SFML, which is probably due to SFML being based on C++, and like mentioned before, you can easily port a C/C++ library to Python with effort. Lua is meant to be great for porting C libraries. I agree, Lua is a little light on the base, but isn't that the point of Lua? It's designed to be lightweight, and part of that is good and part is bad. Good, meaning it's easily implementable in your project(part of the reason a lot of game companies use it over other things like Python or Squirrel), but bad because it doesn't have stuff like OOP or '+=', '-=', '*=', '/=', '++', '--', etc. OOP is easily implementable via tables and metatables though. I, personally prefer Python's way of handling OOP. 

Share this post


Link to post
Share on other sites

[Lua is] bad because it doesn't have stuff like OOP or '+=', '-=', '*=', '/=', '++', '--', etc.

Operator overloading has nothing to do with Object Oriented Programming. Absolutely nothing.

 

And while we are at it, Lua does in fact support operator overloading.

Share this post


Link to post
Share on other sites

It's quite easy to spend a large amount of time describing small features that, for you, mean your language of choice is "the best".

I will start by saying that I love Python. I find I enjoy writing Python more than C++, JavaScript or PHP (and a few other languages in the mix).

Firstly, one of the reasons that we have so many languages is in simple terms, because one person may write a language around one core concept, and thus realising applications / libraries that work with that concept is much easier / runs a lot faster.

 

One of the significant misconceptions about Python is speed. To some extent these are unfounded. A large proportion of benchmarks that "observe" this result involve a script which is unoptimised. Now, first of all, by unoptimised I don't mean squeezing every last processor cycle out of your application. But, I find that in Python, it's easier to write a slow application because there are many ways of realising an end goal, and not all of them are a good choice in respect to the speed of the application. 

However, some of the concerns are valid. Python is interpreted, and with that there comes a loss in performance, with a gain in flexibility. I'm very much interested in PyPy, because there benchmarks (and others using it) are converging upon that of C, and in some optimised cases, outperforming it for certain tasks. Now, the latter is a case of optimisation, as mentioned by a previous poster. It's hard to compare language speed overall because it comes down to where you want to compare (the sample application). 

 

Anyway, I believe that it is inevitable that Python will find itself increasingly at the core of games and large scale software, but whether that's in CPython, PyPy or another implementation remains to be seen.

Share this post


Link to post
Share on other sites

[Lua is] bad because it doesn't have stuff like OOP or '+=', '-=', '*=', '/=', '++', '--', etc.

Operator overloading has nothing to do with Object Oriented Programming. Absolutely nothing.

^This. Also, in my engine's Lua bindings, I choose not to use the ":" operator.
i.e. instead of writing object:method(arg), i write class.method(object, arg)
...but it's still OOP tongue.png

Share this post


Link to post
Share on other sites

As a programmer who's been using Python to make games for a few months now (Check out my developer blog to see the code for some basic projects like Pong and Breakout coded in Python), the performance has more to do with how aware you are of python's limitations. I've known since I started Python how fast I could expect it to run and how I would code in it, so I coded using the mindset that I should write the fastest, most readable code I can. And I would only "optimize" it whenever it was actually slow.

 

So far its been great. For Three-Dimensional games it will probably be just as good if you use the proper algorithms to render efficiently.

Share this post


Link to post
Share on other sites

I didn't say anything about this magical weird thing called "operator overloading". I thought they were math shorthand operators.

 

I also said "Lua is bad because it doesn't have stuff like OOP or [...]". I used OR.

 

I didn't think Python was as popular as this. There's only 1(mostly dead) forum for it. Strange and cool :D

Share this post


Link to post
Share on other sites

Are you  betraying Lua/Love2d ? If you keep changing  languages that does not mean you can do python games..You should be ashamed.

For 2D games you don't need a super language because you are not doing to many calculations and things like this.So don`t worry any more about performance,do games ! Anyone on this forum can say that the performance in a 2d game will always be in any language's okay,of course if you are not doing stupid calculations.]

 

Edit:Maybe if you want to make the next Limbo,Braid or Terraria you should pick C#/Monogame , Java/Libgdx or C++ if not choose anything else and it will be fine

Edited by vladmihail

Share this post


Link to post
Share on other sites

I don't understand what is happening in this thread.

 

Interpreted languages and VM languages are not intended to replace their lower-level counterparts. You don't drive nails with screwdrivers and you don't screw things together with a hammer, but you use both to build a house. It doesn't make sense to try and start a competition between the hammer and the screwdriver. You use tools appropriately for the task at hand. 

Share this post


Link to post
Share on other sites


Interpreted languages and VM languages are not intended to replace their lower-level counterparts.

I don't see any particular reason why not.

 

Microsoft research wrote an experimental OS entirely in managed code, and there are rumours that they may be commercialising it.

 

If your OS isn't written in native code, why should anything be?

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this