[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: Re: [pygame] Python and Speed



On Fri, Apr 18, 2008 at 9:23 AM, Ian Mallett <geometrian@xxxxxxxxx> wrote:
> OK, my point here is that if C languages can do it, Python should be able to
> too.  I think all of this answers my question about why it isn't...

You don't have to use C to get fast programs.  OCaml is very fast
(between C and C++), especially when you start doing interesting
things.  It comes with an interpreter, a bytecompiler, and an
optimizing compiler.  Also, there is OCamlSDL, which is the pygame of
the OCaml world.  http://ocamlsdl.sourceforge.net/

It takes a little bit of brainbending to wrap your mind around the
OCaml language, but once you figure it out you can write real programs
quickly, and have them be very optimized.

I prefer hacking around with pygame and python because you get so much
flexibility.  You don't have to declare variables, you just use them.
You don't have to muck around with makefiles.  You can mix different
types of data in dictionaries.  It is just easier, but the price you
pay is performance.  In a typed language like OCaml, the compiler
might know that every entry in a dictionary is an integer so it can
optimize every access.  In python, the interpreter has no idea what
will come out when you request a key, it could be an integer, a sprite
object, None, ...  The programming languages community is working
feverishly to combine the benefits of typed languages with the ease of
use of dynamic languages, but it is an ongoing effort.
--
Nathan Whitehead