Why is python not written in C++ ?

L

Lawrence D'Oliveiro

The problem has nothing to do with the relative merits of the
languages. The problem is inertia.

So how was C++ able to get popular in the first place? And how was Java able
to grab some share from it?
 
P

Paul Rubin

Lawrence D'Oliveiro said:
Yeah, unfortunately the language was designed by a committee ...
It seems apt to describe the resulting design as “bulletproofâ€, but
“elegant†or “concise†... not so much.

I'd say the Ada standardizers went to a great deal of trouble to specify
and document stuff that other languages simply leave undefined, leaving
developers relying on implementation-specific behavior that's not part
of the standard. Ada itself is not necessarily more complicated.
 
P

Paul Rubin

Lawrence D'Oliveiro said:
So how was C++ able to get popular in the first place? And how was
Java able to grab some share from it?

C++ made improvements over C that were necessary and welcome for
controlling the complexity of large programs, while remaining mostly
upward compatible with C. Java abandoned C compatibility and added
memory safety and GC. That got rid of legacy-related pain and improved
program reliability and eased debugging considerably, at some cost in
performance. Java was also on the OO bandwagon of the 1990's, which
translated into good marketing back then, but is part of the cause of
the massive bureaucracy and bloat in the Java runtime environment. C++
seems to have made something of a comeback because of this, and Java now
has generics patterned after C++'s.
 
C

Carl Banks

Building on C's popularity helped.

AT&T + Money + C backward compatibility

Good question.  Both IBM and Sun put a lot of effort/money behind
Java.

Sun + IBM + Money + 90s Web trinkets


Carl Banks

(haven't seen a Java applet in ages)
 
C

Carl Banks

 Java was also on the OO bandwagon of the 1990's, which
translated into good marketing back then, but is part of the cause of
the massive bureaucracy and bloat in the Java runtime environment.  C++
seems to have made something of a comeback because of this, and Java now
has generics patterned after C++'s.

When I first studied Java, my first impression of the language was
that it had a Prime Directive that, "other than single inheritance and
being kinda like C, don't do anything C++ did".

Not a bad policy, actually. However, omitting generics was probably
the second worst thing about Java (the worst thing being the awful AWT
design).


Carl Banks
 
R

Roy Smith

Lawrence D'Oliveiro said:
So how was C++ able to get popular in the first place? And how was Java able
to grab some share from it?

C++, for all its flaws, had one powerful feature which made it very
popular. It is a superset of C. Whatever that may mean from a
technical standpoint, it made the language feel safe and comfortable and
low-risk to managers. From a more technical standpoint, it had the very
real advantage of being able to include all the C system headers and
link against C system libraries.

As for Java, that's easy. You could launch Java applets from inside a
web browser. In those days, anything related to the web was a one-way
express ticket to fame and fortune.
 
L

Lawrence D'Oliveiro

I'd say the Ada standardizers went to a great deal of trouble to specify
and document stuff that other languages simply leave undefined, leaving
developers relying on implementation-specific behavior that's not part
of the standard.

OK, I have a copy of K&R 2nd Ed on a shelf within reach here. Can you point
out some behaviour that C programmers might need to rely on, that is not
specified in that document?
Ada itself is not necessarily more complicated.

It is. Look at its baroque type structure. Hint: why is

type A is B;

a syntax error?
 
P

Paul Rudin

Lawrence D'Oliveiro said:
Actually, it never was.

Wondering off topic a bit - I am reminded of something I once read in
some MS blurb... it described something as an "extended subset" of some
standard or another. (Think about it :))
 
T

Tim Chase

OK, I have a copy of K&R 2nd Ed on a shelf within reach here. Can you point
out some behaviour that C programmers might need to rely on, that is not
specified in that document?

"need to" is considerably different from "might". Size of an
int, assumptions that int=pointer, evaluation order of postfix
increment/decrement...

http://stackoverflow.com/questions/...plementation-dependent-language-features-in-c

or http://tinyurl.com/263jayy if mailers between here & there
break the URL)

Just because facilities (macros, best-practices, etc) have been
established for some of these things doesn't mean a programmer
will reach for them if their code happens to work locally without
them. Trust me...I've encountered PLENTY of such code in
production before I left behind (for the most part) the world of C.

-tkc
 
E

Edward Diener

I can't understand why any serious programmer mentions C++. As soon as I
read it, I have to rush either to the kitchen to find a bowl to throw up
in, or head for the toilet so I can talk to the great white telephone.

It must be because we can not be as phenomenally intelligent as you
evidently are from your comment.
 
P

Paul Rubin

Lawrence D'Oliveiro said:
OK, I have a copy of K&R 2nd Ed on a shelf within reach here. Can you point
out some behaviour that C programmers might need to rely on, that is not
specified in that document?

