By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,561 Members | 3,083 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,561 IT Pros & Developers. It's quick & easy.

On Java and C++

P: n/a
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 #1
Share this Question
Share on Google+
458 Replies


P: n/a
we***********@yahoo.com wrote:
Again, Occam's Razor is a valuable tool here. In deciding among
competing hypotheses, choose the simplest one.


The simplest is: you are a troll.

--
Salu2

Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
Apr 26 '06 #2

P: n/a
we***********@yahoo.com wrote:

snipped dribble....

oh good a pissing competition!

My Ruby is better than your (Insert your fave, all time language here).

Apr 26 '06 #3

P: n/a
we***********@yahoo.com wrote:

drivel

+-------------------+ .:\:\:/:/:.
| PLEASE DO NOT F :.:\:\:/:/:.:
| FEED THE TROLLS | :=.' - - '.=:
| | '=(\ 9 9 /)='
| Thank you, | ( (_) )
| Management | /`-vvv-'\
+-------------------+ / \
| | @@@ / /|,,,,,|\ \
| | @@@ /_// /^\ \\_\
@x@@x@ | | |/ WW( ( ) )WW
\||||/ | | \| __\,,\ /,,/__
\||/ | | | jgs (______Y______)
/\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
================================================== ============
--
Ian Collins.
Apr 26 '06 #4

P: n/a

Ian Collins wrote:
we***********@yahoo.com wrote:

drivel

+-------------------+ .:\:\:/:/:.
| PLEASE DO NOT F :.:\:\:/:/:.:
| FEED THE TROLLS | :=.' - - '.=:
| | '=(\ 9 9 /)='
| Thank you, | ( (_) )
| Management | /`-vvv-'\
+-------------------+ / \
| | @@@ / /|,,,,,|\ \
| | @@@ /_// /^\ \\_\
@x@@x@ | | |/ WW( ( ) )WW
\||||/ | | \| __\,,\ /,,/__
\||/ | | | jgs (______Y______)
/\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
================================================== ============
--
Ian Collins.


Wow, posted for only 15 minutes and already 3 replies including a
"don't reply to the trolls" reply.

Nice one ;)

Apr 26 '06 #5

P: n/a
["Followup-To:" header set to comp.lang.java.programmer.] On
2006-04-26, we***********@yahoo.com penned:
Java programmers seem to always be whining about how confusing and
overly complex C++ appears to them.


No, they aren't.

Therefore the rest of your troll is moot.

--
monique

Help us help you:
http://www.catb.org/~esr/faqs/smart-questions.html
Apr 26 '06 #6

P: n/a

from
how to start a flame..
chapter 1

Apr 26 '06 #7

P: n/a
I agree that may be C++ programmers are smarter. Even more, I agree that
person that fully understands C++ (or Common Lisp, or PL/I) should be
very clever and more clever than average (not neccessary Java) programmer.
But this doesn't help C++ to be very bad and getting steadily worse
language.
Because computer language is tool. Because people don't study language
for the sake of it, they study them to write programs. More difficult
and complex language is, more time is wasted studying it, and less
people will understand what they are actually writing when they use this
language. I bet <1% of C++ programmers fully understand C++ language. I
am sure statistics is radically different for Java - which is MUCH
simpler and more easy to understand. I myself programmed about 10 years
on C++ and 5 years on Java, so I was able to compare them.
And I am sorry for people who achieved full understanding of C++ virtual
inheritance, STL, Templates, Functors, and so on. They uselessly wasted
huge efforts.
And writing programs on complex, poorly understood language doesn't help
to write reliable and efficient programs.
In this sense C was much better language (through clever use of
preprocessor could provide ugly programs). And I understand why C is
still so popular in Linux.

we***********@yahoo.com wrote:
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 #8

P: n/a
<we***********@yahoo.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
Java programmers seem to always be whining about how confusing and
overly complex C++ appears to them. I would like to introduce an

*snip*

LOL - welcome troll!

--
LTP

:)
Apr 26 '06 #9

P: n/a
....
In this sense C was much better language (through clever use of
preprocessor could provide ugly programs). And I understand why C is
still so popular in Linux.

....

Now, you are begging for a fight?
Apr 27 '06 #10

P: n/a
i am a student,
and i have seen many of my friends 'switch' over to java cos they shy
away from learning much involved language c++
and also they seem to like things like easy GUI interfacing than actual
programming (like practising data structures ..b trees et al.)

Apr 27 '06 #11

P: n/a
"al pacino" <si*************@gmail.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
i am a student,
and i have seen many of my friends 'switch' over to java cos they shy
away from learning much involved language c++
and also they seem to like things like easy GUI interfacing than actual
programming (like practising data structures ..b trees et al.)


Learning C++ is marginally more difficult than learning Java.

I used to be a die hard C++ advocate - but the added complexity doesn't
really add a great deal of usability; but it is great for obscuring the
meaning of the code.

Java is simpler, cleaner - but programming is programming. Java is
designed to be able to more easily make integrated GUI apps. This might,
in turn, make the code of two programmers with otherwise equal talent, one
in C++ and one in Java, differ and their end results differ. In C++ you
have to reinvent the wheel all the time. Except, it's not like you're
rediscovering, just annoyingly doing the same thing repetitively to take up
more time. In Java you implement one of the provided algorithms, and you
are good to go, with an exponentially smaller possibility that the
underlying algorithm code is in some way flawed. (With as many Java users
as are out there, a bug should pop up pretty quick.) GUIs are easier, in
general, so the java programmer can use that time to make their GUI better.
Web examples (sample code) tend to work, unlike C++ where if you download
something, there is only a miniscule chance that it will compile after 20-30
minutes of fiddling.

