On Java and C++

P

peter koch

Roedy Green skrev:
C++ has more addressing modes than other languages except for
assemblers. So obviously they are not "necessary" in some absolute
sense. They are only necessary in the legacy sense. Java has only one
addressing operator.

This is not quite true. Take old fashioned Pascal as an example. Pascal
has all the adressing modes of C++. Algol has (had) more.

Java has two adressing modes - one for the ints and one for the
objects. And this approach is simple but with drawbacks.

/Peter
 
J

JustBoo

Java Progammer Criteria?

a) You don't have to think [...]

Okay. No thinking when programming...
b) You don't have to bother to use auto_pointer (not working with

Never having to bother... yeah.
c) You don't have to decide about programming style. Sun provided

No decisions... right.
d) You don't have to decide about naming of files and classes - they are
the same.

Once again.
e) Logical package directory structure is forced on you.

Likes being "forced." Ugh...
f) You don't have to choose between char *, string, CString ... - String

Once again.
g) you don't have to choose between long int, unsigned int, WORD, DWORD,
size_t .... - close to optimal choice if forced on you.

Ohhh, yes, how horrid to have to actually make an informed decision. I
feel for you.
h) You don't decide do you use internal or external functions

I'm starting to see a pattern.
i) You don't have to decide if you use methods or define new operators.

There IS a *clear* pattern. Quite clear.
Java choice is sometimes more verbose, but usually more clear.

Well apparently it's *not* the Java programmer who is going to be
clear, so something has to be, right? I mean s/he is too busy not
making decisions, right. I get the feeling there would be lots of
left-over rotten food and sticky keyboards that could never be decided
upon either. Hygiene would be something to consider though.
As you can guess, I can continue.
Dropping all these choices first - makes programming easier, you have
less things to bother about,

If you were never meant to be a programmer in the first place I
guess.... Hmm, VB and Java programmer are a lot alike. A river in
Egypt, baby, a river in Egypt....

Wow, given that list I would feel more comfortable paying a monkey to
code my apps. Why pay a human just to follow the banana around when I
can get chimps to do it for less.

"Some drink at the fountain of knowledge... others just gargle."
 
P

peter koch

Roedy Green skrev:
Have you read the book? Were in there on BIX when Stroustrup dropped
by for a month or two?

I have read the book and numerous articles from Bjarne describing the
evolution of C++.

Stroustrup wrote a book about his trials designing C++ called the
Design and Evolution of C++ with a sprouting oak tree on the cover. He
was heavily constrained by his committee of C users who insisted on
strict upward compatibility. The language was designed and implemented
a bit at a time. He was never permitted to have a reintegration/tidy
up phase.
So tell me - where was that committee insisting on strict backward
compatibility?
What was those trials Bjarne faced?
What tidy up phase was he forbidden to have?
I felt much better about C++ knowing at Stroustrup was on my side in
wanting a cleaner language. It was just he was not forceful enough to
persuade his committee of bosses focused on the current job (which was
not designing a new language) of the need.

When did Bjarne try to persuade his "committee of bosses" to let him
write a cleaner language?
If anyone would care to spend just a few minutes at his website, they
would find your description at best grossly misleading. As I said
before, I see it as a bloody lie.

Just a few quotes from Stroustrups homepage:
(Would he rather have created something like Java?)
No. Java isn't even close. If people insist on comparing C++ and Java -
as they seem to do - I suggest they read The Design and Evolution of
C++ (D&E) to see why C++ is the way it is, and consider both languages
in the light of the design criteria I set for C++. Those criteria will
obviously differ from the criteria of Sun's Java team. [...]Much of the
relative simplicity of Java is - like for most new languages - partly
an illusion and partly a function of its incompleteness.

(About comparing C++ to other languages)
[...]That said, I consider C++ the best choice in programming language
for a wide variety of people and applications.

(Are there features Stroustrup would like to remove from C++?)
Not really. People who ask this kind of question usually think of one
of the major features such as multiple inheritance, exceptions,
templates, or run-time type identification. C++ would be incomplete
without those. I have reviewed their design over the years, and
together with the standards committee I have improved some of their
details, but none could be removed without doing damage.

/Peter
 
W

Walter Bright

peter said:
Your comparison with the aircraft design is also not quite fair. When
you write software, you hopefully do lots of testing and review before
slipping anything out the door - and this testing can easily be done
without any deadly consequences. In my opinion, these dangerous
facilities in C++ come in handy in some situations (e.g. when you
implement the std::vector class!) and are very easy to avoid. The first
review will easily find them.

No comparison or analogy is perfect, but such cross-pollination from
seemingly unrelated fields can be very useful. In a former life, I
worked on aircraft flight control systems for Boeing. I learned an awful
lot about practical ways to make things safe and reliable in the
presence of unreliable, perverse human beings. A lot of those ideas
*can* be transferred to the practice of computer programming.

