473,889 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

On Java and C++

Java programmers seem to always be whining about how confusing and
overly complex C++ appears to them. I would like to introduce an
explanation for this. Is it possible that Java programmers simply
aren't smart enough to understand C++?

This is not merely a whimsical hypothesis. Given my experience with
Java programmers --- the code they write and the conversations they
have --- Occam's Razor points to this explanation. For example,

"Oooh I'm confused about the difference between pointers, references,
and objects! How confusing!"

"Oooh operator overloading confuses me! The expression x + y is so
confusing, who knows what's happening with that? If x and y are
complex numbers, what the hell could x + y mean?"

"Oooh multiple inheritance is so confusing! Though I am both a father
and a programmer, I still find it so confusing how the same object can
be two different things! How confusing!"

"Oooh and virtual bases are so bizarre! I am a student --- myself
'the father' is the same student as myself 'the programmer' --- but
nonetheless the idea of virtual bases is absolutely confounding and
confusing to me!"

Again, Occam's Razor is a valuable tool here. In deciding among
competing hypotheses, choose the simplest one. To impartial observers
of indoctrinated Java programmers, the explanation is simple indeed.

Apr 26 '06
458 21648
Phlip wrote:
People are learning that technology in their lives that fails the most
is software. And C++ is leading the charge.

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.

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
May 3 '06 #331
werasm wrote:
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
May 3 '06 #332

Alex Buell wrote:
On 3 May 2006 01:02:01 -0700 "werasm" <w_*****@telkom sa.net> waved a
wand and this message magically appeared:
I was suprised to see on a VxWorks course that none
programmed in C++.
That's because C is better for this sort of work. How else will you
manage to shoe-horn zillions of features into an embedded device with
only 2MB of flash ROM and 16MB of memory?

BTW, most of our hard to find bugs were due to C. sprintf and
strcpy/strncpy and arrays being the culprits. The other irony is that
people programming in C usually have some convoluted form of OO of
their own that is less efficient that what is generated by your C++
compiler. Often they use virtual dispatching mechanisms etc. with
elaborate fpointer matrices etc. I've been lucky enough to maintain
large C projects (iRmx). No thank you - absolute chaos!



Take a nap, it saves lives.

May 3 '06 #333

Chris Uppal wrote:
werasm wrote: 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.

Thanks for that. Interesting. Of course, a C++ compiler can also be
implemented in C. I still maintain (from experience) that most of our
problems relate to the C part of C++. I also maintain that the C part
is necessary as many API's still rely heavily on them. Also, many
current C++ libraries rely heavily on those API's.



May 3 '06 #334
Oliver Wong wrote:

That sounds wrong to me. Did your browser already have a JVM started
(as is
likely if -- for example -- you'd visited Roedy's site since you last
all your Firefox windows) ?

No. I retested just now (quit firefox, went into task manager to make sure
no hidden firefox.exe process was running), and got a similar result
(between 2 and 3 seconds). I do have Eclipse running in the background,
but as I mentioned earlier, I doubt Firefox is sharing the JVM with

Hmm, interesting.

I imagine that having Eclipse open will have some effect, because the JVM DLL
is already paged-in, and (as I understand it) the data used by the new "class
data sharing" will also have been paged-in.

If you are interested enough to check what happens if you close Eclipse, you
should do something big (start Acrobat or MS Office ;-) to encourage Windows to
flush the cached DLL and CDS data out before trying the applet again.

-- chris
May 3 '06 #335
Bent C Dalager wrote:
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
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.).

The native stuff which implements the lowest layer of AWT is probably the
single biggest chunk of native code in the library[*]. Principally because
between the AWT/Swing worldview, and that of (say) Windows, is pretty
complicated. (I have no idea why more of that complicated task isn't done in
Java -- maybe it's just historical, or maybe it's that not /all/ of it can be
done in Java so they felt it was better to keep all the mess in one place.)

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.

I think that was the BigInteger/BigDecimal stuff.

-- chris
[*] and probably the buggiest part of the entire library too -- just to stay
on-topic for this thread ;-)
May 3 '06 #336

"peter koch" <pe************ ***@gmail.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .

Roedy Green skrev:
On 27 Apr 2006 12:45:27 -0700, "peter koch"
<pe************ ***@gmail.com> wrote, quoted or indirectly quoted
someone who said :
>That is simply false - and most probably a bloody lie. About on par
>with the other posts I've seen from you. Others might want to have a
>look at

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++.
First let me reinsert the part you accidently snipped: you wrote:
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
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.

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Interesting read, but in fairness that's like asking James Gosling what he
thinks about Java vs. C++ (you'd get an equally biased opinion). Nobody's
refuting C++ is better for some things and has features that are superior to
the way Java deals with the same problem. It's just that it can be turned
around on other language features and be just as valid.

What bothered me is the apparent superiority complex of some C++ fanatics
involved in this thread as well as having most replies focused on
undermining the opinion of someone rather than come up with technical
arguments for either case. Any notion that the ability of a developer is
directly related to the complexity of the language they're familiar with is
a bit naive in my opinion. C++ definately is more complex, definately
requires more knowledge to produce results the same results and definately
gives you more control. The point of discussion is whether or not those
points are advantages or disadvantages (or just features that thrive in
certain situations/applications, and are completely in the way in others).

Oh and by the way, i forgot exactly who did so, but somehow deriving the
quality of the average Java programmer by the quality of the questions asked
in a newsgroup is retarded. A larger part of the people that get into
software development nowadays will go for Java (or any other "new" language
like C#) rather than C++, so it's pretty reasonably to assume more "noob
questions" end up on Java and C# forums compared to the C++ one. An actually
interesting statistic would be to see how many people moved from C++ to Java
and vice versa. That would average out any language fanatics either way. And
whether or not said beginners made a good language choice will probably
always be a point of hot debate, but i suppose they have the employment
market in their favour.
May 3 '06 #337

"Mishagam" <no*****@provid er.com> wrote in message
news:uF******** ***********@tor nado.southeast. rr.com...
peter koch wrote:
Walter Bright skrev:
Roedy Green wrote:

This principle is evident in things like power tools and aircraft
design. In the former, you've got to do extra work to remove things like
guards and safety interlocks. In aircraft design, one of the terrible
no-no's is for a mechanic hook up the flight controls backwards. So the
designers go to great lengths to make it very hard for the mechanic to
do so, hopefully hard enough so that at some point the mechanic realizes
he must be doing something wrong. If it's easy to install the flight
controls backwards, sooner or later it will be, with deadly

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
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.

Finally...well said.
May 3 '06 #338

"peter koch" <pe************ ***@gmail.com> wrote in message
news:11******** *************@j 33g2000cwa.goog legroups.com...

Bent C Dalager skrev:
In article <11************ *********@g10g2 000cwb.googlegr oups.com>,
peter koch <pe************ ***@gmail.com> wrote:
>Large parts of the C++ libraries are implemented in C++.

This is also the case with Java. Even the Java compiler is implemented
in Java.

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

Swing is (99.9%?) pure Java, but it's built on top of AWT which is mapped to
native OS widgets (and thus a bit of a design flaw in my opinion). Actually
Swing was introduced largely to remove inconsistencies of the GUI on
different OS as well as get rid of the (particularly buggy) AWT components.
JDBC just provides an interface. Most JDBC implementations indeed use JNI
interfaces. Vector is obviously completely Java, i suggest you actually look
into Java before commenting here. The general way of things in Java is that
if it *can* be done within Java, it *will* be done within Java. Some things
cant be done in Java and thus require JNI or whatever, and i'll be the first
to agree that that's a weakness, but that's the price you pay for having
other things. Whether or not you're willing to pay that price depends on
personal preferences but even more on what you're actually trying to do.

And that's exactly the point many people i'm trying to make. In the case of
JDBC for example, Java defines an interface for certain functionality. The
fact that the implementation of such an interface involves native code is
not actually that relevant, apart from the fact that you know the people
most capable of implementing it are the ones that generally do it (in other
words, the Oracle JDBC drivers are implemented exclusively by Oracle
engineers etc.). That isnt to say there arent any design flaws in Java
and/or it's APIs, but the general concept i quite agree with. It provides a
huge number of standards (or at least standard ways to do things). Sometimes
those restrictions will be in the way, in which case C++ is a very capable
alternative, but in most other cases it reduces time-to-market, is built on
proven technology (rather than reinvent the wheel), and dare i say it, less
capable Java developers can still produce commercially viable products
because some worries are removed (ofcourse this is more a business
consideration rather than an actual strength of the language, but worth
mentioning nonetheless).
May 3 '06 #339
On 3 May 2006 02:43:51 -0700 "werasm" <w_*****@telkom sa.net> waved a
wand and this message magically appeared:
That's because C is better for this sort of work. How else will you
manage to shoe-horn zillions of features into an embedded device
with only 2MB of flash ROM and 16MB of memory?

Oh you can - see "Inside the C++ object model" by Lipman. However,
you've enforced my point - the compatibility (with C) is necessary. I
must mention that the course was back in 2000. I have programmed in C+
+ since for the VxW OS :-).

You're probably right. Yesterday, in a fit of utter boredom (I'm
currently unemployed but keeping my skills in use by writing
applications in C++), I used GNU C++ to write a text-based battleship
game. I found it a lot easier to develop.


Take a nap, it saves lives.
May 3 '06 #340

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what the issue is. Thanks Ravi
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to connect to the DB I get the following exception at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2120)
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
by: Mark Fink | last post by:
I wrote a Jython class that inherits from a Java class and (thats the plan) overrides one method. Everything should stay the same. If I run this nothing happens whereas if I run the Java class it says: usage: java fit.FitServer host port socketTicket -v verbose I think this is because I do not understand the jython mechanism for inheritance (yet).
by: jaywak | last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)) and in both cases, get the following list returned from calling getDeclaredFields() on java.lang.ClassLoader via this code snippet: Field fields = loaderClass.getDeclaredFields(); for (int i = 0; i <...
by: jaimemartin | last post by:
hello, I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in Linux there is an error. The code that fails is the following: SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); I´m sure that code is ok. In fact, I´ve found that in several...
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.