473,889 Members | 1,437 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 21637
On 27 Apr 2006 16:08:05 -0700, "peter koch"
<pe************ ***@gmail.com> wrote, quoted or indirectly quoted
someone who said :
What is it in Java that makes it
less low-level in a similar problem than Java?


In C++ you have quite a variety of addressing operators
.., ->, prefix &, postfix &, prefix *, postfix *, :: (in a way),
overloaded operators and probably some I overlooked.

In Java there is only one, the dot.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #121
Roedy Green wrote:
On 27 Apr 2006 16:08:05 -0700, "peter koch"
<pe************ ***@gmail.com> wrote, quoted or indirectly quoted
someone who said :

What is it in Java that makes it
less low-level in a similar problem than Java?

In C++ you have quite a variety of addressing operators
., ->, prefix &, postfix &, prefix *, postfix *, :: (in a way),
overloaded operators and probably some I overlooked.

In Java there is only one, the dot.


Which is kind of what us C++ types strive for with our smart pointers :)

Except ours is the ->

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


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

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

You appeared to believe they had no value at all.

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

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #123
On Fri, 28 Apr 2006 00:25:18 GMT, Mishagam <no*****@provid er.com>
wrote, quoted or indirectly quoted someone who said :
You make Java sound like a jail sentance.

Yes, it COULD easily become jail. The beauty of Java is that all choices
are made so clever, that they are very close to optimal, and (I am sure
for me) that advantage of not having to think about alternatives
overweights possible gains from other choices.
It also makes different pieces of software much more compatible.


To assert you independendence in Java, you don't rebel against the
trivial conventions. Metaphorically speaking, you don't just wear a
nose ring to spite your parents. You express your creativity at a
higher level.

The advantage is, it is pretty easy for any Java programmer to come
along and make sense of any of your low level code with almost no
effort. All the low level stuff is done in the most boring idiomatic
standard way. The problem is always trying to figure out how it all
fits together..

This stereotypical coding style also means you can dig into anybody
else's code with relatively little effort to learn from it or change
it or override it. Java coding is anything but tricky.

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #124
On Fri, 28 Apr 2006 01:47:41 GMT, Roedy Green
<my************ *************** ***@munged.inva lid> wrote, quoted or
indirectly quoted someone who said :
You also sounded independent and argumentative, not the type of person
who can stand working in a corporate team environment for very long.
You have to bite your tongue till it bleeds.


Being team LEADER is quite different from team MEMBER. Autocrats can
succeed, but only as leader.

Being team leader is incredibly fun if you have some supportive
members. Tons of work get done, all as if you had done it yourself,
but without the effort. Your team keeps you from doing stupid things
and keep up the enthusiasm with a constant stream of ideas. Even if
you are dog tired the team keeps on plugging.

When the team gets into the groove everyone feels it. Everyone is
energised. It is just magical. I would literally fall in love with my
team, so pleased at the way they gave me this power to create so
effortlessly. After dealing with computers, folk who do what I mean
rather than do what I say are such a relief.

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #125
On 27 Apr 2006 16:27:49 -0700, "Noah Roberts" <ro**********@g mail.com>
wrote, quoted or indirectly quoted someone who said :
I know all about that.


You seem to have forgotten the difference between email and
newsgroups. These are public posts not done exclusively for your
highness's entertainment.
..
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #126
On Thu, 27 Apr 2006 16:07:01 -0700, Walter Bright
<wa****@digital mars-nospamm.com> wrote, quoted or indirectly quoted
someone who said :
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.


My original peeve in Java was making byte signed. It should have been
unsigned by default or there should have been an separate unsigned
primitive.

The original I/O library is a dog's breakfast. There is no
orthogonality. It as though every class were written by a different
programmer confined in solitary.

Conversion methods lack a consistent naming convention.

Casting should have been a postfix operation.

I think we will come to regret type erasure in generics. It has added
too much craziness and means you lose track of type info on
serialization. You can't even implement ArrayList with its features
without cheating.

For C++ I think I would nail down the names and sizes in bits of each
primitive the way Java does. I would see what could be done to reduce
the number of addressing modes and operators. 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.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Apr 28 '06 #127
Roedy Green <my************ *************** ***@munged.inva lid> wrote:
In C++ you have quite a variety of addressing operators
., ->, prefix &, postfix &, prefix *, postfix *, :: (in a way),
overloaded operators and probably some I overlooked.


As an aside to the conversation, there is no postfix * or postfix &. I
presume you are thinking of type declarations, but these symbols are
applied as prefix syntax to the identifier in a type declaration, not as
a postfix to the type. True, though, the syntax is certainly more
complex. This isn't fundamentally a syntactic problem, though... it's
fundamentally a matter of memory model complexity. Case in point: the
C++ language would be no simpler for having the "." operator
automatically dereference pointers when applied to them; quite the
contrary, as a matter of fact.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Apr 28 '06 #128
Mishagam <no*****@provid er.com> wrote:
Yes, you can use char[] (or byte[]), but as you said it has no support,
so nobody uses it (as opposed to String, which is more heavily supported
than any C/C++ strings version). It is VERY rare Java programmer who
would spend time deciding which string representation to use.
True, true, except not quite. There are certainly a number of choices
in Java for representing a character sequence, depending on the
requirements of the situation. Sometimes, for example, it's more
efficient to do string operations directly on a java.nio.CharBu ffer for
performance reasons. The Swing JPasswordField class has a getPassword
method that returns a char[] so that the information can be cleared from
memory immediately after use. String wouldn't work for that, because
it's immutable... the information would survive in RAM or swap space
until the GC reclaims the memory and allocates it to a new object.
There are also java.lang.Strin gBuilder and the older
java.lang.Strin gBuffer, for working with rapidly mutating strings in a
way that minimizes copying of information.

Certainly not as bad as the situation in C++, since all of these
alternatives are rare and (with the exception of the now-outdated
StringBuffer class) necessitated by the varying requirements of
different situations. Nevertheless, it's not quite so clear-cut as it
sounded from your post.

Of course, String is used 99.5% of the time, and there are easy ways to
convert back and forth to/from the other options most of the time, and a
common interface java.lang.CharS equence for all but the char[]
possibility.
It also makes different pieces of software much more compatible.


Bingo. There are a lot of things that would make sense about freedom of
choice if you only had to deal with your own code.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Apr 28 '06 #129
Roedy Green wrote:
For C++ I think I would nail down the names and sizes in bits of each
primitive the way Java does.
D does that.
I would see what could be done to reduce
the number of addressing modes and operators. 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 using operators for unrelated functions is a bad design
idea. Enshrining iostreams' use of << and >> for non-arithmetic purposes
in the Standard was a worse idea, as it legitimizes such uses.

Operator overloading should be used only for the purpose of making user
defined types work like built-in types.

-Walter Bright
www.digitalmars.com C, C++, D programming languages
Apr 28 '06 #130

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 Im 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); Im sure that code is ok. In fact, Ive 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
9805
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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
10785
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
10887
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
10439
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
5825
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
6025
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4249
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3253
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.