473,889 Members | 1,367 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

"Luc The Perverse" <sl************ ***********@cc. usu.edu> wrote in message
news:s6******** ****@loki.cmear s.id.au...
"Remon van Vliet" <re***@exmachin a.nl> wrote in message
news:44******** *************** @news.xs4all.nl ...

"Chris Smith" <cd*****@twu.ne t> wrote in message
news:MP******** *************** *@news.astraweb .com...
Remon van Vliet <re***@exmachin a.nl> wrote:
It can be, but with Java2D API you have access to hardware accelerated
graphical features that should be on par with Flash performance. In my
opinion everything that can be done in Flash can be done in Java.
However,
Flash is way more efficient from a time to market point of view, it's
just a
bit easier (and dare i say it better) for web based content.

The problem is not with the performance of the graphics hardware. The
limiting factor is the initialization of the virtual machine.
Undoubtedly, if things got anywhere near the point of maxing out the
graphics card, an applet would greatly outperform Flash.


I know, but it's two different things, initialisation isnt in the way of
performance and vice versa. That said, i can see how VM initialisation is
a limiting factor. Having to wait 5+ seconds kind of shoots applets down
as a good option for dynamic web content.


I wonder if running the JVM as a process would eliminate this delay, or at
least greatly reduce it


I think it sort of is after the first invocation. I cant say for sure
though.
May 1 '06 #261

"Oliver Wong" <ow***@castorte ch.com> wrote in message
news:y_s5g.17$W 6.8@edtnps89...

"Remon van Vliet" <re***@exmachin a.nl> wrote in message
news:44******** *************** @news.xs4all.nl ...

"Timo Stamm" <ti********@arc or.de> wrote in message
news:44******** *************** @newsread4.arco r-online.net...
Remon van Vliet schrieb:

I think it's fair to say that on average Java initialises a bit slower
than Flash (not surprising considering the implementation differences).

That's my experience on a lot of different systems and with a lot of
flash movies. I am surprised that Oliver has a different experience and
I'd like to know the reason. I have quite a few customers who would not
accept a delay of five seconds.
Well it's worth noting that the VM initialisation is what's causing the
delay, and that only happens once. Actually loading and starting the
Applet (at least on my system) is a matter of a second or slight more.


I was a bit surprised at the 5 second figure I arrived at as well. This
was done basically by holding my wrist watch up to the screen, and taking
the "start time" to be when I saw the HTML rendered, and the "end time" to
be once I saw the applet/flash actually running. My watch only has 1
second precision, and my reaction time as a human may have been a factor,
but I think I was accurate to within, say, 0.7 of a second.

AFAIK, I didn't have load any applets during that instance of FireFox.
I had Eclipse and jEdit running in the background, but I'd be surprised if
Firefox could somehow "share" the VM with them.


Hm, maybe FireFox starts the VM on startup? I have no idea..


Graphics performance is probably slightly in favour of Flash although
Java2D uses hardware acceleration as well. In terms of raw computing
> power i suspect Java will blow Flash out of the water as i'm boldly
> assuming the "VM" of Flash is not nearly as capable as an average JIT
> JVM. I must stress that's an assumption rather than fact though.

Flash graphics performance is not very good. I have never made any
tests, but I guess that Applets are better. Flash graphics performance
on the mac is very bad, even though they improved it with version 8 of
the player.


Oh yes? That surprises me, i've always assumed Flash to be faster if
you're going for the same graphical quality, especially where
antialiasing is involved. Interesting stuff..


I also assumed Flash would be faster for the graphics stuff. Flash has
a 3D API too, doesn't it?


So does Java though...sort of (Java3D)
May 1 '06 #262
Oliver Wong schrieb:

"Remon van Vliet" <re***@exmachin a.nl> wrote in message
news:44******** *************** @news.xs4all.nl ...

"Timo Stamm" <ti********@arc or.de> wrote in message
news:44******** *************** @newsread4.arco r-online.net...
Remon van Vliet schrieb:
Graphics performance is probably slightly in favour of Flash
although Java2D uses hardware acceleration as well. In terms of raw
computing
> power i suspect Java will blow Flash out of the water as i'm boldly
> assuming the "VM" of Flash is not nearly as capable as an average JIT
> JVM. I must stress that's an assumption rather than fact though.

Flash graphics performance is not very good. I have never made any
tests, but I guess that Applets are better. Flash graphics
performance on the mac is very bad, even though they improved it with
version 8 of the player.


Oh yes? That surprises me, i've always assumed Flash to be faster if
you're going for the same graphical quality, especially where
antialiasing is involved. Interesting stuff..