Airframe design testing can be done with little to no risk to life and
limb. There's very little that cannot be simulated on the ground in an
appropriately designed test rig, or in computers.

Boeing's test pilots are incredibly good. If you're lucky enough to snag
a ride on a test flight, if they happen to be looking up at the ground,
the most you'll likely get out of them is a laconic "cool".

http://www.707sim.com/images/texrole.jpg
 
J

JustBoo

People are learning that technology in their lives that fails the most often
is software. And C++ is leading the charge.

Do you have a credible citation for that? The C++ part I mean. Thanks.
 
P

Phlip

JustBoo said:
Do you have a credible citation for that? The C++ part I mean. Thanks.

If I made it up, I could also make up "C is leading the charge", because
that's the language all these penetratable systems are usually written in.
Same difference, and yes I agree with Werner that robust and bullet-proof
C++ is easy to rapidly write...

Click the link I provided; it's a symptom of a major source of these
defects. And many shops hire people to read the code and review it looking
for nothing but these obvious problems.
 
M

Mishagam

peter said:
Walter Bright skrev:


I do not disagree with you here. C++ is not the perfect language,
inheriting as we all know some of the bad stuff from C - including
arrays.
What you can do is not teach beginners about e.g. pointers, build in
arrays and stuff like that. Just as e.g. Koenig and Moe do in their
introductory text.
I myself, and probably many people out here use C++ only because they
naturally come to C++ from C.
In my opinion, C was very good language for his time. It was not safe,
but it was very clear. You always knew exactly what is going on.
C++, on the other side, is current, very bad overcomplicated language. I
myself use it only because it easily allows me to use only small subset
of it's features and still use Microsoft MFC relatively efficiently. I
am sure this ability to use small subset of C++ (which programmer is
familiar with) is what allows C++ to still be generally popular language
now.
If you will strongly insist on using only new, 'SAFE' C++ features there
will be no reason at all to use C++, it will quickly become small niche
language to addicted.
 
M

Mishagam

peter said:
Roedy Green skrev:


Are you talking about C++ references and C++ pointers? While they might
be identical under the covers, they have widely different semantic uses
and you can't substitute one for the other.
C++ references are not SO different from pointers. Just like Roedy Green
said - one more addressing mode. I doubt any well designed language
(like Java) would have (or has) references.
 
M

Mishagam

Walter said:
For a stupid language nobody uses, the D programming language is doing
remarkably well, having moved up to number 19 on
http://www.tiobe.com/tpci.htm
One part of being uninformed about language is being uninformed about
this language status ;)
But still asking "OK, are there any stupid features in D?" in this
thread is not very clever, because in this thread we talked about C++
and Java most people knew about, and because most people here don't know
D nobody knows D stupid features and so D language could get unfair
advantage.
This is why I posted my answer (at the top).
 
M

Mishagam

Luc said:
It would appear that the rise in Python users (From virtually nothing)
corresponds almost exactly with the drop in Java users. VB also rose,
which probably stole a little java use.
There are many strange features in this chart. Why C always so much
higher than C++? Why VB started growing now when it is losing MS support
and there isn't any reason to use VB?
What is measured here anyway?
 
L

Luc The Perverse

Mishagam said:
There are many strange features in this chart. Why C always so much higher
than C++? Why VB started growing now when it is losing MS support and
there isn't any reason to use VB?
What is measured here anyway?

It would be funny if it were something dumb - like number of applications
being run by what they are written in
 
J

JustBoo

JustBoo wrote:
If I made it up, I could also make up "C is leading the charge", because
that's the language all these penetratable systems are usually written in.
Same difference, and yes I agree with Werner that robust and bullet-proof
C++ is easy to rapidly write...

Yep. All it takes is learning ones craft, rather than wanting the
"tool" to do all the work for one. (Btw, I've read enough of your
posts to know *you have* learned your craft, so absolutely nothing
personal in this reply. But then we have the Java guys....)
Click the link I provided; it's a symptom of a major source of these
defects. And many shops hire people to read the code and review it looking
for nothing but these obvious problems.

http://c2.com/cgi/wiki?MicrosoftSampleCode

That link right above? Dude... man... that's ALL straight C code. I
don't see a C++ construct anywhere in sight. :-D

If you drop your keys into molten lava just let 'em go
'cause, man, they're gone. - Jack Handey
 
N

Noah Roberts

Mishagam said:
C++ references are not SO different from pointers. Just like Roedy Green
said - one more addressing mode. I doubt any well designed language
(like Java) would have (or has) references.

Java has references.
 
M

Mishagam

Noah said:
Java has references.
Excuse me. I meant separate references and pointers with so close
functions. Java has references, but they have also some features of C++
pointers like they can be null.
 
W

werasm

Phlip said:
In general, >70% of all software features are not used as first delivered,
and malware is a crushing burden on global productivity. We have a new form
of war on our hands - a new kind of arms race.