Blah - I'm just blabbering. My point is that coding in Java saves times,
and lessens bugs. It will make the end result better. All the bad things
I thought of Java are pretty much gone.

The reason I am replying is you just seem to have contempt. "Actual
Programming" problems will arise, they will just be less mundane.

I think you might be confusing Java with VB.

Trust me though - you can practice algorithms and data structures in Java -
I do so at least 3 times a week on topcoder.

--
LTP

:)

Apr 27 '06 #12

P: n/a
Gernot Frisch wrote:
...
In this sense C was much better language (through clever use of
preprocessor could provide ugly programs). And I understand why C is
still so popular in Linux.

...

Now, you are begging for a fight?

How should I respond to this? May be I am new to this newsgroup.
I (esthetically) liked C very much when I have first seen it, and still
think it is (and especially was (I mean in context of 70-80s when it was
created)) very good language.
However I now prefer to program on Java. I think best quality of Java is
how beautifully it removes most unnecessary choices, leaving one very
decent way to do things.
I now (esthetically) hate C++, however still program on it (using very
few 'modern' features, but using classes) sometimes.
So I stay by my opinion that C is (was) good language, and C++ is bad
language.
Apr 27 '06 #13

P: n/a
How should I respond to this? May be I am new to this newsgroup.
I (esthetically) liked C very much when I have first seen it, and
still think it is (and especially was (I mean in context of 70-80s
when it was created)) very good language.
However I now prefer to program on Java. I think best quality of
Java is how beautifully it removes most unnecessary choices, leaving
one very decent way to do things.
I now (esthetically) hate C++, however still program on it (using
very few 'modern' features, but using classes) sometimes.
So I stay by my opinion that C is (was) good language, and C++ is
bad language.


The so called "ugly" features is what makes C++ so powerfull. Operator
overloading is essentiall for RAD-classes. Aynway...
Apr 27 '06 #14

P: n/a
> Learning C++ is marginally more difficult than learning Java.

I hate feeding trolls but it is just unfair for C++...

I learned Javascript before C++. My impression is even though C++ is
noticeably more complex, it is not more difficult to learn than Javascript.

I used to be a die hard C++ advocate - but the added complexity doesn't
really add a great deal of usability; but it is great for obscuring the
meaning of the code.
A screw driver can help you fix your car; yet it can also do damage to
your car depending on how you use it. C++ is no different. It is just a
tool after all, and you CAN definitely obscure the code with C++. It
takes experience and skill to write good quality code in just about any
language.

The added complexity to C++ is a result of meeting the need of a wide
range of audiences. The language is like a big toolbox, and it is just
unfair to blame the toolbox for offering much more than what you need
for your task.

Java is simpler, cleaner - but programming is programming. Java is
designed to be able to more easily make integrated GUI apps. This might,
in turn, make the code of two programmers with otherwise equal talent, one
in C++ and one in Java, differ and their end results differ. In C++ you
have to reinvent the wheel all the time. Except, it's not like you're
rediscovering, just annoyingly doing the same thing repetitively to take up
more time. In Java you implement one of the provided algorithms, and you
are good to go, with an exponentially smaller possibility that the
underlying algorithm code is in some way flawed. (With as many Java users
as are out there, a bug should pop up pretty quick.) GUIs are easier, in
general, so the java programmer can use that time to make their GUI better.
Web examples (sample code) tend to work, unlike C++ where if you download
something, there is only a miniscule chance that it will compile after 20-30
minutes of fiddling.
It is again an unfair comparison. The ease building GUI apps with Java
has nothing much to do with the simplistic design of the Java language.
It is Java's "standard" class libraries that allows you to program Java
from a higher level than system calls.

You can program C++ GUI at the same level. First thing to do is to find
a library that supports you. These good libraries are unfortunately not
part of the C++ standard and it is a shame that a lot of people are
under the impression that C++ is incapable of, or poorly supports, tasks
that requires non-standard C++ libraries.

Part of Java's popularity comes from politics rather than technicality.
But I am not in the mood of discussing politics.

Blah - I'm just blabbering. My point is that coding in Java saves times,
and lessens bugs. It will make the end result better. All the bad things
I thought of Java are pretty much gone.


Meanwhile Java is getting larger and larger.

Regards,
Ben
Apr 27 '06 #15

P: n/a
Gernot Frisch wrote:

I think best quality of
Java is how beautifully it removes most unnecessary choices, leaving
one very decent way to do things.
I now (esthetically) hate C++, however still program on it (using
very few 'modern' features, but using classes) sometimes.
So I stay by my opinion that C is (was) good language, and C++ is
bad language.


The so called "ugly" features is what makes C++ so powerfull. Operator
overloading is essentiall for RAD-classes. Aynway...

I always wondered in such context what word 'powerfull' means?
Does it mean that you can write program that cannot be written on Java?
or Does it mean that you can write shorter C++ program doing the same as
equivalent Java program? Then may be you should like Perl even more?
Or does it man that you can write library, such that equivalent C++
program will LOOK simpler than Java program?
Apr 27 '06 #16

P: n/a
Mishagam wrote:
Gernot Frisch wrote:

I think best quality of Java is how beautifully it removes most
unnecessary choices, leaving one very decent way to do things.
I now (esthetically) hate C++, however still program on it (using
very few 'modern' features, but using classes) sometimes.
So I stay by my opinion that C is (was) good language, and C++ is bad
language.


The so called "ugly" features is what makes C++ so powerfull. Operator
overloading is essentiall for RAD-classes. Aynway...

I always wondered in such context what word 'powerfull' means?
Does it mean that you can write program that cannot be written on Java?
or Does it mean that you can write shorter C++ program doing the same as
equivalent Java program? Then may be you should like Perl even more?
Or does it man that you can write library, such that equivalent C++
program will LOOK simpler than Java program?

I meant in last case C++ program using C++ library looks simpler than
Java program using Java library.
Apr 27 '06 #17

P: n/a
I think that some people may be missing the point in having multiple
programming languages.

Why do you think that the world has more than one language? Why don't
we all use English instead of all having different languages, it would
make life so much easier. Well, in fact, it wouldn't.

In my honest opinion, once you know how to program at a decent level,
you should be able to use any language with just a small amount of
effort, if you want to master that language then fine, but be prepared
to put the work in. At the same time, the amount of programs or
applications that require a team of programmers to know every in-depth
detail of their language is slim.

C++ has advantages over Java, it also has its fair share of
disadvantages. I don't buy into the fact that Java is easier to learn.
I have been a learning C++ for about 3 years and as part of my uni
course, have now been asked to program some Java. I find Java as a
language nice to work with but have the same number of problems I would
have expected from learning a new language. Yes, its a slimmed down
version, yes it may be easier to do certain things but if we made all
programming languages insanely difficult only a small number of people
would ever get the joy the rest of us get from programming.

Just my thoughts.....

Apr 27 '06 #18

P: n/a
Gernot Frisch wrote:
The so called "ugly" features is what makes C++ so powerfull.


I don't agree with the fatalistic idea that a feature must be ugly in
order to be powerful. The warts in C++ are not due to its power, but to
its desire to integrate new features in while retaining source
compatibility with 30 years of past decisions, good and bad.

If you're willing to give up legacy compatibility, it's possible to
design a language with similar and even greater power, but in a much
simpler and straightforward package. Such is the D programming language,
www.digitalmars.com/d/

For an example of how an "ugly" power feature like templates can be made
easier (and even more powerful), see
www.digitalmars.com/d/templates-revisited.html .
-Walter Bright
Digital Mars
Apr 27 '06 #19

P: n/a
In article <44***********************@news.optusnet.com.au> ,
benben <be******@yahoo.com.au> wrote:
Learning C++ is marginally more difficult than learning Java.


I hate feeding trolls but it is just unfair for C++...

I learned Javascript before C++. My impression is even though C++ is
noticeably more complex, it is not more difficult to learn than Javascript.


That may say more about Javascript than it does about C++ though :-)

(Personally, I found ECMAScript pretty straight forward up until I
reached the chapter of the spec titled "automatic semicolon
insertion". It went downhill from there <g>)

Cheers
Bent D
--
Bent Dalager - bc*@pvv.org - http://www.pvv.org/~bcd
powered by emacs
Apr 27 '06 #20

P: n/a

"Walter Bright" <wa****@digitalmars-nospamm.com> schrieb im
Newsbeitrag news:Xt******************************@comcast.com. ..
Gernot Frisch wrote:
The so called "ugly" features is what makes C++ so powerfull.


I don't agree with the fatalistic idea that a feature must be ugly
in order to be powerful. The warts in C++ are not due to its power,
but to its desire to integrate new features in while retaining
source compatibility with 30 years of past decisions, good and bad.

If you're willing to give up legacy compatibility, it's possible to
design a language with similar and even greater power, but in a much
simpler and straightforward package. Such is the D programming
language, www.digitalmars.com/d/

For an example of how an "ugly" power feature like templates can be
made easier (and even more powerful), see
www.digitalmars.com/d/templates-revisited.html .


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.

I hope to see D grow and be _the_ (C++)++ one day, though.
Apr 27 '06 #21

P: n/a
>
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.
Apr 27 '06 #22

P: n/a
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).
What about pointer to a pointer? A pointer is a pointer, a reference
is a reference, a variable is a variable. Period.
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.
I like new/delete. Makes me feel I'm in charge. Just my .02$

c) You don't have to decide about programming style. Sun provided
standard Java style.
Juck!
d) You don't have to decide about naming of files and classes - they
are the same.
no, they _have to be_ the same. Otherwise the compiler pukes.
e) Logical package directory structure is forced on you.
What about freedom of choice?
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.
Yeah, and a lot slower in some cases. User std::string where you need
dynamic strings, use char[] where you need static strings. You don't
have to - but you _can_!
g) you don't have to choose between long int, unsigned int, WORD,
DWORD, size_t .... - close to optimal choice if forced on you.
Just a question of style. I use the built-in tpyes for everything.
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.
That's a real feature of java and D! Include files totally suck!
Internal functions are a great benefit as well. Though I'd not want to
loose the preprocessor.
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.
?? I don't understand that. You can't define operators in Java, can
you? Defining operators is one of the most important things for OOP
IMHO.
And I thing C++ standard committee just made bad design -
introducing complexities which doesn't add enough benefits to
justify them.


Well, if you knew C++ as good as Java, you wouldn't say so I guess.
Anyway - I don't give a **** about what others use to write stuff, so
this is all just blahblah about nothing. There's no point making one
language better than the other. You will pick what suits you best or
what your boss indoctrinates on you.




