473,842 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

On Java and C++

Java programmers seem to always be whining about how confusing and
overly complex C++ appears to them. I would like to introduce an
explanation for this. Is it possible that Java programmers simply
aren't smart enough to understand C++?

This is not merely a whimsical hypothesis. Given my experience with
Java programmers --- the code they write and the conversations they
have --- Occam's Razor points to this explanation. For example,

"Oooh I'm confused about the difference between pointers, references,
and objects! How confusing!"

"Oooh operator overloading confuses me! The expression x + y is so
confusing, who knows what's happening with that? If x and y are
complex numbers, what the hell could x + y mean?"

"Oooh multiple inheritance is so confusing! Though I am both a father
and a programmer, I still find it so confusing how the same object can
be two different things! How confusing!"

"Oooh and virtual bases are so bizarre! I am a student --- myself
'the father' is the same student as myself 'the programmer' --- but
nonetheless the idea of virtual bases is absolutely confounding and
confusing to me!"

Again, Occam's Razor is a valuable tool here. In deciding among
competing hypotheses, choose the simplest one. To impartial observers
of indoctrinated Java programmers, the explanation is simple indeed.

Apr 26 '06
458 21557
Oliver Wong wrote:
Windows XP with SP2, Pentium 4 1.8Ghz, 1024MB RAM, Firefox 1.5.0.2.

Java took 3 seconds, Flash took 5 seconds.


That sounds wrong to me. Did your browser already have a JVM started (as is
likely if -- for example -- you'd visited Roedy's site since you last killed
all your Firefox windows) ?

FWIW, Flash is instant on my WinXP + Firefox settup -- I won't have Flash
installed so it fails without noticeable delay ;-)

-- chris
May 2 '06 #281
"Remon van Vliet" <re***@exmachin a.nl> wrote in
news:44******** *************** @news.xs4all.nl :

"Chris Smith" <cd*****@twu.ne t> wrote in message
news:MP******** *************** *@news.astraweb .com...
I V <wr******@gmail .com> wrote:
Actually, I've never really had a problem with resources being
released by
GC systems either, but I don't develop the sort of applications
where I would imagine it being a problem. I'd be interested if
anyone knows of any
actual studies which have investigated in precisely what cases
non-deterministic destruction causes real-world problems. Or,
indeed, anecdotal experience from those with a wider range of
experience than my own.


If you're asking what I think you are, then I have such anecdotal
evidence. About a year ago, I fixed a web application that wouldn't
release a database connection if the user clicked the stop button at
a certain time. This generally didn't cause any problems, since the
JDBC spec requires that finalization will close the connection (a
very bad choice, by the way, which prevented this bug from be
discovered in testing). The app started failing by running out of
database connections when it was sold and installed for a very large
customer who had far more users than were previously seen.

That was with database connections being released in a timely manner
most of the time, and only occasionally being left open in certain
failure cases. I'd hate to see what would've happened if database
connections were never explicitly closed at all!


Hehe, okay, in that is Java weakness rather than bad programming? I'm
lead developer of high-concurrency servers and i cant begin to count
the number of times we use JDBC connections and file access. Not once
have we ran into any such issue. Not dealing with all escape paths is
simply bad implementation and certainly not a language weakness, Java
just makes that quite easy at times with the "finally" block....


While what you say IS true, you should handle all escape paths, I do have
to agree that RAII(or should we focus on the other end, RDIF Resource
Diallocation is Finalization) often makes it easier to handle all escape
paths. It is common in C++ to create a class on the stack that
locks/unlocks/opens a resource during construction and returns it to its
original state in its destructor. Having done so you can forget about it.
No need to deal with it at all when the method using it exits. Even
during exceptions. You know the destructor will have been called once you
are out and all will be as it was.

When I work with Java I often miss the ease deterministic destructors
provide. And I also sometimes miss 'finally' and anonymous classes when
programming in C++.

RAII is a tool. You don't need it but it does make things a lot easier
when its can be used.

Otis

May 2 '06 #282
ebhakt wrote:
It's not of being smarter or not....

I am both a C/C++ and JAVA coder :

c is flexible :
this is both a merit and demerit (depending on programmers
capabilities)

Java takes care of this for both lame and stunt performers...

Its simple for those who want to go that way
but for big guys JAVA has much more......

You should not forget that JAVA was the Impetus behind internet ,
this language should be given respect


No, the american military and the threat of nuclear war was the impetus
behind the internet, which started coming into being at the tail of of
the 60s. Java didn't exist until the 90's.
May 2 '06 #283
Remon van Vliet schrieb:
"Chris Smith" wrote:
That was with database connections being released in a timely manner
most of the time, and only occasionally being left open in certain
failure cases. I'd hate to see what would've happened if database
connections were never explicitly closed at all!


Hehe, okay, in that is Java weakness rather than bad programming? I'm lead
developer of high-concurrency servers and i cant begin to count the number
of times we use JDBC connections and file access. Not once have we ran into
any such issue.


The same argument could be used for unmanaged memory allocation. In that
sense, memory leaks are the result of bad programming, not a weakness of
the language.
Timo
May 2 '06 #284

Otis Bricker wrote:
RAII is a tool. You don't need it but it does make things a lot easier
when its can be used.


There it is.

May 2 '06 #285

"Chris Uppal" <ch*********@me tagnostic.REMOV E-THIS.org> wrote in message
news:44******** *************@n ews.gradwell.ne t...
Oliver Wong wrote:
Windows XP with SP2, Pentium 4 1.8Ghz, 1024MB RAM, Firefox 1.5.0.2.

