473,842 Members | 1,908 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 21563
On 28 Apr 2006 08:37:45 -0700, "Noah Roberts" <ro**********@g mail.com>
wrote, quoted or indirectly quoted someone who said :

That is really grasping at straws. Using set theory to weed out a
meaning you like from a the rewording of a statement. If we were in
the middle of an argument about abstract math then maybe it would have
its place...but we are not.


You are not a programmer at heart. You would make a better lawyer.
They get paid to deliberately misinterpret.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #171

Mishagam wrote:
And of course one of main items:
j: In Java you generally don't have to think how to report error - you
throw Exception. In C++ you have different conventions for different
systems changing over time. Some programs return NULL or 0 or -1 or
SIGNALS ..., Microsoft COM programs returned HRESULT, lately C++ started
using exceptions, but I am sure it is still only one of choices. I don't
know, but doubt that C++ exceptions are as convenient as in Java. Of
course this result of Java being designed later when exceptions already
were well known .


Where to start...

First, are you really making the statement that Java supports no other
error reporting facility? That is blatantly false but let's assume for
the moment that is true and ask ourselves if that is actually a good
thing...

Second...I'm not sure of you use of the term "program". Are you really
claiming that a Java *program* can somehow report exceptions to the OS
or object running it in a way other than what the OS supports - signals
being one common facility? If this is in fact true it would be an
interesting CAN I am not aware of. C++ programs never "return NULL"
but do most commonly return an integer...0 meaning all is ok. AFAIK
Java must do this too as many operating systems depend on the behavior.

Third...COM is not C++, it is a MS specific standard of coding a set of
functionality in ANY language that can be used from ANY language
capable of interacting with COM. I do believe Java can be counted
among them but of course any such program instantly looses any platform
independance.

Finally, if you don't know then your doubts are meaningless.

Apr 28 '06 #172
On Fri, 28 Apr 2006 14:37:29 GMT, "Oliver Wong" <ow***@castorte ch.com>
wrote, quoted or indirectly quoted someone who said :

I don't think Roedy asserted that "Java is better than C++"


That is a meaningless assertion. Better for WHAT?.

Arguing with Noah is as silly as arguing with a five year old about
the merits of sex vs ice cream. If you have not used both languages,
how can you possibly compare them, much less make dogmatic assertions?

This argument reminds me of "which team is better". Everything is
determined by team loyalty. The debate becomes just a primate
territory ritual.

So I end my participation in this thread by flinging some metaphoric
feces in Noah's face, and thumping my chest like a good primate.

Many years ago on BIX, I was bitching about some of the features of
C++ and one of the participants got extremely emotional and defensive,
as if he were responsible for the failings. I was greatly embarrassed
to find out handle bstroustrup was THE Bjarne Stroustrup, creator of
C++. He had reason to take the criticism of C++ personally. You, Noah,
do not. C++ is just a language you learned, not your life partner.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #173

"Noah Roberts" <ro**********@g mail.com> wrote in message
news:11******** *************@j 33g2000cwa.goog legroups.com...

Bent C Dalager wrote:
In article <11************ *********@e56g2 000cwe.googlegr oups.com>,
Noah Roberts <ro**********@g mail.com> wrote:
>
>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.


That is an assertion that may exist inside your head, but you will not
actually find it in this thread.


Really? I guess you never said the following then:

"Interestin gly, 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 :-) "


FWIW, on the very next line, Bent wrote "(No, it's not an important
point.)"

From the text you've quoted, even if you omit the parenthesis that
follows, I don't see where Bent implies "C++ is not as good as Java". This
is an example of what I was referring to when I mentioned psychological
projection. Bent simply stated the fact that chips exist which process Java
bytecode natively. From there, you inferred that Bent was making a statement
about the merits of Java versus C++. I don't think Bent intended for that
interpretation.

- Oliver

Apr 28 '06 #174

Roedy Green wrote:
On 28 Apr 2006 08:37:45 -0700, "Noah Roberts" <ro**********@g mail.com>
wrote, quoted or indirectly quoted someone who said :

That is really grasping at straws. Using set theory to weed out a
meaning you like from a the rewording of a statement. If we were in
the middle of an argument about abstract math then maybe it would have
its place...but we are not.
You are not a programmer at heart. You would make a better lawyer.
They get paid to deliberately misinterpret.