Apr 27 '06 #23

P: n/a
REH

Luc The Perverse wrote:
Java is simpler, cleaner - but programming is programming.


Yeah, and that's why I write real-time systems in Perl. Languages are
tools. Use the right one for the right job. No language has yet
filled the "one-size-fits-all" catagory.

REH

Apr 27 '06 #24

P: n/a
I normally dont get involved with pissing contests, but there's only so much
bs in a single post i can take without replying...

<snip>
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.
I like new/delete. Makes me feel I'm in charge. Just my .02$


So, your entire reasoning behind preferring manual memory managment over
garbage collection is that "you feel in charge"? You should give assembly
language a go. Meanwhile, in the real world most recent garbage collectors
outperform manual memory managment in the vast majority of applications, and
as a bonus you get the complete lack of memory leaks and such.
c) You don't have to decide about programming style. Sun provided
standard Java style.
Juck!


I'll grant you that it's a matter of taste, but no self respecting developer
will consider standards a bad thing. If you do, draw your conclusions.
d) You don't have to decide about naming of files and classes - they are
the same.
no, they _have to be_ the same. Otherwise the compiler pukes.


And the ability to stick tons of classes in a single file with a non-related
name would be a good thing because....? Again, standards -> good
e) Logical package directory structure is forced on you.
What about freedom of choice?


Can you think of a single instance where having an illogical directory
structure is preferred over a logical one?
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.


Yeah, and a lot slower in some cases. User std::string where you need
dynamic strings, use char[] where you need static strings. You don't have
to - but you _can_!


When was the last time you benchmarked Java strings vs. C++?
g) you don't have to choose between long int, unsigned int, WORD, DWORD,
size_t .... - close to optimal choice if forced on you.
Just a question of style. I use the built-in tpyes for everything.


It's freedom that doesnt add anything but confusion and hurts readability.
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.


?? I don't understand that. You can't define operators in Java, can you?
Defining operators is one of the most important things for OOP IMHO.

He's not claiming you can, he simply says the exact same functionality can
be achieved albeit more verbose (i.e. .add rather than +). There are
certainly instances where operator overloading provides more readable code,
but at the same time it can also be the cause of rather unpredictable code.
On this point my stance is that if used with care operator overloading is a
pretty neat thing.
And I thing C++ standard committee just made bad design - introducing
complexities which doesn't add enough benefits to justify them.


Well, if you knew C++ as good as Java, you wouldn't say so I guess.
Anyway - I don't give a **** about what others use to write stuff, so this
is all just blahblah about nothing. There's no point making one language
better than the other. You will pick what suits you best or what your boss
indoctrinates on you.


Ofcourse there's a point in making languages "better" or at least different
than others. Sometimes a language is simply outdated, sometimes it's just
not a viable option for certain applications (people generally dont write
web-based application in C++ for example, just as you wont find many
commercial games or OSs written in Java). As for bosses, people usually get
a job based on their language skills and preferences, not the other way
around.

Anyway. there's room for both, but most of your arguments in the post above
are flawed or outdated in my opinion, as i feel you're considering rather
obvious weaknesses of C++ to be benefits. And to the OP, anyone claiming C++
programmers are somehow better than Java programmers is a tool. 90% of
skills related to being a "good developer" is completely unrelated to the
language you're using.
Apr 27 '06 #25

P: n/a

"Bent C Dalager" <bc*@pvv.ntnu.no> wrote in message
news:e2**********@orkan.itea.ntnu.no...
In article <44***********************@news.optusnet.com.au> ,
benben <be******@yahoo.com.au> wrote:
Learning C++ is marginally more difficult than learning Java.


I hate feeding trolls but it is just unfair for C++...

I learned Javascript before C++. My impression is even though C++ is
noticeably more complex, it is not more difficult to learn than
Javascript.


That may say more about Javascript than it does about C++ though :-)


We're all aware Javascript is completely unrelated to Java right?
Apr 27 '06 #26

P: n/a

"Luc The Perverse" <sl***********************@cc.usu.edu> wrote in message
news:92************@loki.cmears.id.au...
"al pacino" <si*************@gmail.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
i am a student,
and i have seen many of my friends 'switch' over to java cos they shy
away from learning much involved language c++
and also they seem to like things like easy GUI interfacing than actual
programming (like practising data structures ..b trees et al.)


Learning C++ is marginally more difficult than learning Java.

I used to be a die hard C++ advocate - but the added complexity doesn't
really add a great deal of usability; but it is great for obscuring the
meaning of the code.

Java is simpler, cleaner - but programming is programming. Java is
designed to be able to more easily make integrated GUI apps. This might,
in turn, make the code of two programmers with otherwise equal talent, one
in C++ and one in Java, differ and their end results differ. In C++ you
have to reinvent the wheel all the time. Except, it's not like you're
rediscovering, just annoyingly doing the same thing repetitively to take
up more time. In Java you implement one of the provided algorithms, and
you are good to go, with an exponentially smaller possibility that the
underlying algorithm code is in some way flawed. (With as many Java users
as are out there, a bug should pop up pretty quick.) GUIs are easier, in
general, so the java programmer can use that time to make their GUI
better. Web examples (sample code) tend to work, unlike C++ where if you
download something, there is only a miniscule chance that it will compile
after 20-30 minutes of fiddling.

Blah - I'm just blabbering. My point is that coding in Java saves times,
and lessens bugs. It will make the end result better. All the bad
things I thought of Java are pretty much gone.

