473,889 Members | 1,386 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

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

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 think Roedy is saying that when you work in a team, there are certain
things you can't do (e.g. ignore the conventions of the team). Java helps
you not do those things (by establishing a convention, as opposed to having
each team coming up with their own, so you have to relearn conventions when
switching teams). Or something along those lines.

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.


I don't think Roedy asserted that "Java is better than C++". See
http://en.wikipedia.org/wiki/Psychological_projection

- Oliver

Apr 28 '06 #151

"Noah Roberts" <ro**********@g mail.com> wrote in message
news:11******** *************@i 40g2000cwc.goog legroups.com...

I'm still looking for the can. You listed all the thing Java *can't*
do but haven't come with anything it can. I don't see much advantage
in *can't*.


That you can't shoot yourself in the foot (or at least not as easily as
in some other languages) seems like a big advantage to me.

- Oliver

Apr 28 '06 #152

Oliver Wong wrote:
See
http://en.wikipedia.org/wiki/Psychological_projection


Ahhh yes, the last ditch attack from the weak. I grant you that it
appears to be a big gun as there is no way to argue against it...any
such attempt is of course also projecting. But only the unintelligent
cannot see it for what it is; I'll count you among them.

Apr 28 '06 #153

Roedy Green wrote:
However, I know C++ is not the best choice for many others. I know
from first hand, rather than second hand experience. For a start,
there is not even such an animal as a C++ Applet.
Holy crap, you people actually comming up with a can??!! Almost
anyway...I'll count it.

Took you long enough...damn!! !
There is nothing
comparable to rich set of GUARANTEED PRESENT class libraries.
Of course there is something comparable. The whole second half of the
C++ standard specifies the GUARANTEED PRESENT class (and other object
type) libraries.
C++ is
hopeless at platform-independent code.


Not even remotely true.

Apr 28 '06 #154
In comp.lang.java. advocacy, peter koch
<pe************ ***@gmail.com>
wrote
on 27 Apr 2006 14:51:39 -0700
<11************ *********@u72g2 000cwu.googlegr oups.com>:

The Ghost In The Machine skrev:

[snip]
"finally" is to RAII as manual transmission is to
automatic, from the looks of things.


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.

[.sigsnip]

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

Roedy Green wrote:
On 27 Apr 2006 16:16:20 -0700, "Noah Roberts" <ro**********@g mail.com>
wrote, quoted or indirectly quoted someone who said :
I also don't see how my quoted statement above would lead one to
believe I have never worked in a team...


I would think anyone who had ever worked on a team was familiar with
the ego battles that go on especially over how code should be
formatted. You would have seen the necessity of deciding on project
coding conventions to keep people from each others' throats.

You made several comments of form "convention s are like a
straightjacket" , which indicated you had never experienced a situation
where you needed them or where pre-existing conventions eased the
tensions.

You appeared to believe they had no value at all.

You also sounded independent and argumentative, not the type of person
who can stand working in a corporate team environment for very long.
You have to bite your tongue till it bleeds.


This entire avenue of argument is not only riddled with ego and
argumentative remarks but it is also entirely beside the point even if
true.

Apr 28 '06 #156
Martin Vejnár <av****@volny.c z> wrote:
Could you please give me equivalent Java code for this...

// C++
func()
{
class_with_poss ible_ressource cwpr, cwpr2;
dosomethingwith (cwpr, cwpr2);
}

...and for this?

// C++
func()
{
class_with_poss ible_ressource cwprs[1000];
dosomethingwith (cwprs);
}


No. :) I think you already know the answer. The latter would generally
be done by modifying the structure a bit. If there's really a need to
hold all those resources open at the same time, then some kind of
aggregate class could be written whose close method attempts to close
all of the resources in a collection.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Apr 28 '06 #157
Mishagam wrote:

OK. True, the D language has cleaned up old C inheritances C++ suffers
from. However, I doubt anyone would switch to D unless you provide a
large class library for almost everything. That's the only true
benefit of Java, the large std library.

Yes, large standard library helps. However Perl, Python, C# have
something close.
I would give additional benefits (for me).
a) You don't have to think should you include fields of have variables
as objects or references or pointers. It is decided for you usually
close to optimal way (closest to references).
b) You don't have to bother to use auto_pointer (not working with
collections) or new delete or automatic destructor. It is decided for
you to use something like auto_ptr but much better.
c) You don't have to decide about programming style. Sun provided
standard Java style.
d) You don't have to decide about naming of files and classes - they are
the same.
e) Logical package directory structure is forced on you.
f) You don't have to choose between char *, string, CString ... - String
is better (or same) than either of them and it is only choice.
g) you don't have to choose between long int, unsigned int, WORD, DWORD,
size_t .... - close to optimal choice if forced on you.
h) You don't decide do you use internal or external functions
definitions, or do you use macro. - close to optimal choice if only one
possible.
i) You don't have to decide if you use methods or define new operators.
Java choice is sometimes more verbose, but usually more clear.
...
As you can guess, I can continue.
Dropping all these choices first - makes programming easier, you have
less things to bother about, second - makes language smaller and more
easy to understand. Of course such approach could lead to very bad
language - but Java luckily has good design. And I thing C++ standard
committee just made bad design - introducing complexities which doesn't
add enough benefits to justify them.

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 .
Apr 28 '06 #158
peter koch wrote:
Roedy Green wrote:
However, I know C++ is not the best choice for many others. I know
from first hand, rather than second hand experience. For a start,
there is not even such an animal as a C++ Applet. There is nothing
comparable to rich set of GUARANTEED PRESENT class libraries. C++ is
hopeless at platform-independent code.

I do agree that Java probably should be used for client side web-based
programming.
That said there is ATL which COM which is used extensively in those
area - resulting in platform dependent code, of course.

/Peter

If you are talking about IE ActiveX controls they were also responsible
for a lot of security breaches (I am not expert here), because C++ and
specifically ActiveX controls don't have Java Applets inherent security.
Apr 28 '06 #159
Noah Roberts schrieb:
Oliver Wong wrote:
See
http://en.wikipedia.org/wiki/Psychological_projection


Ahhh yes, the last ditch attack from the weak.


You are the only one who takes this discussion for a battle. Oliver
didn't attack you, he just tried to help you realizing what is going on.
Timo
Apr 28 '06 #160

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

Similar topics

0
6823
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
6927
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
9298
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
5664
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
9675
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
5939
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
3295
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
4314
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
3304
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
11188
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...
0
10789
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
10441
tracyyun
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...
0
9606
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
7993
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
7150
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
6028
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3255
bsmnconsultancy
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.