Won't respond to your personal attack but I will respond to your claim
I am purposfully misinterpreting your statements.

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

Both your original statement and your reply indicate that the non set
theory interpretation of your words are in fact what you originally
meant. Are you claiming otherwise? If so then perhaps you wish to
reword YOURSELF instead of letting other attempt weed nuggets of
insight on their own? There is at least one other person who
interpreted what you said as I have so your meaning is obviously not as
clear as you indicate. If I misinterpret your words it is because they
are ambiguous at best...not because I do so on purpose.

Apr 28 '06 #175
Noah Roberts <ro**********@g mail.com> wrote:
Really? I guess you never said the following then:

"Interestin gly, 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 don't see any "C++ is not as good as Java because" in that paragraph.
I took it as an indictment of the silliness of bringing up this hardware
CPU/bytecode stuff in this conversation in the first place. Maybe I
misinterpreted something, but I really don't think so.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Apr 28 '06 #176

"Noah Roberts" <ro**********@g mail.com> wrote in message
news:11******** **************@ j73g2000cwa.goo glegroups.com.. .

Where to start...

First, are you really making the statement that Java supports no other
error reporting facility? That is blatantly false but let's assume for
the moment that is true and ask ourselves if that is actually a good
thing...
Of course, it's possible in Java to declare a method as returning an
int, and then using various codes for reporting status (e.g. 0 means
everything is OK, -1 means something bad happened, etc.), however if you
actually write Java code like this, you will probably be ridiculed. It's
like those conventions people brought up earlier and were complained as
being "can'ts" or "straightjacket s" of Java. You *CAN* return error codes.
It's just that most Java programmers don't. It's considered bad form.

Second...I'm not sure of you use of the term "program". Are you really
claiming that a Java *program* can somehow report exceptions to the OS
or object running it in a way other than what the OS supports - signals
being one common facility? If this is in fact true it would be an
interesting CAN I am not aware of. C++ programs never "return NULL"
but do most commonly return an integer...0 meaning all is ok. AFAIK
Java must do this too as many operating systems depend on the behavior.


If the OS expects specific return values as the primary mechanism for
exception reporting, I fail to see how Java, C++, or any other language and
their conventions are relevant. If you had a Java-centric OS, the OS might
simply expect "nothing" (in the same way that you expect nothing from a void
method) when everything is working normally, and expect exceptions when
something bad happens. I believe BlueJ does something like this:
http://www.bluej.org/

And for what it's worth, the main method of a Java program is declared
to return void. I.e.:

public static void main(String args[])

If you wish to signal an error to the OS, you would usually use the
"Runtime.exit(i nt status)" method. See
http://java.sun.com/j2se/1.5.0/docs/....html#exit(int)

- Oliver

Apr 28 '06 #177

Oliver Wong wrote:
"Noah Roberts" <ro**********@g mail.com> wrote in message
news:11******** *************@j 33g2000cwa.goog legroups.com...

Bent C Dalager wrote:
In article <11************ *********@e56g2 000cwe.googlegr oups.com>,
Noah Roberts <ro**********@g mail.com> wrote:
>
>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.

That is an assertion that may exist inside your head, but you will not
actually find it in this thread.
Really? I guess you never said the following then:

"Interestin gly, 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 :-) "


FWIW, on the very next line, Bent wrote "(No, it's not an important
point.)"


If you are correct in what you point out below then it is not only not
important it is completely meaningless.

From the text you've quoted, even if you omit the parenthesis that
follows, I don't see where Bent implies "C++ is not as good as Java". This
is an example of what I was referring to when I mentioned psychological
projection. Bent simply stated the fact that chips exist which process Java
bytecode natively.
And that none exist to process C++ "instructio ns".

From there, you inferred that Bent was making a statement about the merits of Java versus C++. I don't think Bent intended for that
interpretation.


Well perhaps he wasn't infering Java was thus better than C++ but he
was certainly stating that this was something Java does that C++
doesn't. Either way it is a meaningless comparison between compiled
Java vs. an apparently less than compiled form of C++.