The reason I am replying is you just seem to have contempt. "Actual
Programming" problems will arise, they will just be less mundane.

I think you might be confusing Java with VB.

Trust me though - you can practice algorithms and data structures in
Java - I do so at least 3 times a week on topcoder.

--
LTP

:)


Well said. "Actual programmers" shouldnt spend a large chunk of dev time on
things like standard data structures, memory managment and well known
algorithms.
Apr 27 '06 #27

P: n/a
In comp.lang.java.advocacy, we***********@yahoo.com
<we***********@yahoo.com>
wrote
on 26 Apr 2006 15:05:15 -0700
<11**********************@y43g2000cwc.googlegroups .com>:
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!"


[rest snipped]

First rule of software: know thy tools. This includes
the computer, the compiler, and the environment.

Both Java and C++ aim for a niche: the specification of
instructions to a modern computer. There are, of course,
many differences.

[1] Java hides pointers. This can be a good or a bad
thing; it's good in that Java has the option of playing
garbage collect (built in). It's a bad thing when Java
developers forget and leave an object to moulder in
a global collection map and then wonder why there's a
"memory leak".

[2] Java does not have operator overloading. C++ does.
In C++, this can be a convenience but it also can lead to
some hairy expressions.

[3] Java does not have a C preprocessor. C++ does. And
one thought operator overloading was bad. The Obfuscated
C process is testimony to some of the abuses of a useful
construct; fortunately those are for humorous purposes.

[4] C++ doesn't have packaging. Java does. While there
are some quirks in the implementation of packaging in Java,
it's a very nice way to organize one's code.

[5] Java doesn't have explicit deletes. The garbage
collection is expected to take care of things. (There are
some exceptions; a FileOutputStream for example will be
left open indefinitely, even if the reference is lost.)

There's a fair number of others but these will do for a start.

In any event, many programmers, myself included, migrated
from C++ to Java. To call us stupid invites ridicule, if
not worse.

As for operator overloading -- I'll admit, I occasionally
miss it. Matrix operations in particular would benefit
somewhat from a shortening of the notation; one could write
P = M * N instead of P = M.multiplyBy(N). But operator
overloading does complicate the language, requiring the
compiler to sort out whether an operator is overloaded or
not (and operator precedence issues). In Java it would
be especially bad as the operator may require a run-time
lookup.

If one assumes that an operator can be declared by the pseudo-code
(which looks suspiciously like C++, of course :-) )

String operator+ (String x, String y)
{
StringBuffer z = new StringBuffer();
z.append(x);
z.append(y);
return z.toString();
}

Integer operator+ (Integer x, Integer y)
{
return new Integer(x.intValue() + y.intValue());
}

and then have a code sequence

Object a;
Object b;
Object c = a + b;

what operator should be executed, and when should this be determined?
C++ doesn't have this problem, as all routines are determined at
compile time except for virtual methods.

It is possible Java could implement a C++-like solution (and complain
in the above case as I've not defined operator+(Object,Object)) but
someone will probably be unhappy with whatever solution is finally
implemented.

One can also compare Java to C#. I lack expertise in C# beyond what
I've seen in the press but know that C# has the interesting property of
converting an assignment:

a.b = c.d;

into a sequence of function calls:

a.setB(c.getD());

by a declaration within the classes somehow.

This can get arbitrarily tricky. I'm not sure if I like this property
or not. As I understand it, interactions with [] further complicate
things.

Java avoids all this; except for an issue that one can have variable
lengths in each array row in an Object[][] variable (which is easy
to resolve with some care), one can be sure that

a.b = c.d;

means

a.b = c.d;

:-)

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

P: n/a
Ben
REH wrote:
Luc The Perverse wrote:
Java is simpler, cleaner - but programming is programming.

Yeah, and that's why I write real-time systems in Perl. Languages are
tools. Use the right one for the right job. No language has yet
filled the "one-size-fits-all" catagory.

REH


I've programmed both in JAVA and C++

Try writing a OS in JAVA...wait is that even possible?

or try writing web based programs in C++, get ready for a headache...
Apr 27 '06 #29

P: n/a
>
c) You don't have to decide about programming style. Sun provided
standard Java style.
Juck!


You don't like Sun Style? I find it not worse than any other, and it has
advantage that most Java programmers use it. In C, for example, Linux
core uses one style, and Gnu uses other, incompatible style, and
Microsoft, of course, uses third.
d) You don't have to decide about naming of files and classes - they
are the same.
no, they _have to be_ the same. Otherwise the compiler pukes.


Of course everything I wrote here (style is exception) is enforced by
compiler. That's what compiler is for.
e) Logical package directory structure is forced on you.
What about freedom of choice?


My main idea in my post was that freedom of choice is often Bad. Anyway,
I don't insist on this as a law, only as my personal preference. May be
you value freedom of choice in programming more. Then C++ obviously has
advantages for 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.
Yeah, and a lot slower in some cases. User std::string where you need
dynamic strings, use char[] where you need static strings. You don't
have to - but you _can_!


I benchmarked strings long time ago. My impression - C strings are much
faster, STL/CStrings have about the same speed (I don't remember
exactly) as Java strings. But C strings created their own (apparently
very big) category of security breaches. Bottom line - you don't lose
much, if anything, by sticking to Java strings.
g) you don't have to choose between long int, unsigned int, WORD,
DWORD, size_t .... - close to optimal choice if forced on you.
Just a question of style. I use the built-in tpyes for everything.