I also assumed Flash would be faster for the graphics stuff. Flash
has a 3D API too, doesn't it?


No, there is no 3D API :(

Antialising is a good point. I am not sure whether Applets can compete
at that.

But overall graphics performance is not as good as one might think from
seeing flash movies on the web. They mostly run at 12 FPS (default
setting) instead of 25-50 (what I would choose in an Applet).
Timo
May 1 '06 #263

Remon van Vliet wrote:
*SNIP*
That comparison is quite a stretch. GC is, as far as I know and as far
as Java implements it, totally unaccessable to the programmer. Can you
force the GC to delete anything? There may be certain times when you
can expect the GC to do some cleanup but you cannot guarantee it nor
can you control it. On the other hand, refrence counting using smart
pointers is 100% programmer controlled. You _can_ force something to
get deleted and you know for certain that the object will get deleted
the instant the last reference to it leaves scope or is destroyed.
This is a totally dependable action that is 100% guaranteed. With the
GC you can have no references to an object but it hangs out until who
knows when and then gets destroyed sometime after the last reference to
it leaves scope or is destroyed..../sometime/ after.


Which is a problem because? You dont have to point out continuously that the
GC doesnt allow exact control over cleaning up discarded objects. We all
know that and consider that a good thing. What'd be more interesting is to
finally hear a valid reason why it's actually a problem rather than an
advantage.

Does that mean it works if the programmer doesn't work? No. But it
means that RAII _can_ be depended on to perform the actions it has been
described so long as the programmer does their job. Requiring correct
code is not unreasonable and in reality RAII is quite effective at
keeping a lot of bugs out of code so long as it is followed.


Why are you so stuck on wanting control over these kind of things? Are you
under the impression you do a better job at manually alloc/deallocing memory
and cleaning up objects than the latest generation Java GC will do? I'm
getting a bit tired of all these unsupported assumptions. Either come with
practical examples/facts or just agree to disagree.


You are comming in rather late and/or don't have the knowledge to
understand what I am talking about.

Look up what RAII is and what it is used for, or read this thread where
it is spoken of quite a bit.

Then you will understand what I am talking about above.

May 1 '06 #264

Remon van Vliet wrote:
I'll take your word for it, but his argument was that having exact control
over memory usage is somehow an advantage.


Actually, my argument is pretty clearly that knowing exactly when an
object is destroyed is somehow an advantage. Direct control over when
it occurs or not, knowing when and being able to guarantee that
behavior is very adventageous.

May 1 '06 #265
"Remon van Vliet" <re***@exmachin a.nl> wrote in message
news:44******** *************** @news.xs4all.nl ...

"Luc The Perverse" <sl************ ***********@cc. usu.edu> wrote in message
news:s6******** ****@loki.cmear s.id.au...
"Remon van Vliet" <re***@exmachin a.nl> wrote in message
news:44******** *************** @news.xs4all.nl ...

"Chris Smith" <cd*****@twu.ne t> wrote in message
news:MP******** *************** *@news.astraweb .com...
Remon van Vliet <re***@exmachin a.nl> wrote:
> It can be, but with Java2D API you have access to hardware accelerated
> graphical features that should be on par with Flash performance. In my
> opinion everything that can be done in Flash can be done in Java.
> However,
> Flash is way more efficient from a time to market point of view, it's
> just a
> bit easier (and dare i say it better) for web based content.

The problem is not with the performance of the graphics hardware. The
limiting factor is the initialization of the virtual machine.
Undoubtedly, if things got anywhere near the point of maxing out the
graphics card, an applet would greatly outperform Flash.
I know, but it's two different things, initialisation isnt in the way of
performance and vice versa. That said, i can see how VM initialisation
is a limiting factor. Having to wait 5+ seconds kind of shoots applets
down as a good option for dynamic web content.


I wonder if running the JVM as a process would eliminate this delay, or
at least greatly reduce it


I think it sort of is after the first invocation. I cant say for sure
though.


Typically I am opposed to background services running - but if I could make
Java programs initial startup cost go away, I could sacrifice a few MB.

Does anyone know for sure? (To be honest, java programs interest me more
than applets.)

--
LTP

:)
May 1 '06 #266
Noah Roberts wrote:
Look up what RAII is and what it is used for, or read this thread where
it is spoken of quite a bit.


Or read the huge multi-thread conversation regarding GC, deterministic
destruction, and the general proposal to add a 'finally' keyword to C++
that ran for the last 2 months at news:comp.lang. c++.moderated .