Yet when you look at the sources of security breaches, over and over again
you find the things that sloppy C++ programmers revel in. Double deletes,
array overruns from unchecked buffers, runaway recursion, gratuitous
typecasts, etc.

Yes, its time that we get a good book on exactly how software can be
exploited (what to look out for). Maybe they are around. I haven't seen
one in the Bjarne Stroustrup series though, which is what I have come
to like to read.

As far as the things you've mentioned are concerned, they are quite
rare, and with a little of experience easy to spot. Simply look for
sprintf, strncpy, memcpy, memset - replace arrays with vectors, using
at() for indexing. Prohibit c-style casting (actually, prohibit C, or
tuck it away where no one can see it, testing the tucked away part well
- most legacy API's are C - hence the unfortunate need for
compatibility). I was suprised to see on a VxWorks course that none
programmed in C++. There is a lot of embedded code running out there
and still being developed every day. Most of the projects I work on
interface with the hardware very closely. Runaway recursion, hmmm -
sometimes recursion can reduce code and make it much simpler (Tower of
Hanoi, quicksort etc). Is recursion only applicable to C++ as
programming language, if so, one more reason to use it :).

Hmmm, that's Win32 for you. A good c++ implementation would hide that
as far as possible - but you know that! Yes, it compiles with a c++
compiler - so does assembler. Obviously non-standard.
People are learning that technology in their lives that fails the most often
is software. And C++ is leading the charge.

No, not C++ - the humans using it (BTW, maybe its the Win32 API with
hundreds of ways to do things and no organised documentation indicating
more correct ways). As far as stability is concerned, IMHO the standard
is pretty clear on when you should test your code before trusting it,
aside from many authoritative books written on the subject.

The biggest thing the Java guys (SUN) did was to give humans less
freedom - this cut out >50% of their problems. Leave the hard work to a
couple of guys that know how to develop software (BTW, in which
language was their VM written). Programming in sub-standard teams
before I could appreciate the value in this. This does not mean I
personally enjoy programming in C++ far more than other languages (I
have not tried D, BTW - I appreciate that they maintain templates with
similar flexibility that C++). As far as ruby is concerned, I've tried
it briefly, and it's a bit too loose for my liking. Maybe I should try
it more before commenting.

Kind regards,

W
 
C

Chris Uppal

Oliver said:
(referring to http://www.tiobe.com/tiobe_index/images/tpci_trends.gif
as of May 2nd, 2006): I wonder what happened in 2004 that made Java drop
considerably, and everything else jump up a bit.

From the TIOBE faq:

Q: What happened to Java in April 2004? Did you change your methodology?
A: No, we did not change our methodology at that time. Google changed its
methodology. They performed a general sweep action to get rid of all kinds of
web sites that had been pushed up. As a consequence, there was a huge drop for
languages such as Java and C++. In order to minimize such fluctuations in the
future, we added two more search engines (MSN and Yahoo) a few months after
this incident.

-- chris
 
C

Chris Uppal

Phlip said:
If I made it up, I could also make up "C is leading the charge", because
that's the language all these penetratable systems are usually written in.

I think that PHP is making a credible attempt for top-dog status here.

As is Java if the posts in this (c.l.j.p) newsgroup are anything to go by --
huge numbers of posters appear to see nothing even faintly questionable in
assembling SQL queries by concatenating user-supplied strings...

-- chris
 
C

Chris Uppal

werasm said:
The biggest thing the Java guys (SUN) did was to give humans less
freedom - this cut out >50% of their problems. Leave the hard work to a
couple of guys that know how to develop software (BTW, in which
language was their VM written).

The current series of JVMs from Sun are written mostly in reasonable quality C
sprinkled with a little C++ dust to help structure it. I.e. it needs a C++
compiler, but a C-only programmer could follow most of it without difficulty.
IIRC there is also some assembler in there.

Other JVM implementations are written in other languages. Perhaps the most
interesting technically (at several levels) is the IBM Jikes Research JVM which
is written entirely in Java except for a little assembler to allow it to
bootstrap itself.

The platform library is another matter, of course.

-- chris
 
B

Bent C Dalager

So e.g. Swing, JDBC and Vector are all implemented in Java? Without a
single JNI-call in the code? It seems my knowledge of Java needs an
update.

Swing certainly has native portions to interface with the native GUI,
as will generally any library that needs to access some native
third-party library (I/O, thread handling, etc.).

There is no reason for Vector (or its replacement, ArrayList) to have
native code and so they don't, and I don't expect JDBC has any but I
haven't actually looked.

I seem to recall that a while back, some maths functions were moved
from native code to Java code, resulting in a speedup of the maths
operations involved. Can't remember any details though.

Cheers
Bent D
 

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,794
Messages
2,569,641
Members
45,353
Latest member
RogerDoger

Latest Threads

Top