473,842 Members | 1,917 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
On Thu, 27 Apr 2006 21:37:37 GMT, "Oliver Wong" <ow***@castorte ch.com>
wrote, quoted or indirectly quoted someone who said :
So how about instead of characterizing a language as being universally
hard or universally bad, we just accept that some people find it difficult
to program in C++, and so C++ is not the language for them? Similarly, maybe
some people find it difficult to program in Java, and so Java is not the
language for those people.


I would be happy with that if people making the comments had working
knowledge of both before pontificating. It seem the people with the
strongest opinions have experience in primarily one language. We are
hearing the breast beatings similar to those about the best hockey or
basketball team, rather than a dispassionate comparison of features.

It further seems these fights could be turned into contests where
teams use their favoured language. The idea is to do the work in the
fewest man hours and have the fastest least resource hungry result.
You would also have a maintainability challenge, X hours to change the
program to do something different. You could get some hard data to
compare.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 27 '06 #91
On 27 Apr 2006 15:16:11 -0700, "peter koch"
<pe************ ***@gmail.com> wrote, quoted or indirectly quoted
someone who said :
I agree here. Readability matters a lot. And here C++ is a clear
winner, due to its more advanced features such as templates, operator
overloading and RAII,


Seems to me so much low level stuff in C++ (e.g. addressing trivia)
clutters readability. Operator overloading can make code more
readable, but if misused is one of the most powerful obfuscators ever
devised. I have not used the latest IDE's but I find it so much
harder in C++ to find the definition of somthing, especially when
smothered in macros.

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 27 '06 #92
On 27 Apr 2006 10:54:17 -0700, "Noah Roberts" <ro**********@g mail.com>
wrote, quoted or indirectly quoted someone who said :
Yes, but all the benefits you are listing are things you *can't* do and
the things forced upon you. Where are the list of things you *can* do?
You make Java sound like a jail sentance.


Team coding and coding on your own are quite different experiences. I
presume you work mostly on your own. The conventions are very useful
to prevent bloodshed between team members. They are just accepted and
you get on with something more important to fight about.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 27 '06 #93

Roedy Green skrev:
On Fri, 28 Apr 2006 00:01:48 +0200, "Alf P. Steinbach"
<al***@start.no > wrote, quoted or indirectly quoted someone who said :
I think perhaps the easiest for you to see the incorrectness of, is (2),
the belief that no memory leaks occur. A simple way to create a memory
leak in Java is to install an object in some global list of objects to
be called back on (event handling), then forget to remove it.
see http://mindprod.com/jgloss/packratting.html

I think you are quibbling over terminology. A leak would be an object
nothing pointed to continuing to tie up ram. Packratting is holding
on to objects you will never need again. Unless you ran a program
twice and studied the history, there is no way you could have the ESP
to determine that even in theory.


This is playing wordgames. I don't care if it is what is in Java-speak
called a memory leak or pack-ratting. The fact is that you have to do
some "resource management" stuff to avoid memory usage increasing ad
infinitum. And this is not theoretical. If I remember correctly this
behaviour was found in a released official Java-library. So Java is not
just "allocate and forget" even when it comes down to "pure" memory.
Again the advantage is with C++.

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


Apr 27 '06 #94
Bent C Dalager wrote:
Yes, but, I used to think that this was a self-solving problem.
Newbies don't write programming languages, after all, and by the time
they have the skill required to do so, one would have thought they
were long past the "let the language just guess what I mean" stage
. . .

Obviously not though :-)


Language design is complicated, with lots of tradeoffs. I don't know any
language that doesn't contain at least one stupid feature its designer
should have known better about.
Apr 27 '06 #95

Roedy Green skrev:
On 27 Apr 2006 15:16:11 -0700, "peter koch"
<pe************ ***@gmail.com> wrote, quoted or indirectly quoted
someone who said :
I agree here. Readability matters a lot. And here C++ is a clear
winner, due to its more advanced features such as templates, operator
overloading and RAII,
Seems to me so much low level stuff in C++ (e.g. addressing trivia)
clutters readability.


I can't follow you here. If you have to do low-level stuff in C++ this
gives you low-level code, of course. What is it in Java that makes it
less low-level in a similar problem than Java? Do you adress stuff such
as using operator-> instead of operator.(dot)? If you refer to raw
pointer manipulations, their usage normally indicates an incompetent
programmer (or that you look at the implementation of std::vector ;-)

/Peter

Operator overloading can make code more
readable, but if misused is one of the most powerful obfuscators ever
devised. I have not used the latest IDE's but I find it so much
harder in C++ to find the definition of somthing, especially when
smothered in macros.

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


Apr 27 '06 #96
On 27 Apr 2006 10:59:36 -0700, "Noah Roberts" <ro**********@g mail.com>
wrote, quoted or indirectly quoted someone who said :
Well, that is one area where Java *can't* be used then isn't it.

Another can't. Where is the can?