"There's enough material there for an entire conference" --Fawlty Towers

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
May 1 '06 #267
In comp.lang.java. advocacy, Oliver Wong
<ow***@castorte ch.com>
wrote
on Mon, 01 May 2006 17:16:27 GMT
<Lnr5g.9$W6.1@e dtnps89>:

"Timo Stamm" <ti********@arc or.de> wrote in message
news:44******** **************@ newsread2.arcor-online.net...
Oliver Wong schrieb:

FWIW, in my experience, Flash is not "much quicker".
Thanks for sharing your experience.

But do you really mean that Flashs /initialization/ is not generally much
faster for you than Applets? Or were you thinking of rendering and
computing performance?

Right now on my Powerbook with Safari, it takes 11 seconds until the
following very simple applet showed it's input elements:
http://java.sun.com/applets/jdk/1.4/.../example1.html

The following Flash movie shows instantly, without any measurable delay:
http://www.contourdesign.com/rollerm...ouse_flash.htm

Windows XP with SP2, Pentium 4 1.8Ghz, 1024MB RAM, Firefox 1.5.0.2.

Java took 3 seconds, Flash took 5 seconds.


I think part of the problem may be the loading of the
jar files for the applet. Java initialization, after
all, is not perceptible in the browser proper, though
the 1.5 version does show a "load in progress" screen,
which is an improvement over a mostly blank gray screen
in earlier versions.

Does your figure include the jar file loading?

In any event, ArcTest might have taken for me 4 seconds to bring up
something, and 1 more second to show an arc.

The RollerMouse demo took 6 seconds to come up and maybe 2-3 seconds to
load.

I'm thinking Internet time variance, or maybe server issues.

- Oliver

--
#191, ew****@earthlin k.net
Windows Vista. Because it's time to refresh your hardware. Trust us.
May 1 '06 #268

"Noah Roberts" <ro**********@g mail.com> wrote in message
news:11******** **************@ g10g2000cwb.goo glegroups.com.. .

Remon van Vliet wrote:
I'll take your word for it, but his argument was that having exact
control
over memory usage is somehow an advantage.


Actually, my argument is pretty clearly that knowing exactly when an
object is destroyed is somehow an advantage. Direct control over when
it occurs or not, knowing when and being able to guarantee that
behavior is very adventageous.


Because?
May 1 '06 #269

"Noah Roberts" <ro**********@g mail.com> wrote in message
news:11******** **************@ u72g2000cwu.goo glegroups.com.. .

Remon van Vliet wrote:
*SNIP*
> That comparison is quite a stretch. GC is, as far as I know and as far
> as Java implements it, totally unaccessable to the programmer. Can you
> force the GC to delete anything? There may be certain times when you
> can expect the GC to do some cleanup but you cannot guarantee it nor
> can you control it. On the other hand, refrence counting using smart
> pointers is 100% programmer controlled. You _can_ force something to
> get deleted and you know for certain that the object will get deleted
> the instant the last reference to it leaves scope or is destroyed.
> This is a totally dependable action that is 100% guaranteed. With the
> GC you can have no references to an object but it hangs out until who
> knows when and then gets destroyed sometime after the last reference to
> it leaves scope or is destroyed..../sometime/ after.


Which is a problem because? You dont have to point out continuously that
the
GC doesnt allow exact control over cleaning up discarded objects. We all
know that and consider that a good thing. What'd be more interesting is
to
finally hear a valid reason why it's actually a problem rather than an
advantage.
>
> Does that mean it works if the programmer doesn't work? No. But it
> means that RAII _can_ be depended on to perform the actions it has been
> described so long as the programmer does their job. Requiring correct
> code is not unreasonable and in reality RAII is quite effective at
> keeping a lot of bugs out of code so long as it is followed.


Why are you so stuck on wanting control over these kind of things? Are
you
under the impression you do a better job at manually alloc/deallocing
memory
and cleaning up objects than the latest generation Java GC will do? I'm
getting a bit tired of all these unsupported assumptions. Either come
with
practical examples/facts or just agree to disagree.


You are comming in rather late and/or don't have the knowledge to
understand what I am talking about.

Look up what RAII is and what it is used for, or read this thread where
it is spoken of quite a bit.

Then you will understand what I am talking about above.


I read the entire thread, i understand RAII perfectly. If you're stuck on
personal sneers rather than actually coming up with practical issues you
seem to have with Java i'm just gonna give up on you. All you do is run
around claiming control over X or Y is a good thing, without bothering to
explain why, or replying to posts that explain why it isnt a good thing.
May 1 '06 #270

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
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...
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
9603
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
7991
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
7148
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
6025
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.