It should also be noted that C++ itself isn't fundamentally a fast language
from a design perspective (and if you make the mistake of having a lot of
"new"s and "delete"s going off at inopportune times you'll see its true
potential sluggishness). Its primary benefit is that it lets you talk to
hardware more-or-less directly which lets you the intelligent programmer
(with the help of the compiler) align the interests of the hardware with
the interests of the problem you're trying to solve, whereas Python is
mostly about just solving the problem even if it takes a long time to
compute. Which makes it an excellent platform to learn anything abstractly
(like game design) off of while not simultaneously fighting with the
language on account of hardware being a particular way. You can focus on
learning algorithms and data structures that improve efficiency in a
language-agnostic way and with Python's flexibility you can also explore
algorithms that don't usually get mentioned in the C++ world that may fit
your particular case (and learn to love native dictionaries/hash tables and
lists).

Sufficiently smart compilers have been able to compile Haskell and
(slightly annotated) Common Lisp to code that beats C++ for a long while
now, and FORTRAN is still used in some circles because it's still very fast
for number crunching. Projects others mentioned like PyPy continue to
narrow the margins though they've got a ways to go. Unfortunately talking
to hardware directly with Python usually means doing it with C/C++ then
talking to those libs from Python. (As is the case for PyGame's core (SDL
in C), PyOpenGL, etc.) I'd like to say this is the standard approach for
most Pythonistas: write everything in Python, then rewrite the slow bits in
C/C++. Fortunately a lot of the reasons we might need to talk to the
hardware (graphics drivers, screens, fast number crunching) are general
enough that other people have done most of the work for you to take
advantage of. Even in the FPGA world where you get to design your own
hardware with code, there's the MyHDL project which provides Python with
nice sugar for HDL code and compiles your source to Verilog or VHDL which
you'd normally write instead at your own peril and frustration.

Reply via email to