C has all kinds of undefined behavior. "Might need to rely on" is not
relevant for this kind of issue. Ada's designers had the goal that that
Ada programs should have NO undefined behavior.

As a famous example of C's underspecification, the behavior of

a[i++] = i;

is undefined in C99. See:

https://www.securecoding.cert.org/c...n+order+of+evaluation+between+sequence+points
 
B

Britt

On Mon, 2010-08-02 at 01:08 +0200, candide wrote:

I would propose that in fact most programming languages are implemented
in C.  Sun's (Oracle's) Java compiler and runtime are written in ANSI C..
The core of the Gnu Compiler Collection (which includes C++ and
Objective-C compilers) is written in C.

The open-source GCC Ada compiler (GNAT) is written in Ada. The GPL'd
compiler source code is available at http://libre.adacore.com/libre/
 
N

Neil Hodgson

Paul Rubin:
C has all kinds of undefined behavior. "Might need to rely on" is not
relevant for this kind of issue. Ada's designers had the goal that that
Ada programs should have NO undefined behavior.

Ada achieves this by describing a long list of implementation defined
behaviour (Annex M).
http://oopweb.com/Ada/Documents/Ada95RM/Volume/m.htm
As a famous example of C's underspecification, the behavior of

a[i++] = i;

is undefined in C99.

Ada does not define ordering in all cases either. For example the
order of elaboration of library_items (essentially the order in which
modules are run in the absence of explicit declarations) is defined for
GNAT as

"""
first elaborating bodies as early as possible (i.e. in preference to
specs where there is a choice), and second by evaluating the immediate
with clauses of a unit to determine the probably best choice, and third
by elaborating in alphabetical order of unit names where a choice still
remains
"""

Other compilers use different orders.

I just love that "probably".

Neil
 
R

Roy Smith

Lawrence D'Oliveiro said:
Actually, it never was.

Yes, there are a few corner cases where valid C syntax has different
semantics in C and C++. But, they are very few. Calling C++ a superset
of C is essentially correct.

It is certainly correct from the level of a risk-averse development
manager deciding if he or she is willing to use C++ for the first time.
Fear of the unknown is a powerful deterrent. It's a lot easier to
accept something like C++ because "it's just a superset of C, and we've
been using C for years".

I suspect the same effect contributed to Java's success as well. "Look,
it's got curly braces and semicolons. It's just like C!"
 
D

David Cournapeau

Yes, there are a few corner cases where valid C syntax has different
semantics in C and C++.  But, they are very few.  Calling C++ a superset
of C is essentially correct.

This is only true if you limit yourself to C89 (as python seems to
do). If you start using C99 (and lot of people do, if only because
they don't realize it because gcc is quite relax about it), then
almost no non trivial C code is valid C++ in my experience.

David
 
R

Roy Smith

Yes, there are a few corner cases where valid C syntax has different
semantics in C and C++.  But, they are very few.  Calling C++ a superset
of C is essentially correct.

This is only true if you limit yourself to C89 (as python seems to
do). If you start using C99 (and lot of people do, if only because
they don't realize it because gcc is quite relax about it), then
almost no non trivial C code is valid C++ in my experience.[/QUOTE]

I'm not following you. If anything, C99 makes C closer to C++. Can you
give me some examples of valid C99 which is not also valid C++?
 
D

David Cournapeau

This is only true if you limit yourself to C89 (as python seems to
do). If  you start using C99 (and lot of people do, if only because
they don't realize it because gcc is quite relax about it), then
almost no non trivial C code is valid C++ in my experience.

I'm not following you.  If anything, C99 makes C closer to C++.  Can you
give me some examples of valid C99 which is not also valid C++?[/QUOTE]

variable size array, the meaning of inline, etc... In addition to int
f(void) vs int f(), legality vs illegality of p = malloc(n);, type of
enum, keyword incompatibility (new, delete, etc...) which are already
there in C89.

I have yet seen a project where you could build C code with a C++
compiler - the only ones I know are specifically designed that way and
it is painful.

David
 
L

Lawrence D'Oliveiro

David said:
I have yet seen a project where you could build C code with a C++
compiler - the only ones I know are specifically designed that way and
it is painful.

I seem to recall a FAQ entry, might have been on kernelnewbies.org, asking
why the Linux kernel wasn’t written in C++. The answer explained that at one
time there was an experiment to make the kernel compilable with a C++
compiler, without actually using any C++ features. The result: they lost
about 10% in speed. That was enough to put the kernel developers off taking
the experiment any further.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,796
Messages
2,569,645
Members
45,369
Latest member
Carmen32T6

Latest Threads

Top