473,544 Members | 1,972 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 20803
In comp.lang.java. advocacy, Remon van Vliet
<re***@exmachin a.nl>
wrote
on Thu, 27 Apr 2006 20:44:11 +0200
<44************ ***********@new s.xs4all.nl>:

"Walter Bright" <wa****@digital mars-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?


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

--
#191, ew****@earthlin k.net
Windows Vista. Because it's time to refresh your hardware. Trust us.
Apr 27 '06 #61
Remon van Vliet <re***@exmachin a.nl> wrote:
Have you ever used Java and actually ran into an issue that requires
RAII?


Of course no one has. There are no issues that require RAII. That's
irrelevant to the question of whether it is useful. Certainly,
try/finally gets cumbersome sometimes.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Apr 27 '06 #62
> Roedy Green wrote:
Mixing exception handling and memory management boggles the human
mind.

Noah Roberts <ro**********@g mail.com> wrote: Only one incapable of learning very simple techniques to make it a
non-issue.

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


There are two questions being considered simultaneously here. One is
what is required to produce useful software in a language. The other
matter is what is required to understand that language. I side with the
position that a language that's hard to understand has a weakness in
this even if it remains possible to write software using that language.
Exception handling and memory management IS tricky in C++. So is the
relationship between function overloading, implicit type conversions,
and templates.

RAII is a different matter. It's a nice feature to have; but it doesn't
make the language any easier to understand.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Apr 27 '06 #63

Chris Smith wrote:
Roedy Green wrote:
Mixing exception handling and memory management boggles the human
mind.

Noah Roberts <ro**********@g mail.com> wrote:
Only one incapable of learning very simple techniques to make it a
non-issue.

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


There are two questions being considered simultaneously here. One is
what is required to produce useful software in a language. The other
matter is what is required to understand that language. I side with the
position that a language that's hard to understand has a weakness in
this even if it remains possible to write software using that language.
Exception handling and memory management IS tricky in C++. So is the
relationship between function overloading, implicit type conversions,
and templates.


Lots of silly statements but no backing. "X is hard." Meaningless.
RAII is a different matter. It's a nice feature to have; but it doesn't
make the language any easier to understand.


Actually, RAII is at the HEART of this matter as it is a commonly used
technique to deal with the issue put forth. It is a very simple
concept and it works not only for memory management but also any other
resource that needs to be aquired and released.

Apr 27 '06 #64
Remon van Vliet wrote:
"Walter Bright" <wa****@digital mars-nospamm.com> wrote in message
news:Dc******** *************** *******@comcast .com...
Noah Roberts wrote:
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

What point am i missing if i mention the "finally" block in Java?


'finally' works fine for one level of undo. It doesn't work so well (and
neither does RAII) if there are multiple operations that must all
succeed or none have happened. For example, if a transaction consists of
transactions A, B, and C, and A and B succeed but C fails, one must
unwind B and C. The article goes into more depth with this including
examples.

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

Apr 27 '06 #65
Noah Roberts wrote:
Also, you could read that article above which shows some shortcommings
of both RAII and finally. However, the "scope guard" appears to be a D
language particular construct so is rather moot in this discussion.


There's a link at the end of the article with Andrei Alexandrescu's
technique for doing a limited form of scope guard in C++.

http://www.digitalmars.com/d/exception-safe.html

-Walter Bright
www.digitalmars.com C, C++, D programming language compilers
Apr 27 '06 #66
In article <44************ ***********@new s.xs4all.nl>,
Remon van Vliet <re***@exmachin a.nl> wrote:

We're all aware Javascript is completely unrelated to Java right?


Well, "completely unrelated" may be going a bit too far (it's more
like the wayward half brother that comes around to borrow money from
you every now and then, who you don't like to talk about in polite
company) but it is definately a different language.

Cheers
Bent D
--
Bent Dalager - bc*@pvv.org - http://www.pvv.org/~bcd
powered by emacs
Apr 27 '06 #67
Remon van Vliet wrote:
Have you ever used Java
No
and actually ran into an issue that requires RAII?


Require is a strong word. You can always do without RAII. You just have
a greater chance of losing precious time trying to figure out where
exactly have you forgotten to release that mutex...

Garbage collector may be good when it comes to releasing memory, but
memory is not the only resource you use. How about files, network
streams, database connections, synchronization primitives, etc?

A reply from "The Ghost In The Machine" has mentioned try..finally.
Whenever you use that construct to safely dispose of a resource, you're
better off using RAII.

Btw, I'm not really sure, but is the finally block executed, when you do
'return' from inside the try block?

--
Martin
Apr 27 '06 #68
In article <e2**********@s olaris.cc.vt.ed u>, Ben <be******@vt.ed u> wrote:

I've programmed both in JAVA and C++

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


This is easily possible (and reasonably common) on smart card chips,
many of which support Java bytecode natively.

Java-based CPUs for desktops have been tried I think, but it didn't
take off.

Cheers
Bent D
--
Bent Dalager - bc*@pvv.org - http://www.pvv.org/~bcd
powered by emacs
Apr 27 '06 #69
* Walter Bright:
Noah Roberts wrote:
Also, you could read that article above which shows some shortcommings
of both RAII and finally. However, the "scope guard" appears to be a D
language particular construct so is rather moot in this discussion.


There's a link at the end of the article with Andrei Alexandrescu's
technique for doing a limited form of scope guard in C++.

http://www.digitalmars.com/d/exception-safe.html


I think you should get the attributions right (sorry, how could I put
this in a more gentle way?): ScopeGuard was Petri Marginean's invention,
and he co-authored the CUJ article with Andrei.

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

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

Similar topics

0
6787
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
6904
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
9215
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
5640
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...
1
9594
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...
12
5894
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...
0
3255
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...
1
4289
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 = ...
0
3242
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
7420
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7362
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...
1
7368
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...
0
7704
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...
1
5291
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...
0
4911
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...
0
3407
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...
0
3404
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
983
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.