Is this a true statement: Part II

Grant Edwards grante at visi.com
Fri Jun 29 16:23:32 EDT 2001


In article <9hiifr$sjs$1 at taliesin.netcom.net.uk>, MDK wrote:

>Why is C++ awful; what's wrong with it?

Two important (somewhat subjective) qualities of a programming
language:

1. safe vs. unsafe

Languages like C and assembler are unsafe.  You can stomp all
over memory and crash your program (and possibly your system)
in fun and spectacular ways.

Languages like BASIC, Smalltalk, Pascal, Modula-3, LISP, and
Scheme are safe.  It is possible to write an incorrect program,
but it is not possible to create a bogus pointer, to allocate
memory and never free it, etc. IOW, your program may not do
what you want, but it doesn't crash your system.[1]


2. simple vs. complex

The syntax and semantics of languages like C and Scheme are
fairly simple.  A moderately skilled programmer can look at a
piece of code and have half a chance of figuring out what it is
going to do.  Other languages have complex syntax and semantics,
and it's hard to tell what is going to happen when you compile
and run a piece of code.

C is dangerous, but it's also simple.  That means that you
_can_ shoot your foot off, but the language is simple enough
that you can figure out how to avoid doing so.

Modula-3 is a bit more complex, but it's safe.  The compiler
won't let you shoot your foot off, even if you can't get the
program to do what you want.

C++ is both complex and unsafe.  It can shoot your foot off,
cut your arm off, impale you on a pike, or slowly poison your
food.  Unfortunately it's got so damn many buttons, knobs,
levers, bells and whistles, that it's impossible to tell how to
avoid being shot, impaled, poisoned, or otherwise
inconvenienced.

Even if you've figured out how to survive encounters with C++
Flavor X, Version Y, your experience is often useless with the
next flavor or version.

OTOH, Python (the language itself) is both simple and safe.
Some of the library modules are complex, and some of them are
written in C and are quite capable of crashing.

[1] So called "safe" languages often have extensions to do
    unsafe things (e.g. BASIC's peek() and poke(), Modula-3's
    linkage to "unsafe" modules).  But you have to go out of
    your way to get at the unsafe features, and they're not
    required for "every-day" programming they way they are in C
    or C++.

-- 
Grant Edwards                   grante             Yow!  I just forgot my
                                  at               whole philosophy of life!!!
                               visi.com            



More information about the Python-list mailing list