And I am a little bit sick of casting size_t to int. Or remembering what
to use: long long or _int64.

Well, if you knew C++ as good as Java, you wouldn't say so I guess.

I suspect it is not my fault that I better know Java than C++. I spend
10 years programming mostly on C++ and only 5 years mostly on Java. It
is just more easy to learn Java.
Apr 27 '06 #30

P: n/a
They /both/ suck.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Apr 27 '06 #31

P: n/a
REH

Ben wrote:
REH wrote:
Luc The Perverse wrote:
Java is simpler, cleaner - but programming is programming.

Yeah, and that's why I write real-time systems in Perl. Languages are
tools. Use the right one for the right job. No language has yet
filled the "one-size-fits-all" catagory.

REH


I've programmed both in JAVA and C++

Try writing a OS in JAVA...wait is that even possible?

or try writing web based programs in C++, get ready for a headache...


I don't know if you are agreeing with me or just misunderstood my
statement.

REH

Apr 27 '06 #32

P: n/a
In comp.lang.java.advocacy, Ben
<be******@vt.edu>
wrote
on Thu, 27 Apr 2006 11:03:52 -0400
<e2**********@solaris.cc.vt.edu>:
REH wrote:
Luc The Perverse wrote:
Java is simpler, cleaner - but programming is programming.

Yeah, and that's why I write real-time systems in Perl. Languages are
tools. Use the right one for the right job. No language has yet
filled the "one-size-fits-all" catagory.

REH


I've programmed both in JAVA and C++

Try writing a OS in JAVA...wait is that even possible?


It's been done, although AFAIK it didn't fare all that well in the
marketplace.

http://en.wikipedia.org/wiki/JavaOS

A freeware variant is also active. This one looks rather interesting,
although the compatibility list is a little skimpy...but then, that's
why freeware is such fun; someone will write those drivers (and one
might port them from equivalent Linux drivers) if they need them.

http://www.jnode.org/

or try writing web based programs in C++, get ready for a headache...


Not as bad as one might think if one avoids pointers and
sticks to the Standard Template Library. However, Java
may very well be more efficient under those conditions,
as it copies pointers instead of entire structures.

There is one thing missing from Java, the equivalent
of std::multiset<> and std::multimap<>. However, the latter
can be replaced by std::map<..., std::list<>>, and I don't
know of any really good uses for the former offhand that
wouldn't be better served by a std::multimap<> or a
std::map<...,std::list<>>.

--
#191, ew****@earthlink.net
Windows Vista. Because it's time to refresh your hardware. Trust us.
Apr 27 '06 #33

P: n/a
"Ben" <be******@vt.edu> wrote in message
news:e2**********@solaris.cc.vt.edu...

Try writing a OS in JAVA...wait is that even possible?


http://en.wikipedia.org/wiki/JavaOS

- Oliver

Apr 27 '06 #34

P: n/a
On Wed, 26 Apr 2006 22:48:25 GMT, Mishagam <no*****@provider.com>
wrote, quoted or indirectly quoted someone who said :
I agree that may be C++ programmers are smarter.


There are two meaning for smarter.

There is a the sort of guy who can keep his home books doing all the
arithmetic in his head.

There is the sort of guy who uses an adding machine with a tape for
verification.

The first has more raw skill. The second gets the job done more
accurately with less effort, and gets to go fishing sooner.

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 27 '06 #35

P: n/a

Mishagam wrote:
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.
Three things I _really_ hate about Java.
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.
Actually, you are in err. Java also has char[] and there is nothing
stopping someone from using it or designing a new String. Therefor
Java suffers from the same "problem" as C++ here except there are no
Java functions and tools to work with char[]...you have to write them
from scratch.
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.


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.

I don't think one is better than the other but common, these are just
bad arguments.

Apr 27 '06 #36

P: n/a
On Thu, 27 Apr 2006 10:43:36 GMT, Mishagam <no*****@provider.com>
wrote, quoted or indirectly quoted someone who said :
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).


This is a huge benefit. There are so many addressing modes in C++ that
really don't buy you much other than confusion.

The other huge benefit is platform independence. Java has everything
removed that would temp you to write platform dependent code.

Granted I tend to use a very vanilla style of coding, but platform
specific problems just don't happen to me.

Even writing something as UI-free as a compiler takes a huge amount of
platform-adjusting application code. In Java, that his already
handled by standard libraries.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 27 '06 #37

P: n/a
On Thu, 27 Apr 2006 15:06:53 +0200, "Gernot Frisch" <Me@Privacy.net>
wrote, quoted or indirectly quoted someone who said :

I like new/delete. Makes me feel I'm in charge. Just my .02$


The problem is a bit like "feeling in charge" at a 747 control panel.
You know you are not up to the job for any serious app.

I used to use Numega to track leaks in a C/C++ team's code. It was
not a matter of fixing them, but getting them down to a dull roar.

Mixing exception handling and memory management boggles the human
mind.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 27 '06 #38

P: n/a

Roedy Green wrote:
The other huge benefit is platform independence. Java has everything
removed that would temp you to write platform dependent code.


Well, that is one area where Java *can't* be used then isn't it.

Another can't. Where is the can?

Apr 27 '06 #39

P: n/a
On Thu, 27 Apr 2006 15:48:54 GMT, Mishagam <no*****@provider.com>
wrote, quoted or indirectly quoted someone who said :
c) You don't have to decide about programming style. Sun provided
standard Java style.


