473,889 Members | 1,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

On Java and C++

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

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

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

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

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

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

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

Apr 26 '06
458 21648
if you need power and performance from a language then you can expect
it to be simpler.

java scores in free and special purpose libraries.

Apr 28 '06 #141
> Language design is complicated, with lots of tradeoffs. I don't know any
language that doesn't contain at least one stupid feature its designer
should have known better about.


I know a couple.
Granted, these people had very clear objectives the day they set out to
write their language, and every choice can be traced back to those
objectives. However, Java and C++ have nothing at all to do with programming
language theory. It's strange what the critical mass prefer, even if it
violates their interest (but appears not to). I suspect some sociology can
explan that a bit better than I can with thought experiments.

--
Tony Morris
http://tmorris.net/
Apr 28 '06 #142

Roedy Green wrote:
[snip]
For C++ I think I would nail down the names and sizes in bits of each
primitive the way Java does. Why? If a CPU does not have a 32-bit integer or an 8-bit char or a IEEE
floating point you could then not write C++ programs on it. That seems
a severe restriction to me.
If you want to restrict yourself to "fixed-bit" ints, you simply need
to include a small include file (standard in C - if not available with
your compiler you can create one in no time). I would see what could be done to reduce
the number of addressing modes and operators. It's time to come out of the bush. What adressing mode is not needed?
Anyone with a reasonable knowledge of C++ knows theyre all necesarry.I would either define
some additional operators to use in overloading or allow users to
specify the new operators so that you don't have ambiguity. C++
reuses the same operators for unrelated functions. I have always found
reusing the shift operator for I/O offensive.


I agree that it is unfortunate that you use the same operator here. But
remember: in C++ >> and << are stream, not shift operators.

/Peter

Apr 28 '06 #143
hi ltp,
heard of STL, tempelates (...generic programming)?
and dont you think for once writing your own code for the sake of
practising at least,
improve your programming skills and what better tool to do that than
using c++.

for your vouching for java the same things can be said about python et
al.
and for the gui thing these folks seem to like making the front end
than
writing the actual code!(actually its flaw in them ,not in java , :-)

Apr 28 '06 #144

Roedy Green wrote:
On 27 Apr 2006 16:20:18 -0700, "peter koch"
<pe************ ***@gmail.com> wrote, quoted or indirectly quoted
someone who said :

The one I know with expertise in both systems - James Kanze - believes
C++ to be the best and fastest language for software development. But
then he has very high standards for his software.
I am sure there are many application for which that is true, e.g.
device drivers, JVMs, Microsoft utilities, matrix math packages.


Also lots and lots of applications.

However, I know C++ is not the best choice for many others. I know
from first hand, rather than second hand experience. For a start,
there is not even such an animal as a C++ Applet. There is nothing
comparable to rich set of GUARANTEED PRESENT class libraries. C++ is
hopeless at platform-independent code. I do agree that Java probably should be used for client side web-based
programming.
That said there is ATL which COM which is used extensively in those
area - resulting in platform dependent code, of course.

/Peter
It all depends on what you are trying to do which tool is best.

And would you kindly can the snide ad hominems. We are discussing
languages, not people. see http://mindprod.com/jgloss/adhominem.html

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.


Apr 28 '06 #145
Chris Smith wrote:
peter koch <pe************ ***@gmail.com> wrote:
// C++
func()
{
class_with_poss ible_ressource cwpr;
dosomethingwith (cwpr);
}


// Java

void func()
{
ClassWithPossib leResource cwpr = new ClassWithPossib leResource();

try
{
doSomethingWith (cwpr);
}
finally
{
cwpr.dispose();
}
}


Could you please give me equivalent Java code for this...

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

....and for this?

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

--
Martin
Apr 28 '06 #146
In article <11************ *********@e56g2 000cwe.googlegr oups.com>,
Noah Roberts <ro**********@g mail.com> wrote:

I know all about that. Point is that it was asserted that C++ is not
as good as Java because Java binary code will run on some processors
but C++ source code won't.


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

Cheers
Bent D
--
Bent Dalager - bc*@pvv.org - http://www.pvv.org/~bcd
powered by emacs
Apr 28 '06 #147
On 28 Apr 2006 00:59:08 -0700, "peter koch"
<pe************ ***@gmail.com> wrote, quoted or indirectly quoted
someone who said :
For C++ I think I would nail down the names and sizes in bits of each
primitive the way Java does.

Why? If a CPU does not have a 32-bit integer or an 8-bit char or a IEEE
floating point you could then not write C++ programs on it. That seems
a severe restriction to me.

the two are not mutually exclusive.

You could do it by saying for example that int32 is a built-in type
and must have precisely 32 bits. That does not stop you from having
some other type
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #148
On 28 Apr 2006 00:59:08 -0700, "peter koch"
<pe************ ***@gmail.com> wrote, quoted or indirectly quoted
someone who said :
It's time to come out of the bush. What adressing mode is not needed?
Anyone with a reasonable knowledge of C++ knows theyre all necesarry


C++ has more addressing modes than other languages except for
assemblers. So obviously they are not "necessary" in some absolute
sense. They are only necessary in the legacy sense. Java has only one
addressing operator.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #149
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.

C++ allows well made programs but does little to insist on or even
encourage them. The beautiful quality remains a theoretical goal
rarely achieved. It is a bit like an impressive high wire act.

You can see the effect. If you look over C++ code you will see a huge
range of quality. If you look at Java code it is much more uniform.
The artisan in you yearns for the sporadic brilliance, but the manager
prefers the uniformity.

As a programmer you see the effect. In Java, a higher percentage of
trouble is caught at compile time. Once you have the compiler happy,
usually the code works. Because of the null pointer checks, enforced
initialisation and subscript checks, if a program works at all there
is a higher probability it is working correctly than the equivalent
C++ program. That means a poor programmer who writes buggy code has a
bigger safety net with Java to watch over him to catch these errors.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #150

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

Similar topics

0
6823
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what the issue is. Thanks Ravi
1
6927
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
11
9298
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
0
5664
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to connect to the DB I get the following exception at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2120)
1
9675
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
12
5939
by: Mark Fink | last post by:
I wrote a Jython class that inherits from a Java class and (thats the plan) overrides one method. Everything should stay the same. If I run this nothing happens whereas if I run the Java class it says: usage: java fit.FitServer host port socketTicket -v verbose I think this is because I do not understand the jython mechanism for inheritance (yet).
0
3295
by: jaywak | last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)) and in both cases, get the following list returned from calling getDeclaredFields() on java.lang.ClassLoader via this code snippet: Field fields = loaderClass.getDeclaredFields(); for (int i = 0; i <...
1
4314
by: jaimemartin | last post by:
hello, I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in Linux there is an error. The code that fails is the following: SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); I´m sure that code is ok. In fact, I´ve found that in several...
0
3304
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
0
9961
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11188
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10789
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10889
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
10441
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9606
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4647
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3255
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.