Apr 28 '06 #178
Noah Roberts schrieb:
Yes, Applets have to be given to Java as something it can do that
current incarnations of C++ cannot. I do not know that this is
inherent to the language or more because of the way Java is normally
processed.
It is mostly independent of the language. Java is usually compiled to
byte code, and it is much easier to safely run byte code in a sandbox
than machine code.

Also it must be mentioned that flash is also used quite a bit in this
area and in fact, in my opinion at least, results in better output.
Flash "applets" seem to work better on more platforms than Java. Hell,
at home where I use Linux I will use Flash but won't even bother with
installing the Java plugins because much of the time the applets just
don't function well.
I think applets are much worse than Flash. They take a long time to
load, their abilities to communicate with the browser (Javascript) is
even worse than Flashs.

It simply doesn't work well to have parts of the interface in
Java/Flash, the other parts in HTML. In my experience, you are better
off sticking either to plain HTML/CSS/JS or a Java Web Start application.

However, flash is much more expensive for the devolper, who doesn't
even have to pay for the JDK but has to pay a fortune for flash.
Actually, the current version of the Eclipse based Flash IDE is
available for free. There is also an ActionScript2 open source compiler,
and an alternative to the upcoming ActionScript3 - HaXe - that will
target current and future Flash Players.

I write applets it is with Java, not Flash and certainly not C++. But
when I write cross-platform code that won't be running in a browser
most of the time I use C++, not Flash, and not Java (though sometimes I
think about that as an alternative).


I must admit that I don't like most Java desktop apps. Swing just
doesn't feel like a native GUI. SWT is much better than Swing, but it
has disadvantages too.
Timo
Apr 28 '06 #179
In comp.lang.java. advocacy, Mishagam
<no*****@provid er.com>
wrote
on Fri, 28 Apr 2006 15:57:11 GMT
<rX************ ******@tornado. southeast.rr.co m>:
The Ghost In The Machine wrote:
In comp.lang.java. advocacy, peter koch
Not at all. RAII is to finally what a printing machine is to a pen.
RAII simplifies a nontrivial and tedious task. Or do you always check
for your objects being of the IDisposable type before deciding if you
can leave their destruction to the garbage collector or if you will
have to destroy them manually?
If not - how will your program cope with classes that change?
Also - how do you write generic code if you do not know if you will
have to destroy your objects - except than by using run-time
information?


How indeed? The best Java can do in that department is
a dispose() method (Swing) -- and that's not supported
in the language, unlike C++'s virtual destructor. finalize()
is overridable but it's never clear exactly when that will
be called.

I understand that RAII is basically use automatically called
destructor's to dispose resources? I agree it is useful where it can be
used.


The little I've studied the issue indicates it's more
than that. Apparently, the general idea is that a resource
can be destructed at any time, and in a human-predictable
fashion. (This includes during exceptions.)

C++ destructors here are merely a means to an end.
It works if you work with objects as values, it doesn't work if you work
with pointers or references.
Java has neither pointers nor references (although one could consider
any Object a pointer to some sort of data structure, really, and
any Object function parameter is passed by reference, allowing
modification methods and/or field assignments to that parameter).

Personally, I prefer smart pointers in C++, when I
use pointers at all, and tend to use reference counts.
(std::auto_ptr< > is IMO a horrid hack.) There are a number of
problems with reference counts, though; the main one is the
"floating loop" problem.
In such cases destructor can easily leave
dangling pointer. If you work with references you are on your own, or
have to duplicate something like reference counting or Java GC. I don't
think you can work without using references in big program.
I think because of this STL mostly works (in examples) with value
elements, and this creates a lot of problems - you cannot place
descended class objects were you can place base objects, you have to
deal with constructors, destructor's, copy constructors called in
strange places, you waste memory and so on. Also, you have to have
different generated code for different objects and use templates. And in
Java one Collections library works OK with any object.


Depends on the Object and the Collection. TreeMap, for instance,
cannot work with Objects that aren't Comparables without a
Comparator.

I don't see major problems in this area, though, except that
the List interface requiring implementation of a get by index
is a little weird.

--
#191, ew****@earthlin k.net
Windows Vista. Because it's time to refresh your hardware. Trust us.
Apr 28 '06 #180

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
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
10942
Oralloy
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...
1
10671
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,...
0
9452
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
7855
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
5696
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
5884
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4499
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
2
4088
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.