You CAN write platform independent Java code "in your sleep". You
can't do that in C++. At best you need to resort to the macro
preprocessor, and even then your code works on just the handful of
platforms you explicitly code and test for. In Java, it just comes
out in the wash as a side effect of writing code for one platform.

The big advantage of the Java approach is it FORCES you to write
cleaner code. There simply is no unconscious reliance on platform
quirkiness the way you have with C/C++ code. You use JNI for platform
specific code (Using C/C++) just for what you need, no more. This
makes the code base much more maintainable and generic.

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.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 27 '06 #97

Bent C Dalager skrev:
In article <11************ **********@j33g 2000cwa.googleg roups.com>,
peter koch <pe************ ***@gmail.com> wrote:

Oliver Wong skrev:

If you goal is to intentionally write platform dependent code, maybe
Java isn't for you.
Which ironically precludes writing the Java library in Java.


Not any more so than for any other non-assembly language.


Large parts of the C++ libraries are implemented in C++. All exceptions
I know of (Microsofts C++ compiler) are low-level functions such as
strcpy and memcpy where it was a question of efficiency rather than
possibility.
At some point, C++ also needs to fall back to assembly code to
implement its basic functions - even if that means bootstrapping a
compiler chain up from a simple assembly-based C compiler.
Of course - but this has no relation to my statement.
Interestingly, of course, while there are no CPUs that support C++
instructions natively (that I know of anyway), there are those that
support Java bytecode natively. The conclusion being that while it is
possible to have a pure Java system, it is not possible to have a pure
C++ system :-) I do not understand that one - are you trying to put a joke on me - or
do you propose that Java should run only on processors supporting
byte-code? ;-)

/Peter

(No, it's not an important point.)

Cheers
Bent D
--
Bent Dalager - bc*@pvv.org - http://www.pvv.org/~bcd
powered by emacs


Apr 27 '06 #98

Roedy Green wrote:
On 27 Apr 2006 10:54:17 -0700, "Noah Roberts" <ro**********@g mail.com>
wrote, quoted or indirectly quoted someone who said :
Yes, but all the benefits you are listing are things you *can't* do and
the things forced upon you. Where are the list of things you *can* do?
You make Java sound like a jail sentance.


Team coding and coding on your own are quite different experiences. I
presume you work mostly on your own. The conventions are very useful
to prevent bloodshed between team members. They are just accepted and
you get on with something more important to fight about.


I don't see how your assertion applies to my quoted statement above.
If you want to be understood I suggest you make your point more
clearly.

I also don't see how my quoted statement above would lead one to
believe I have never worked in a team...but whatever. It is clear you
don't have any good, and valid, arguments for you assertion that Java
is better than C++. This is frankly not surprising to me as such
assertions are always riddled with illogic and falacy.

Apr 27 '06 #99
* Roedy Green:
On Fri, 28 Apr 2006 00:01:48 +0200, "Alf P. Steinbach"
<al***@start.no > wrote, quoted or indirectly quoted someone who said :
I think perhaps the easiest for you to see the incorrectness of, is (2),
the belief that no memory leaks occur. A simple way to create a memory
leak in Java is to install an object in some global list of objects to
be called back on (event handling), then forget to remove it.


see http://mindprod.com/jgloss/packratting.html

I think you are quibbling over terminology. A leak would be an object
nothing pointed to continuing to tie up ram. Packratting is holding
on to objects you will never need again.


When a program uintentionally gobbles up memory, never releasing it, and
never using it again, there is a memory leak. So, you're not quibbling
over terminology: you're using terminology to try to define that reality
away. Which would be utterly silly were it not that someone might
believe it, and that someone evidently has believed it.

Your reference states:

"In fact it is almost impossible to write a program that nullifies
references to every object the instant it will never be needed again.
So every program is guilty of minor packratting."

Apart from the lack of connection from premise to conclusion, that's not
a fact, it's an excuse for sloppiness. Trying to define the problem
away by inventing new terminology and redefining old is more of the
same, an extra, fallback excuse position for incompetence. "Hey, it's
not a memory leak, it's /packratting/ [or whatever], and besides
[fallback excuse position], it's impossible to avoid, so there!"

Let's not discuss at that level, trying to pull the wool over things
that are technically clear and trivial but perhaps not viewed as
compatible with one's position.

It is possible to avoid memory leaks, it is possible to have them with
or without automatic garbage collection, and it is possible to use
garbage collection in C++, so the assumptions are all incorrect.

--
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 27 '06 #100

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

Similar topics

0
6821
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
1
6923
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
11
9294
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();
0
5662
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)
1
9668
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?
12
5935
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).
0
3292
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 <...
1
4310
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...
0
3301
oll3i
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);
0
9870
marktang
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...
0
9715
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,...
0
10610
jinu1996
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...
0
9451
agi2029
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...
1
7854
isladogs
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...
0
7030
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();...
0
5695
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4087
muto222
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.