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
"Phlip" <ph******@yahoo .com> writes:
There is no language C/C++.
It was shorthand for "C or C++". For someone promoting less clutter in
languages you sure seem unable to "parse" common English with reduced
clutter.
You missed the point. If an editor can parse your code and predict what you
are trying to do, then the language could too. The language itself could
finish these lines, and all I'd have to do is start them.
I notice your English sentences are full of words that can be omitted
without changing its meaning, since they can be implied. Why is that?
Do you prefer a readability in English that you would deny in
programming languages?
log4j's src folder has 31,764 lines of code.
Ah. The "this book is better than that book because it's shorter"
argument?
log4r's src folder has 2,071 lines of code.
Noone disputes Ruby code can be more compact than Java code. The
question is whether something - like readability - is lost in the more
terse code.
Again you missed the point. 'virtual' is a weak, primitive keyword
that I can use to assemble a class or an interface. I can control
how concrete and how abstract the class is. Just because I _should_
create interfaces doesn't mean the language should _force_ me to.
Why not? You are forcing yourself to use grammatically correct
English, knowing that plenty of the words you write can be omitted or
replaced by symbols or abbreviations. Like this:

"Again: missed pt. 'virtual' = weak, prim. kwd. I can use 2 assemble
class/interf. I can ctrl. how concrete+abstra ct class is. I
_should_ create interf. != language _force_ me 2."

See how much space you could save?

(Try playing a MMORPG like World of Warcraft sometime - it's amazing
how compact English can be written using "u" for "you", "r" for "are"
etc.)
You cannot legislate morality. (You _can_, however, legislate immorality!)
It's legislating readability and understanding among developers. A
language that invites a million different ways of doing things takes
the disease of unmanageability with it. I want to learn a language,
not a language plus the particular habits of ten developers who worked
on code before me. Even C++ dev houses decide upon a limited set of
ways to do things.
Write an Any or Variant class in Java.
Are any of those used in other ways than Object is in Java? "A Rose by
any other name" etc. You could probably make something using
Proxy/InvocationHandl er and a Map to hold values.
You have insufficient experience with block closures.
No, I have used Smalltalk. Don't pretends something doesn't exist just
because the syntax is different. It's the same way you can implement
multiple inheritance of implementation in Java using nested classes:
People just don't "see" it because the syntax would be too different
from C++.
A GUI should be event-driven.
Java's are, whether AWT or Swing. Haven't programmed SWT but I guess
they use it as well.
Block closures make those as easy as falling off a log.
No, they just invite a terser syntax than Java's. Again, a book
doesn't become better from being shorter.
Most of the code you write in a static-typing OO language, for a
GUI, is excess plumbing to route events to handlers, and then excess
plumbing to convey state variables into handlers.
Correct - in a way. Except it's not "excess" but a consequence of
language design.
Block closures simply turn that problem inside out. The language
does the plumbing, and all you need to do is add the custom
behaviors.


But you lose Java's event system's listeners' access to the listeners'
code, unless the closure delegates to code in the listeners, in which
case your closure has just taken on the role of AWT and Swing's event
dispatchers.

It seems you are against static typing (with its compile-time checking
and implicit documentation of argument values and return types)
because you are willing to take the risk of catching type errors only
at runtime in order to get the terser syntax of dynamic type
languages. The question is whether it's the programmer's needs or the
customer's needs that are at the forefront in software engineering...
May 7 '06 #431
Chris Smith <cd*****@twu.ne t> writes:
Oracle, for example, provides both a pure Java driver and a driver
that uses JNI, but I don't know of anyone using the latter.


That's because the JNI driver requires Oracle client software to be
installed on the computer, and java.library.pa th to point to its
libraries (either explicitly or implicitly). Too much hassle when the
"thin" driver works fast enough.

(I guess the OP can argue that at some point pure Java JDBC drivers
need to use a Socket, and then you delegate to the native
implementation of that - but that would be being argumentative for the
sake of it.)
May 7 '06 #432
"peter koch" <pe************ ***@gmail.com> writes:
Java has two adressing modes - one for the ints and one for the
objects. And this approach is simple but with drawbacks.


No, the modes are the same: Values are put on the stack. The
difference is that an object "value" (the pointer) can be further used
to get values from that object - ints cannot.

If you insist the addressing modes are different, feel free to
demonstrate.
May 7 '06 #433
bc*@pvv.ntnu.no (Bent C Dalager) writes:
The day we have a programming language that is so good a monkey could
produce quality software with it is the day we have won.


