Re: Is C++ really used ?

Nasser Abbasi <nasser@apldbio.COM>
8 May 1997 21:29:47 -0400

          From comp.compilers

Related articles
[10 earlier articles]
Re: Is C++ really used ? kbreinho@bsquare.com (Keith L. Breinholt) (1997-05-08)
Re: Is C++ really used ? geert@sun3.iaf.nl (1997-05-08)
Re: Is C++ really used ? David.Monniaux@ens-lyon.fr (1997-05-08)
Re: Is C++ really used ? chase@world.std.com (David Chase) (1997-05-08)
Re: Is C++ really used ? clark@quarry.zk3.dec.com (1997-05-08)
Re: Is C++ really used ? cliffc@risc.sps.mot.com (Cliff Click) (1997-05-08)
Re: Is C++ really used ? nasser@apldbio.COM (Nasser Abbasi) (1997-05-08)
Re: Is C++ really used ? shankar@chromatic.com (1997-05-08)
Re: Is C++ really used ? bduncan@tiac.net (Bruce Duncan) (1997-05-08)
Re: Is C++ really used ? cfc@world.std.com (1997-05-12)
Re: Is C++ really used ? jocelyn_coulmance@hol.fr (Jocelyn Coulmance) (1997-05-12)
Re: Is C++ really used ? salomon@nickel.cs.umanitoba.ca (1997-05-13)
| List of all articles for this month |

From: Nasser Abbasi <nasser@apldbio.COM>
Newsgroups: comp.compilers
Followup-To: comp.lang.misc
Date: 8 May 1997 21:29:47 -0400
Organization: Compilers Central
References: 97-05-044
Keywords: C, Java, design

Dwight VandenBerghe <dwight@pentasoft.com> :
>You want a better alternative? Try Java. It's not Caml,
>but it's three giant steps in the right direction, and native Java
>compilers will be out soon that exceed 90% of C++'s runtime speed.
>You get garbage collection, you get pointer safety, you get OOP, you
>get thread safety, you get the right way of doing inheritance (single
>inheritance for implementations, multiple inheritance for interfaces)
>instead of the wrong way (only single inheritance, or full multiple
>inheritance ala C++). You'll like it, I bet.


One thing that is starting to bother me with Java is that everything
in it is pointer. ok, they are pointers that you can not abuse, but
the fact that all objects are references can be a problem.


As an example, adding an object to a a vector (using
vector.addElement( object ) will offcourse only add the reference to
the object, not the object itself, this can lead to a problem if in
some other part of the program you modify this object forgetting that
it is being referenced from some other part of the program, and when
later on, you remove it from the vector, expecting its value to be the
same as when you put it there, but it is not.


This sort of thing can happen very easily. in C++ one can supply copy
constructors and assignment operators to make copies of the
objects. sometimes I really want to copy the object over, not the
reference to it. in Java, one has to explicitly make deep copies of
objects by calling methods in them. I think the C++ way is better.


Another problem with Java is that there is no control of parameter
passing. In C++ I can use "const" to control this, in C++ I can use
refererences or not use them, I can have control on where my objects
reside, if I want them to be all on the heap or not, I have this
control.


Jave has no operator overloading, would you rather say


  A + B or A.add(B) ?


which is more natural? Java does not seem to me to be an algorithmic
langauge, I really rather say a[i] instead of a.elementAt(i) , with
C++ I can do this even if 'a' was an array of objects other than
primitive data types, I just have to define my own operator[] for the
class.


ALso Java has no enumeration data types. enumeration data types are
very important for good programming styles.


I still see some nice things in Java, the biggest advatage in Java is
that it is a language that runs on a VM, it is the VM that is the neat
idea, the Java langauge is OK, but not that great.


I dont think java is the one that will replace C++. C++ is complex
and big, yes, but at the same time it is a powerfull language, and
very expressive, and yes, if one is not experienced in it, one can
make big mistakes, I guess this is the trade off one has to pay.


I wish C++ had threads build-in, that would have been a big plus. as
for GC, I am not sure what is the big deal with GC, I actually find it
better if I have control on my memory allocation and deallocations. I
have been using Java for short amount (I probably written 10,000 line
only in it), but I have more memory problems with Java that I ever had
with C++, I guess I need to call gc() manually more often, or I must
be wasting memory somewhere, the fact that every thing in java is a
pointer and lives on the heap is something I find annoying, and I do
like that fact that C++ is a hybrid language, and not 100% pure OO.


IMHO offcourse.


Nasser
[I'm directing this discussion elsewhere, since "Why I love/hate/tolerate
language X" has little to do with compiler design. -John]






--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.