Juck!


You don't like Sun Style? I find it not worse than any other, and it has
advantage that most Java programmers use it. In C, for example, Linux
core uses one style, and Gnu uses other, incompatible style, and
Microsoft, of course, uses third.


1. A Java shop can adopt Sun style which every new programmer knows
since they have seen it ad nauseam in the Sun classes.

2. Or a shop can adopt its own more rigid super set of Sun rules.

3. Or a shop can adopt its own style.

4. Or a shop can adopt chaos and start blood feuds between programmers
to poison the coffee of the programmers who reformat "their" code and
deal with repository false deltas.

How is a C++ shop better off having only choices 3 and 4?

see http://mindprod.com/jgloss/codingconventions.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 27 '06 #40

P: n/a

Roedy Green wrote:
On Thu, 27 Apr 2006 15:06:53 +0200, "Gernot Frisch" <Me@Privacy.net>
wrote, quoted or indirectly quoted someone who said : Mixing exception handling and memory management boggles the human
mind.


Only one incapable of learning very simple techniques to make it a
non-issue.

http://www.hackcraft.net/raii/

Note that this won't work in Java. You can't use this technique to
clean up resources like handles and other resources that are not memory
related as you can't depend on the deallocation of any object in your
code; GC picks it up when it wants to.

There are also the three exception guarantees, which are applicable in
ANY language, that also make exception handling in C++ less risky.

If you aren't capable of avoiding a memory leak in an exceptional
situation then you can't handle any other kind of leak and believe
me...the problem exists in ANY language that has exceptions as there
are numerous resources that you gather and have to release that are not
memory related and so you can't use GC as a crutch for that.

So, if your mind is boggled by memory and exception handling then you
better stick to simple problems.

Apr 27 '06 #41

P: n/a
The Ghost In The Machine wrote:
[5] Java doesn't have explicit deletes. The garbage
collection is expected to take care of things. (There are
some exceptions; a FileOutputStream for example will be
left open indefinitely, even if the reference is lost.)


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
be destroyed when leaving scope. Why?) How do you do RAII in Java?

--
Martin
Apr 27 '06 #42

P: n/a
On Wed, 26 Apr 2006 23:56:50 -0600, "Luc The Perverse"
<sl***********************@cc.usu.edu> wrote, quoted or indirectly
quoted someone who said :

Learning C++ is marginally more difficult than learning Java.

I used to be a die hard C++ advocate - but the added complexity doesn't
really add a great deal of usability; but it is great for obscuring the
meaning of the code.


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.

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.

I think of computer languages as like species of dinosaur. Each new
species can build on the last and do one new "trick". It would be
silly to expect one early dinosaur to be the ultimate. Because others
built on the shoulders of its design does not detract from the
"pioneering" work of the earlier species.

People like to pretend their current favourite is the end point in
language evolution. Getting too attached just slows evolution. We
have a long way to go.

We will have to give up more and more fine control, and let more and
more programming be handled by the augmented equivalent of CSS style
sheets. We will have to get used to the idea of specifying the
desired results and letting computers figure out the best algorithms.

The big change will be the effect of the SCID on language design. A
program will become a set of structured data describing how you want a
computer to behave. It won't just be a text stream. It will consist of
binary data, dialogs, images, internationalisation, cross references,
declarations, rules of thumb, style sheets, spreadsheets, PET tables,
examples, online/offline documentation, algorithms that can be
displayed in dozens of different ways, even flow charts.

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 27 '06 #43

P: n/a

"Noah Roberts" <ro**********@gmail.com> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...

Roedy Green wrote:
On Thu, 27 Apr 2006 15:06:53 +0200, "Gernot Frisch" <Me@Privacy.net>
wrote, quoted or indirectly quoted someone who said :

Mixing exception handling and memory management boggles the human
mind.


Only one incapable of learning very simple techniques to make it a
non-issue.

http://www.hackcraft.net/raii/

Note that this won't work in Java. You can't use this technique to
clean up resources like handles and other resources that are not memory
related as you can't depend on the deallocation of any object in your
code; GC picks it up when it wants to.

There are also the three exception guarantees, which are applicable in
ANY language, that also make exception handling in C++ less risky.

If you aren't capable of avoiding a memory leak in an exceptional
situation then you can't handle any other kind of leak and believe
me...the problem exists in ANY language that has exceptions as there
are numerous resources that you gather and have to release that are not
memory related and so you can't use GC as a crutch for that.

So, if your mind is boggled by memory and exception handling then you
better stick to simple problems.


It's quite tricky to be really condecending and really wrong at the same
time but hey, somehow you managed. Rather than question the intelligence and
expertise of someone who offered perfectly valid points you may want to
consider either actually having a look at Java instead of browing Java
newsgroups ready to jump in on the first sigh of a troll. I'd be more than
interested in even a single practical example of these resource/exception
issues of Java you speak of that are so much easier in C++...just one..
Apr 27 '06 #44

P: n/a

"Noah Roberts" <ro**********@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...

Mishagam wrote:
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.


Three things I _really_ hate about Java.
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.


Actually, you are in err. Java also has char[] and there is nothing
stopping someone from using it or designing a new String. Therefor
Java suffers from the same "problem" as C++ here except there are no
Java functions and tools to work with char[]...you have to write them
from scratch.
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.


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.

I don't think one is better than the other but common, these are just
bad arguments.