Java took 3 seconds, Flash took 5 seconds.


That sounds wrong to me. Did your browser already have a JVM started (as
is
likely if -- for example -- you'd visited Roedy's site since you last
killed
all your Firefox windows) ?


No. I retested just now (quit firefox, went into task manager to make sure
no hidden firefox.exe process was running), and got a similar result
(between 2 and 3 seconds). I do have Eclipse running in the background, but
as I mentioned earlier, I doubt Firefox is sharing the JVM with Eclipse.

- Oliver

May 2 '06 #286
ebhakt wrote:
It's not of being smarter or not....

I am both a C/C++ and JAVA coder :

There is NO C/C++ language.

There is the C Language and the C++ language. There are compilers that
will compile source files from both languages - but there is no C/C++
language.

c is flexible :
this is both a merit and demerit (depending on programmers
capabilities)

Java takes care of this for both lame and stunt performers...

Its simple for those who want to go that way
but for big guys JAVA has much more......

You should not forget that JAVA was the Impetus behind internet ,
this language should be given respect
what are you talking about?



....
.......and its programmers are not just smart..they are bigger than
that

Bhaskar

May 2 '06 #287
Roedy Green wrote:
On 28 Apr 2006 00:59:19 -0700, "al pacino" <si************ *@gmail.com>
wrote, quoted or indirectly quoted someone who said :
improve your programming skills and what better tool to do that than
using c++.


You might find the work of W. Edwards Deming interesting. He was the
man who taught the art of quality control to the Japanese.

He argues there is no point in exhorting people to be better. You
have to change the environment so they naturally and without
additional effort produce better results.


This is insightful, and in my experience, correct. C++ has a problem in
that the 'right' way to do things is significantly more work than the
'wrong' way. For example, instead of:

int a[3];

I am supposed to write:

#include <vector>

vector<int> a(10);

If one expects people in general to write better programs, the
programming language should be designed so that the straightforward ,
simpler expression is the right one. Doing the wrong thing should
require more work.

This principle is evident in things like power tools and aircraft
design. In the former, you've got to do extra work to remove things like
guards and safety interlocks. In aircraft design, one of the terrible
no-no's is for a mechanic hook up the flight controls backwards. So the
designers go to great lengths to make it very hard for the mechanic to
do so, hopefully hard enough so that at some point the mechanic realizes
he must be doing something wrong. If it's easy to install the flight
controls backwards, sooner or later it will be, with deadly consequences.
-Walter Bright
www.digitalmars.com C, C++, D programming language compilers
May 2 '06 #288
"Walter Bright" <wa****@digital mars-nospamm.com> wrote in message
news:co******** ************@co mcast.com...

If one expects people in general to write better programs, the programming
language should be designed so that the straightforward , simpler
expression is the right one. Doing the wrong thing should require more
work.

This principle is evident in things like power tools and aircraft design.
In the former, you've got to do extra work to remove things like guards
and safety interlocks. In aircraft design, one of the terrible no-no's is
for a mechanic hook up the flight controls backwards. So the designers go
to great lengths to make it very hard for the mechanic to do so, hopefully
hard enough so that at some point the mechanic realizes he must be doing
something wrong.


I go through this experience all the time, e.g. when trying to assemble
furniture. It's incredibly difficult (e.g. the male connector will not fit
into the female connector, even if I try slam my entire body mass,
accelerated by gravity, to force them together), so I wonder if I'm doing
something wrong, but I'm staring at the assembly diagram (all pictures, no
words, supposedly in the interest of i18n), and I can't find any other
reasonable interpretation of the instructions than the one I was following
thus far.

I eventually end up with a working piece of furniture (e.g. if it's a
chair, then yes, you can sit on it; a table, yes, you can place items on
it), but inevitably, there are spare parts, and the box that the furniture
came in is just plain indescript brown cardboard, with no "real life"
picture to compare against to see if I got it right.

- Oliver

May 2 '06 #289

"Andrew McDonagh" <ne**@andmc.com > wrote in message
news:e3******** **@news.freedom 2surf.net...
ebhakt wrote:

I am both a C/C++ and JAVA coder :


There is NO C/C++ language.

There is the C Language and the C++ language. There are compilers that
will compile source files from both languages - but there is no C/C++
language.


Perhaps "C/C++" is C++ "spoken" with a C "accent".

- Oliver

May 2 '06 #290

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

Similar topics

0
6821
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what the issue is. Thanks Ravi
1
6923
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
11
9294
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
0
5662
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to connect to the DB I get the following exception at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2120)
1
9668
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
12
5935
by: Mark Fink | last post by:
I wrote a Jython class that inherits from a Java class and (thats the plan) overrides one method. Everything should stay the same. If I run this nothing happens whereas if I run the Java class it says: usage: java fit.FitServer host port socketTicket -v verbose I think this is because I do not understand the jython mechanism for inheritance (yet).
0
3292
by: jaywak | last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)) and in both cases, get the following list returned from calling getDeclaredFields() on java.lang.ClassLoader via this code snippet: Field fields = loaderClass.getDeclaredFields(); for (int i = 0; i <...
1
4310
by: jaimemartin | last post by:
hello, I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in Linux there is an error. The code that fails is the following: SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); I´m sure that code is ok. In fact, I´ve found that in several...
0
3301
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
0
10610
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10670
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10308
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
9451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7030
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5695
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4087
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3141
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.