473,842 Members | 1,835 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 21557
Roedy Green <my************ *************** ***@munged.inva lid> wrote:
On Thu, 27 Apr 2006 20:09:24 +0200, Martin Vejnr <av****@volny.c z>
wrote, quoted or indirectly quoted someone who said :
For some reason, you've put the most important statement in parentheses.
RAII is one of the two reasons I stick with C++. I don't know of any
other language that would support such concept. (C# and D both support
RAII, but require the programmer to explicitly mark objects that should

The equivalent in Java is called finalizers. This is one of the most
unsatisfactory parts of Java. One problem is guaranteeing ALL the
finalizers will be run on shutdown. The whole business is a bit flaky
and most people avoid using them.

Sorry to jump in, but it's terribly misleading to call finalizers the
Java equivalent of RAII, even with all the qualification above. Without
a doubt, try/finally is the Java equivalent of RAII, with all that is
implied by the asymmetry of the two. I'd hate to see someone misled
into using a finalizer for this.

So what are finalizers good for? Causing programs to run out of memory
by interfering with the garbage collector. That, and pretty much
nothing else, except for MAYBE the possibility of displaying diagnostic
messages telling programmers that they forgot to close a resource, but
it would be best to disable that in a production build to avoid the
program correctness problems that finalizers imply; some kind of ant
magic, perhaps.

The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Apr 28 '06 #131
Roedy Green <my************ *************** ***@munged.inva lid> wrote:
I think we will come to regret type erasure in generics.

"Will come to"? I'd say it more like this: We have been regretting type
erasure in generics for the last year and a half.

The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Apr 28 '06 #132
* Roedy Green:
On Fri, 28 Apr 2006 01:19:40 +0200, "Alf P. Steinbach"
<al***@start.no > wrote, quoted or indirectly quoted someone who said :
Apart from the lack of connection from premise to conclusion, that's not
a fact, it's an excuse for sloppiness.
In java, memory leaks and packratting are quite different problems and
require quite different tools to detect them and quite different

Exactly how can the memory leak that cannot exist, be detected and
require a different solution?

If you wished, you could make the same distinction in C++, but you
don't because the distinction does not matter so much for C++.
On the contrary, in C++ it's meaningful to talk about different kinds of
memory leaks, such as when there's still a reference somewhere, what you
call a "packrat", and when there's no reference anywhere. If the case
of no reference couldn't exist, as in Java, then it would be meaningless
to distinguish it. That distinction is meaningless for Java.

there is no way on earth you will convince us that C++ memory
allocation is easier and more fool proof, especially when you don't
even claim to know Java.

I have not made the claims you assert. I don't believe that you talk on
behalf of "us", as you imply. Perversely, I hope you're trolling.

A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Apr 28 '06 #133
On Fri, 28 Apr 2006 05:24:37 +0200, "Alf P. Steinbach"
<al***@start.no > wrote, quoted or indirectly quoted someone who said :

Exactly how can the memory leak that cannot exist, be detected and
require a different solution?

If you discovered a true leak, you have to create an SSCCE and submit
that to the JVM vendor, or the AOT run time vendor.

See http://mindprod.com/jgloss/sscce.html
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #134
On Thu, 27 Apr 2006 20:56:35 -0600, Chris Smith <cd*****@twu.ne t>
wrote, quoted or indirectly quoted someone who said :
Bingo. There are a lot of things that would make sense about freedom of
choice if you only had to deal with your own code.

One of the more remarkable things about Java is how easily code from
different sources can be cobbled together.

Everything follows the same commenting conventions for example so you
can create Javadoc (automatically generated documentation) as a
unified whole.

This blending works because, for example a HashMap from Source A will
be the exact same beast as a HashMap from Source B. The collection
can be passed freely back and forth without special glue.

Even when you use vendor specific implementations like SQL, JCE
(cryptography), JMF (media), JavaMail (email), vendor packages all
hook up using the same API. Sun has a defined a standard pluggable
API for darn near everything.

You can plug in a free implementation, or a high performance one, or a
special features one. You can have different customers with different
service providers all running the exact same object code.

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #135
"Noah Roberts" <ro**********@g mail.com> wrote in message
news:11******** *************@e 56g2000cwe.goog legroups.com...
>Hey, my CPU will run C++ byte code natively but there are no CPU's that
>run Java source code...guess Java sucks then.

There are machines that run Java bytes codes directly. But even such
machines have some microcode or other assembler assists to handle the
lowest levels. see http://mindprod.com/jgloss/picojava.html

[blah blah blah JVM blah blah]

I know all about that. Point is that it was asserted that C++ is not
as good as Java because Java binary code will run on some processors
but C++ source code won't. This is just stupid...almost as stupid as
me having to point this out to you.

I definately hear a vacuum...

If you think you are being witty, vacuum boy, you are falling short.

You can't use 6th grade rhetoric to try to convince a group of people who
have been using Java for years that suddenly it "sucks" because you say so.
You can't ignore counter arguments and expect people not to remember that
one post ago you posted something grossly inaccurate.

You hide behind a thin veil of intelligence - but it only works among the
ignorant. Don't argue with experts about things you don't know. You only
succeed in making yourself look stupid. Almost as stupid as me having to
point this out to you.


Apr 28 '06 #136
"Roedy Green" <my************ *************** ***@munged.inva lid> wrote in
message news:de******** *************** *********@4ax.c om...
Your name Noah, suggests you might be the son of fundamentalist
parents. Fundamentalists are people who are utterly convinced their
faith is the one true faith, and guarantee they never change their
opinion by scrupulously avoiding studying any others.

And then pass it on to their children ;)


Apr 28 '06 #137
On Thu, 27 Apr 2006 19:59:45 -0700, Walter Bright
<wa****@digital mars-nospamm.com> wrote, quoted or indirectly quoted
someone who said :
Operator overloading should be used only for the purpose of making user
defined types work like built-in types.

If operator overloading comes to Java, I would hope that matrix
overloaded plus would not use + (already confusingly meaning both
addition and concatenation See

I would hope they would use a high Unicode character that looks like +
but would not easily be confused with it such as \u2a01

see http://mindprod.com/jgloss/unicode.html to view the glyphs.
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #138
On Thu, 27 Apr 2006 21:08:49 -0600, Chris Smith <cd*****@twu.ne t>
wrote, quoted or indirectly quoted someone who said :
"Will come to"? I'd say it more like this: We have been regretting type
erasure in generics for the last year and a half.

You and I have certainly, and a number of others. By "we" I mean the
entire Java community including Sun an the inventors of generics.
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #139
if you need power and performance from a language then you can expect
it to be simpler.

java scores in free and special purpose libraries.

Apr 28 '06 #140

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 Im 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); Im sure that code is ok. In fact, Ive 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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets 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: 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: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.