No, then we get replaced by monkeys, and have to drive taxkis to make
a living. Unless cars get so automated monkeys can drive them, too.
May 7 '06 #434
Im sometimes amazed at how many people seem to know.
mostly its the "CV" effect.
People put gazillions of languages in their CVs to make it look
impressive.
it turns out the "Assembler" experience is the 3day homework they did
in college some years ago... PHP and SQL Experience come from the
private homepage they copy pasted to sho off their "world".
Java is mostly Java script that was ripped off some site to put a cool
menu to the homepage...
i mean i think the sentence:
"Most of the messages in this thread appear to be written by people who
only know one programming language."
is meant like:
you know this language well and have worked full time with it in a
professional environment for some years.
gosh, i do work like that with C++ and can definitely understand and
code C if i have to without problems... but i would not say i "know" C.
i could not design a bigger system from scratch taking full advantage of C.

I could also write a good dozen of languages i've worked with in the
last years... but im only proficient with 3 or 4 of them.
Guys stay in the ground.

I also think every language has its strenghts and weaknesses.
True knowlegde of the language means also knowing which language suits
best fo the desired task.
There is no better or worse.
Alone discussing about that show a lot of your knowledge and so i say:

WillemF wrote:
"Most of the messages in this thread appear to be written by people who
only know one programming language."

FULL ACK!!!
May 7 '06 #435
Oliver Wong wrote:
"Noah Roberts" <ro**********@g mail.com> wrote

Java references are pointers without the benifits of being pointers and
without an explicit notation to label them as such to reduce confusion.


I actually laughed out loud when I read the above. That's very rare
for me. The punchline, that making Java more like C++ would *reduce*
confusion, was very unexpected.

Why would you need explicit notation to differentiate between Foo and
Bar if a given environment has only Foos and no Bars?


Because it has Bars and just hides them, so that the user (programmer)
does not see them. But it would be (imo) better to clearly differentiate
between both.

Raymond
May 7 '06 #436
Raymond Haeb wrote:
Oliver Wong wrote:
"Noah Roberts" <ro**********@g mail.com> wrote

Java references are pointers without the benifits of being pointers and
without an explicit notation to label them as such to reduce confusion.


I actually laughed out loud when I read the above. That's very rare
for me. The punchline, that making Java more like C++ would *reduce*
confusion, was very unexpected.

Why would you need explicit notation to differentiate between Foo
and Bar if a given environment has only Foos and no Bars?


Because it has Bars and just hides them, so that the user (programmer)
does not see them. But it would be (imo) better to clearly differentiate
between both.

Raymond


no - it just has foos.

'there is no spoon'

May 7 '06 #437
Raymond Haeb <ra******@gmx.d e> wrote:
Because it has Bars and just hides them, so that the user (programmer)
does not see them. But it would be (imo) better to clearly differentiate
between both.


No, it doesn't have both. This is why it's important to really learn a
language and understand it before pretending to know it. You can
understand Java in C++ terms, if you like, but you will see a very
complicated language. Heck, you could insist on understanding LISP in
C++ terms, if you so desire. The resulting complexity is not a
necessary consequence of the language; it exists because you've picked
the wrong mental model to understand the language.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
May 7 '06 #438
Chris Smith wrote:
Raymond Haeb <ra******@gmx.d e> wrote:
Because it has Bars and just hides them, so that the user (programmer)
does not see them. But it would be (imo) better to clearly differentiate
between both.


No, it doesn't have both. This is why it's important to really learn a
language and understand it before pretending to know it. You can
understand Java in C++ terms, if you like, but you will see a very
complicated language. Heck, you could insist on understanding LISP in
C++ terms, if you so desire. The resulting complexity is not a
necessary consequence of the language; it exists because you've picked
the wrong mental model to understand the language.


oh come on now - my 'there is no spoon' is much funnier!
May 7 '06 #439
Ed Jensen wrote:
In comp.lang.c++ Noah Roberts <ro**********@g mail.com> wrote:
void foo(const I & i);

That function accepts a reference to an I object that cannot be changed
by foo without purposfully breaking the language's protections through
a const_cast. Callers can rely on the fact that i is not changed as
that definition is a statement to that effect.


Translation: The const "guarantee" can trivially be broken by casting
away const; thus, it's no real guarantee at all.


No: const_cast only removes the const. Trying to modify the object
will result in UB.

Raymond
May 7 '06 #440

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
9870
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
10940
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
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...
1
7854
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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...
1
4499
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

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.