You do think one is better than the other, it's just a flawed way of
reasoning. Also, all arguments you mentioned in your posts range from
somewhat doubtful to factually inaccurate. You're just bashing, which is a
waste of time for people that bother reading this. Move along.
Apr 27 '06 #45

P: n/a
Noah Roberts wrote:
Roedy Green wrote:
On Thu, 27 Apr 2006 15:06:53 +0200, "Gernot Frisch" <Me@Privacy.net>
wrote, quoted or indirectly quoted someone who said :

Mixing exception handling and memory management boggles the human
mind.


Only one incapable of learning very simple techniques to make it a
non-issue.

http://www.hackcraft.net/raii/


There's another way to do it - scope guard. Here's an article on it:
http://www.digitalmars.com/d/exception-safe.html

-Walter Bright
www.digitalmars.com C, C++, D programming language compilers
Apr 27 '06 #46

P: n/a

"Martin Vejnár" <av****@volny.cz> wrote in message
news:e2**********@ns.felk.cvut.cz...
The Ghost In The Machine wrote:
[5] Java doesn't have explicit deletes. The garbage
collection is expected to take care of things. (There are
some exceptions; a FileOutputStream for example will be
left open indefinitely, even if the reference is lost.)


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 be destroyed
when leaving scope. Why?) How do you do RAII in Java?

--
Martin


Have you ever used Java and actually ran into an issue that requires RAII?
Apr 27 '06 #47

P: n/a
* Remon van Vliet -> Noah Roberts
I'd be more than
interested in even a single practical example of these resource/exception
issues of Java you speak of that are so much easier in C++...just one..


All external resources.

They're not "so much easier" to handle in C++. In fact they're /very
difficult/ to handle correctly in C++. However, C++ offers facilities
that make it practically possible to prevent such problems from arising.

People who come from e.g. Java or C tend to not see those issues as
problems, because in those languages there's just no hope of dealing
preventively with fundamental resource leak issues, so the pragmatic
approach of "if it becomes a real problem, let's deal with that concrete
real problem" is applied instead of designing in any guarantee from the
start. Pick up any C or Java code dealing with external resources of
any kind, and more often than not, there's a potential resource leak
staring the C++ programmer in the eye. However, the C++ programmer
would be wrong to chastise the C or Java programmer for that, because
most probably the resource leaks will be consequences of the intentional
pragmatic approach to dealing with the languages' shortcomings: those
potential leaks won't, in general, be actual problematic leaks.

Add to that that C++ is so infernally huge and complex, like COBOL or
PL/1, that it's seldom used correctly by the average programmer.

And in sum that means that the C or Java code may actually have less
relevant resource leaks than the equivalent average programmer's C++
code. Only for the critical support code written by an expert or
experts does C++ shine. Because there the potential can be realized.

--
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 #48

P: n/a

"Walter Bright" <wa****@digitalmars-nospamm.com> wrote in message
news:Dc******************************@comcast.com. ..
Noah Roberts wrote:
Roedy Green wrote:
On Thu, 27 Apr 2006 15:06:53 +0200, "Gernot Frisch" <Me@Privacy.net>
wrote, quoted or indirectly quoted someone who said :

Mixing exception handling and memory management boggles the human
mind.


Only one incapable of learning very simple techniques to make it a
non-issue.

http://www.hackcraft.net/raii/


There's another way to do it - scope guard. Here's an article on it:
http://www.digitalmars.com/d/exception-safe.html

-Walter Bright
www.digitalmars.com C, C++, D programming language compilers


What point am i missing if i mention the "finally" block in Java?
Apr 27 '06 #49

P: n/a

"Alf P. Steinbach" <al***@start.no> wrote in message
news:4b*************@individual.net...
* Remon van Vliet -> Noah Roberts
I'd be more than
interested in even a single practical example of these resource/exception
issues of Java you speak of that are so much easier in C++...just one..
All external resources.


I think this is factually untrue. So, a practical example please?

They're not "so much easier" to handle in C++. In fact they're /very
difficult/ to handle correctly in C++. However, C++ offers facilities
that make it practically possible to prevent such problems from arising.

People who come from e.g. Java or C tend to not see those issues as
problems, because in those languages there's just no hope of dealing
preventively with fundamental resource leak issues, so the pragmatic
approach of "if it becomes a real problem, let's deal with that concrete
real problem" is applied instead of designing in any guarantee from the
start. Pick up any C or Java code dealing with external resources of any
kind, and more often than not, there's a potential resource leak staring
the C++ programmer in the eye.
Perhaps said C++ programmer just isnt overly familiar with Java. It seems to
be the red line through these kind of threads.
However, the C++ programmer would be wrong to chastise the C or Java
programmer for that, because most probably the resource leaks will be
consequences of the intentional pragmatic approach to dealing with the
languages' shortcomings: those potential leaks won't, in general, be actual
problematic leaks.

Add to that that C++ is so infernally huge and complex, like COBOL or
PL/1, that it's seldom used correctly by the average programmer.
Once again this sounds like a C++ developer with a superiority complex.
"Average programmers" here and there. Fact remains i still need to hear of a
external resource leak problem that's consistently easier to deal with in
C++ compared to Java.

And in sum that means that the C or Java code may actually have less
relevant resource leaks than the equivalent average programmer's C++ code.
Only for the critical support code written by an expert or experts does
C++ shine. Because there the potential can be realized.


"Critical support code"? like?
Apr 27 '06 #50

458 Replies

This discussion thread is closed

Replies have been disabled for this discussion.