Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Is Python underestimated with what it can do?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • This topic is locked This topic is locked
33 replies to this topic

#1 Eamonn Rea   Members   -  Reputation: 54

Like
1Likes
Like

Posted 02 August 2013 - 04:57 PM

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.



Sponsor:

#2 frob   Moderators   -  Reputation: 22235

Like
7Likes
Like

Posted 02 August 2013 - 05:14 PM

I think you summed it up well enough.

 

Python is a great language on its own.  It has many strengths.  String processing and filesystem manipulation are among those strengths.

 

Python also has weaknesses.  Some things are difficult to accomplish, and many operations require a deceptively large amount of processing power.

 

 

 

Personally I find that Python is most useful in tools.  Many tools operate on the command line.  Many tools operate with text-based intermediate file formats.  Having a Python script manipulate XML documents is easy. Having a Python script manage complex conditional build scripts is often straightforward.

 

Python is an excellent language.  It is one of several that I recommend all programmers become conversant in.  (The others must-know languages include C++, C#, Java, JavaScript, and Perl.)


Edited by frob, 02 August 2013 - 05:15 PM.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.


#3 Eamonn Rea   Members   -  Reputation: 54

Like
0Likes
Like

Posted 02 August 2013 - 05:47 PM

You described it well: Python is good at making tools. Integrating it with Java could mean making GUI's in Python(since it's so simple to do so), and have Java do the heavy stuff. I believe Minecraft uses Jython.



#4 SeraphLance   Members   -  Reputation: 1438

Like
3Likes
Like

Posted 02 August 2013 - 05:59 PM




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.



#5 Hodgman   Moderators   -  Reputation: 31017

Like
2Likes
Like

Posted 02 August 2013 - 07:41 PM

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.

#6 swiftcoder   Senior Moderators   -  Reputation: 10236

Like
3Likes
Like

Posted 03 August 2013 - 06:09 AM

It's also worth pointing out that there are efforts underway to make Python much, much faster.
 
Don't expect it to catch up to C anytime soon, but the performance difference is nowhere near as large as it used to be...


Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#7 Bregma   Crossbones+   -  Reputation: 5247

Like
5Likes
Like

Posted 03 August 2013 - 07:27 AM


I'd like to point out that Gimp was written in C/C++, and it's quite slow at responding a lot of times.

The gimp is written in C (not C++) and is very fast.  It has a scripting extension that uses Scheme, because developing in a scripting language (like Python) is very fast compared to developing in C (in particular, the Gimp ToolKit, aka GTK).  If you find something in the gimp to be unresponsive, it's likely a scripted part, both because interpreting scripts is relatively slow and because those parts tend to do massive data processing.

 

The first big advantage of Python is rapid development time.  In today's world of disposable everything, the cost of a developer's time needs to be minimized so an application can get to market as quickly as possible.  Python has a lower learning curve so you can hire inexperienced, inexpensive developer monkeys to churn out code, and since the product is disposable it doesn't have to work well, it just has to get into consumers' hands quickly so money can be exchanged.

 

The second big advantage is the Python is Fast Enough.  Yes, it's slower than native code, but humans are slow.  When it comes to most human interaction software, you do not need the fantastic speed geeks brag about.  The parts that do need speed can be delegated to lower levels written in native code (for example, OpenGL).

 

Combine those two advantages, and it makes Python an excellent and recommendable choice for not only a first language when learning programming, but a go-to language for many general purposes.  It's not always the best tool for a particular job, but it's an appropriate tool for many jobs, including game development.


Stephen M. Webb
Professional Free Software Developer

#8 Eamonn Rea   Members   -  Reputation: 54

Like
-4Likes
Like

Posted 03 August 2013 - 11:55 AM

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.



#9 swiftcoder   Senior Moderators   -  Reputation: 10236

Like
7Likes
Like

Posted 03 August 2013 - 01:50 PM

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.

Nope. Though there are a number of ways to write C extension modules that can be loaded by Python programs (ctypes, Cython, etc.)
 

I saw a benchmark somewhere, and it said that Java 7 was slightly faster then Python, but Python's catching up.

Benchmarks are easily manipulated. If you look around the internet, you can individual benchmarks where Java or Python are hundreds of times faster than C/C++. They are not however representative of general performance.
 

Another thing: Python is faster than Lua, I think. I saw a benchmark somewhere

Again, benchmarks are flexible. Last I checked LuaJIT was faster than Python on most benchmarks, but your mileage may vary.
 

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.

Language performance has (perhaps surprisingly) very little to do with the performance of software. Computers are fast, you can write performant software in "slow" language, and many people manage to write hideously slow software in C++.
 

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.

Most commercial games are built using game engines, yes. But those game engines have to be written in something... Usually C++.
 

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.

You seem to be missing the fact that Python is already a hugely popular and successful programming language:


Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#10 Memories are Better   Prime Members   -  Reputation: 769

Like
5Likes
Like

Posted 03 August 2013 - 02:21 PM

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.



#11 thok   Members   -  Reputation: 693

Like
1Likes
Like

Posted 05 August 2013 - 04:21 AM


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/.)



#12 thok   Members   -  Reputation: 693

Like
4Likes
Like

Posted 05 August 2013 - 04:42 AM

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.



#13 thok   Members   -  Reputation: 693

Like
2Likes
Like

Posted 05 August 2013 - 04:46 AM

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



#14 thok   Members   -  Reputation: 693

Like
3Likes
Like

Posted 05 August 2013 - 04:52 AM


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



#15 Karsten_   Members   -  Reputation: 1637

Like
0Likes
Like

Posted 05 August 2013 - 05:47 AM

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_, 05 August 2013 - 05:48 AM.

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.


#16 Eamonn Rea   Members   -  Reputation: 54

Like
-1Likes
Like

Posted 06 August 2013 - 04:21 AM

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. 



#17 swiftcoder   Senior Moderators   -  Reputation: 10236

Like
3Likes
Like

Posted 06 August 2013 - 05:24 AM

[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.


Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#18 Angus Hollands   Members   -  Reputation: 717

Like
0Likes
Like

Posted 06 August 2013 - 06:42 AM

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.



#19 Hodgman   Moderators   -  Reputation: 31017

Like
1Likes
Like

Posted 06 August 2013 - 07:01 AM

[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

#20 superman3275   Crossbones+   -  Reputation: 2061

Like
0Likes
Like

Posted 06 August 2013 - 11:09 AM

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.


I'm a game programmer and computer science ninja ph34r.png!

Here's my 2D RPG-Ish Platformer Programmed in Python + Pygame, with a Custom Level Editor and Rendering System!

 

Here's my Custom IDE / Debugger Programmed in Pure Python and Designed from the Ground Up for Programming Education!

Want to ask about Python, Flask, wxPython, Pygame, C++, HTML5, CSS3, Javascript, jQuery, C++, Vimscript, SFML 1.6 / 2.0, or anything else? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

hobohm.business@gmail.com

or Personal-Message me on here smile.png!





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS