New to Python - Compiled Language?

Francis Avila francisgavila at yahoo.com
Tue Nov 4 00:56:32 EST 2003


"Relee Squirrel" <relee_s at hotmail.com> wrote in message
news:mailman.410.1067915526.702.python-list at python.org...
> Please reply both here and directly to my email address
> relee_s at hotmail.com
>
> I just found out about Python today and it sounds very interesting,
> but I'm having trouble finding solid information about my main
> question. Is Python a compiled language, or merely a sequence of
> commands fed into a seperate program?

I'm not sure how this distinction names corelatives, or even why it's
important.

Python is a bytecode compiled language (as opposed to machine-code compiled,
but see Psycho http://psyco.sourceforge.net/introduction.html (et al.?),
which compile Python to native machine code like a JIT compiler).

Python is also an interpreted language.  It interprets the bytecode.  (This
is, presumably, your "sequence of commands fed into a seperate program"?)

Python is also interactive:
Read:eval:print :: code:bytecode:interpreting bytecode.

...
> Is Python a language which can be compiled into an executable program?

Um, what do you mean by "executable"?  You can execute Python code, sure,
given a Python interpreter.  Python will simply compile it before running
the generated bytecode (compilation is transparent and fast enough that we
ignore it, for all practical purposes).  You can also only give Python the
bytecode, and it'll use that (these are *.pyc files).

Or, you can use Psycho.  (I think there's something out there that converts
Python to C code, too?)

Or, you can bind up the Python code with a Python interpreter, using py2exe
or workalikes.

Or, you can write C that uses the CPython libraries, but doesn't use the
Python interpreter.  It's arguable whether this is still Python, but hey.

But what computer language is there that doesn't produce--at least
theoretically--an executable program?

I simply don't understand your categories.  Python is a real-life bona-fide
computer programming language.  You write code, give it to the Python thingy
(whatever you want to call it), and it makes the computer do stuff.  Like
any language.

Python isn't a "scripting" language any more than lisp is.  It's not a very
good shell-script replacement (see perl for that); it's a general-purpose
language.  Does "scripting" mean "does not compile to machine code"?  Or
maybe it means "no pointers"?  "Scripting" names a problem domain, not a
language species (except insofar as that problem domain is a given
language's strength.  Even then, Python isn't a scripting language!)

I think you're probably going about this the wrong way.  Pythonistas
generally extend Python with C(++) for one of two reasons:
1) Because native Python simply isn't fast enough (rare)
2) To wrap libraries that aren't in Python (very common, so common that
there is boilerplate code in the distribution to speed you along.)

Otherwise, they program everything in Python!  So when I read this:

> the tools and utilities referred to existing in Python
> would increase the development time of my projects.

I think, "Well, just using Python would increase it even *more*!"
Then I read this:

> However, what I'm
> creating are programs, not just scripts.

I think, "What the?! Only C++ programs are 'real' programs?!"

Look, I know you said you just heard about Python, so I'm being far gruffer
than I should be.  I'm sorry.  I can't say anything specific because you
weren't very specific about how you think Python can serve your needs.  I
may be entirely off base.  However, there are only three ways *I* can think
of as to how Python could possibly help you:
1) Prototype your code in Python, then write it in C++.
2) Embed Python into an existing C++ application, as a "scripting language"
for that application.
3) Just write the whole darned thing in Python!

Try this: download Python, follow the included Python tutorial, and code up
some small non-trivial application that duplicates part of the functionality
of something you already have some C++ code doing in the application domain
for which you want to use Python's "tools and utilities".  I guarantee you,
that even if you code in a very un-Pythonic fashion, the Python code will be
simpler, shorter, clearer, more robust and powerful, have fewer bugs, be
more fun to write, and 9 times out of 10, fast *enough*.  Repeat this a few
times, and you'll probably want to stop using C++ altogether.

But that's just me. Explore the www.python.org site a bit more, and you'll
find many faqs, commercial success stories, tutorials, HOWTOs, links to
Python-related sites, the entire documentation for present, past, and future
language and library versions, tutorials, Package Index, etc, etc, where you
can learn more.
--
Francis Avila





More information about the Python-list mailing list