C++, C# or Java.

J

John Swan

Which one is best?

Java is slow but can be ran on every machine.
C# kicks the crap out of MFC but can only be run on M$ platforms.
C++ is class :) but is harder work so ultimately makes you better.

If someone wanted to learn an oop based language which one would you
choose????
 
Z

zero

Which one is best?

Java is slow but can be ran on every machine.
C# kicks the crap out of MFC but can only be run on M$ platforms.
C++ is class :) but is harder work so ultimately makes you better.

If someone wanted to learn an oop based language which one would you
choose????

The answer to this question is very subjective. But here is my view, as
someone who's used all three languages:

If it's the first OO language you're learning, I'd go with Java. Java
forces you to use classes and objects, while most C++ learning books cover
OO only after extensively going through structured programming techniques,
with the result that the student is more likely to write long methods
instead of finding a good OO Design.

Once you know your way around Java, you can tackle C++. It may look
confusing at first because of the memory management, but it shouldn't be
too much of a problem. First knowing Java will give you the advantage that
the control structures will look familiar, and more importantly that you
will be more comfortable using classes.

When you know Java and C++, C# kinda comes naturally. All you have to do
is learn the C# libraries. Yes I'm simplifying here, but it really will be
easy after Java and C++. Personally I think C# is only useful for web
applications (ASP.NET), for the rest you're better off with Java or C++.

For web applications there's also J#, which is even easier than C# if you
already know Java. Just as long as you stay away from VB.NET. Actually
you shouldn't ignore VB completely, a lot of companies ask that you know
it. I just hate it.

Again, let me say that these are my personal opinions, from my personal
experience. You would do good to ask around, read articles comparing the
languages, and above all: stay critical and draw your own conclusions.

Zero
 
J

James Yong

John Swan said:
Which one is best?

Java is slow but can be ran on every machine.
C# kicks the crap out of MFC but can only be run on M$ platforms.
C++ is class :) but is harder work so ultimately makes you better.

If someone wanted to learn an oop based language which one would you
choose????

Hi,

I am guessing you are referring to desktop application since you mention
C++.
The choice of language depends which one you are comfortable with, although
you may need to consider whether they are easy to decompile or not.

For java, I don't consider it as slow. Have you try SWT instead of SWING.
SWT runs pretty fast. One thing good about java is that there is only one
version of the language.

No comments about C#. Hehe.

For C++, there are many frameworks that you can choose from to help you to
speed up the development work.
You can give Ulimate ++ framework a look, if you haven't. One thing is that
it isn't mainstream.

Regards,
James Yong
 
T

Thomas G. Marshall

zero coughed up:
The answer to this question is very subjective. But here is my view,
as someone who's used all three languages:

If it's the first OO language you're learning, I'd go with Java.
Yes!


Java
forces you to use classes and objects,

And keeps you clear of many horrid notions that only impede learning, (such
as MI, operator overloading, pointer arithmetic, and doing your own garbage
collection.)

while most C++ learning books
cover OO only after extensively going through structured programming
techniques, with the result that the student is more likely to write
long methods instead of finding a good OO Design.

Once you know your way around Java, you can tackle C++. It may look
confusing at first because of the memory management, but it shouldn't
be too much of a problem.

It's likely to be a big problem.

First knowing Java will give you the
advantage that the control structures will look familiar, and more
importantly that you will be more comfortable using classes.

When you know Java and C++, C# kinda comes naturally.

Wrong order IMO.

Java -> C# -> C++ is a better progression. C# seems to be either C++ with
sanity, or Java with slight insanity, IMO.

....[rip]...


--
Puzzle: You are given a deck of cards all face down
except for 10 cards mixed in which are face up.
If you are in a pitch black room, how do you divide
the deck into two piles (may be uneven) that each
contain the same number of face-up cards?
Answer (rot13): Sebz naljurer va gur qrpx, qrny bhg
gra pneqf naq syvc gurz bire.
 
T

Thomas G. Marshall

John Swan coughed up:
Which one is best?

Quick notes:
Java is slow but can be ran on every machine.

Not so slow according to the theorists. I have to say though that in
practice, even when coding properly, it is a tad slow. Much of the "even
faster than C++ in some cases" crap is a lot of theoretical hype with little
real-world support, IMO. *However*, that being said, java is almost
certainly fast enough for nearly everything you can imagine. /Nearly/.

C# kicks the crap out of MFC but can only be run on M$ platforms.

This statement is a little like saying that my car kicks the crap out of my
neighbor's tires. MFC is a gui subsystem/library, and like java such GUI
support is only a part of C#.

C++ is class :)

"class". Becareful using that word in OO circles. Did you mean "course"?

but is harder work so ultimately makes you better.

This is actually very true. This depends upon your current position in your
engineering learning. However, for reasons explained elsethread, I believe
that C++ will very much hamper your learning of OO itself.

I do have to say, by the way, that if you really want to learn OO and
nothing but OO and be an OO purist who lives breathes eats and craps out OO
then you really would not want any of these three. Suitable suggestions
abound, and you could ask this on comp.object, or just google search in that
newsgroup alone.



If someone wanted to learn an oop based language which one would you
choose????



--
Puzzle: You are given a deck of cards all face down
except for 10 cards mixed in which are face up.
If you are in a pitch black room, how do you divide
the deck into two piles (may be uneven) that each
contain the same number of face-up cards?
Answer (rot13): Sebz naljurer va gur qrpx, qrny bhg
gra pneqf naq syvc gurz bire.
 
E

Eric Jacoboni

John Swan said:
Java is slow but can be ran on every machine.

Java is not slow per se, but some programmers write slow code. Of
course, Java will be slower than C (but is it really a problem ?).
C# kicks the crap out of MFC but can only be run on M$ platforms.

Nope... See Mono project (http://www.mono-project.com/). In fact, you
may learn C# on your favorite platform... if you want to do so.
 
D

Dimitri Maziuk

John Swan sez:
Which one is best?

Java is slow but can be ran on every machine.
C# kicks the crap out of MFC but can only be run on M$ platforms.
C++ is class :) but is harder work so ultimately makes you better.

If someone wanted to learn an oop based language which one would you
choose????

Depends on what you already know. E.g. if you're doing systems
programming major with a healthy doze of (OO) software engineering
thrown in, start with C++. For programming languages major I'd
recommend Smalltalk, and if you just want to tech yourself an OO
language "in 21 days", start with Java.

Dima
 
T

Thomas G. Marshall

Eric Jacoboni coughed up:
Java is not slow per se, but some programmers write slow code.

Very common mantra from nearly every java pundit except me. I very much
like java, and will likely be a proponent of it for a very long time, but in
real life, it is "slow" when compared to anything else native. Everything
else I've seen to the contrary in my time with java (since pre 1.0--beta)
has been theoretical wishful thinking. And I'm not talking about newbie
coding here either. Very careful consideration has been given to speed
concerns in my past, and the consensus is still that the JVM just cannot
come close to a "real" cpu.

Please understand, this does not amount to any real negative criticism: For
java to do what it does more than makes up for its [lack of] speed, and
quite frankly I've always been amazed at just how fast it is. But don't let
anyone kid you: If you are used to C or C++ coding, you will notice a
decrease in speed.

Now saying this often causes very emotional kneejerk reactions.

....[rip]...
 
C

Chris Smith

Thomas said:
Very common mantra from nearly every java pundit except me. I very much
like java, and will likely be a proponent of it for a very long time, but in
real life, it is "slow" when compared to anything else native.

I agree with you. Now, I don't consider myself a Java "pundit", so I
don't know if that disproves your statement or not. I do use Java a
lot. Nevertheless, it makes sense from the standpoint of objective
decision-making to admit that Java is mostly slower than native code.

I don't think I'd go so far as you, though. I don't agree that:
the consensus is still that the JVM just cannot
come close to a "real" cpu.

Java certainly can come close to a real CPU. I find it to be comparable
in micro-benchmarking, and within 20% in real-world application testing,
of the performance of applications compiled straight to machine code.
Of course, these are generalizations, but they describe my experience,
and I think it meets the definition of "close" fairly well.

There seem to be four factors that account for the "slow" reputation, in
no particular order:

1. Poor programmers
2. Garbage collection
3. Memory/locality issues
4. Pure object model

Poor programmers is a somewhat standard excuse, but one that holds some
merit. Java is definitely more accessible to the novice programmer than
C and C++ were; and as a result, there are plenty of examples of poor
code in Java. In general, though, evidence of poor code takes the form
of bad design and abstraction, as even poor programmers can write
reasonably well-performing code in 90% of situations. In fact, many
poor programmers are obsessed with it!

Garbage collection, of course, can theoretically be made faster than
explicit memory management when given enough memory, as Andrew Appel is
famous for having argued. I believe it's important to realize that GC
opens up new ways of managing a heap that have their own unique
advantages performance-wise over an explicitly managed heap.
Nevertheless, in practice, garbage collection is generally slower except
in certain specialized algorithms that can exploit it efficiently.
Java's being fundamentally based on garbage collection has many benefits
for safety, ease-of-development, and security... but it objectively must
be admitted to be slower on average.

The most overlooked reason for Java's performance problems is the
difficulty of maintaining good cache and page locality. Because Java's
microbenchmark improvements have come at the cost of memory usage, Java
processes are often larger than native processes. They maintain two
copies of a lot of the code (native and bytecode), and they lack the use
of shared libraries so that memory becomes even more scarce when
multiple virtual machines are running. They also maintain a lot more
information at runtime than a typical C or C++ application, for the
purpose of providing powerful features like OO dynamic linking/loading
and reflection. The result is a higher likelihood of paging and of
cache misses, both of which slow things down. This is largely a direct
cost of the bytecode format. It also accounts for much of the curious
fact that simple benchmarks often show Java at comparable performance
with native code, but real-world (larger) applications fail to
demonstrate such similar performance.

The pure object model (by which I mean that all objects own their
identity and therefore do not have a lifetime tied to local scope) is
perhaps a bigger concern. It exacerbates both the garbage collection
impact (because garbage collection runs more often) and the locality
impact (because data is not stored as compactly or contiguously in
memory) as described above.
Now saying this often causes very emotional kneejerk reactions.

Yes, it does. Loyalty is a natural human emotion, whether it's
appropriate or not.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
E

Eric Jacoboni

"Thomas G. Marshall"
Very common mantra from nearly every java pundit except me.

Yes, as i said in the second sentence, Java is not as fast as C. But
i've often see slow Java programs simply because they are poorly
coded... In some case, changing String in StringBuilder makes a Java
program 10x faster.
But don't let anyone kid you: If you are used to C or C++ coding,
you will notice a decrease in speed.

Anyone will be agree with that as long as "speed" means "program
execution speed". I will not repeat here some basic software
engineering principles about design/maintainability/debug speeds.

But, for sure, if you need to write a number crunching program, Java
is not the perfect candidate... BTW, in this case, i'm not sure OO is
a perfect paradigm for this kind of job, either.
 
R

Roedy Green

Java is slow but can be ran on every machine.
C# kicks the crap out of MFC but can only be run on M$ platforms.
C++ is class :) but is harder work so ultimately makes you better.

If someone wanted to learn an oop based language which one would you
choose????

People usually choose what they are familiar with. They are obviously
most productive and write the fewest bugs if they are not newbies in
the language. This leads to language chauvinism.

You also have to consider the availability of talent to assist you and
maintain the code after you are gone, (a strike against Smalltalk or
Eiffel for example).

Since you are asking in a Java newsgroup, you should expect to get
reasons for choosing Java.

Java is scalable. If you out grow your server, your same code will
work on hundreds of much larger machines. If you outgrow your womb,
there are higher performance alternatives.

On the other end you can strip down your app to run in a cellphone.
Everything works in the same language with the same development team.

As a pure language, C# has a lot of appeal. The big problem is you
have to trust Microsoft not to screw you some time in the future.
Given their track record, it seems likely they will eventually.
 
R

Roedy Green

but in
real life, it is "slow" when compared to anything else native.

Java the language is not slow. For example the lack of pointers, and
the lack of unions make for more optimisable code. What you mean is
the Sun's JIT is slower to start that an native app and Swing is
slower than a native platform-specific GUI.

Compare natively compiled Java against natively compiled C++.
See http://mindprod.com/jgloss/nativecompiler.html

Compare Swing against something like C++ Rogue wave platform
independent GUI.
 
O

Oliver Wong

Thomas G. Marshall said:
For java to do what it does more than makes up for its [lack of] speed,
and quite frankly I've always been amazed at just how fast it is.

People often don't realize how much Java is actually doing behind the
scenes.

When someone points at Java application Foo and says that they can write
a faster version of it in [said person's language of choice], I ask them:

* Will your program run on Windows, Max, Gnome and KDE using the
platform specific look and feel?
* If I'm visually impaired, and I decide globally increase font size at
the OS level, do you have a layout manager that makes sure the widgets are
still placed appropriately on the form?
* If I'm completely blind, does your code associate labels with their
controls (e.g. textfields) so that when I mouse over the textfields, the
screenreader knows which label to read to me?
* Does your code detect the locale and if it's one where text should be
displayed right to left instead of left to right (e.g. many Asian locales),
do you lay out your widgets accordingly?
* Does your code detect the locale and display dates, decimals and
financial data formatted accordingly? Does your app support the Buddhist
calendar? The Chinese one? Ethiopic? Hebrew?
* Does your code handle Unicode?
* If you have code that converts char to int, it's trivial to convert
'9' to 9, but does character convert \u2167 (this is the roman character
'VIII') to 8? What about \u4E00 (the Chinese/Japanese character for 1) to 1?
* Since your program is non-trivial, it therefore contains bugs. When
such a bug is encoutered, does your application emit a stack trace and exits
cleanly, or does it drop a "core dump"?
* If a stack trace is not desired, is it trivial in your language to, at
a top level, catch all exceptional situations and display a message to the
user indicating that some internal error occured, with information on how to
get technical support?

In empirical benchmarks I've run, using BigInteger instead of int or
long makes by code about 7 times slower. For applications which are not
performance-critical (e.g. where responce times of 7 milliseconds instead of
1 millisecond is okay), I'll typically use BigInteger liberally, just 'cause
I don't want to place arbitrary limits on my users. With Strings,
arbitrary-length support is automatic in Java.

* Does your code handle strings in excess of 500'000'000 characters?
* Does your handle numerics (integer in the mathematical sense, or
rational numbers) in excess of 300 decimal digits?

There are probably a lot of other niceties that Java (both the language
and the platform) does which often go unappreciated which might contribute
to the slow down. These are just some things I thought of off the top of my
head.

- Oliver
 
R

Roedy Green

* If I'm completely blind, does your code associate labels with their
controls (e.g. textfields) so that when I mouse over the textfields, the
screenreader knows which label to read to me?

that is one thing Java does not do. I did an experimental layout when
labels were made attributes of data components and a special layout
manager placed the labels.

It is true though that Java components can have invisible names.
 
O

Oliver Wong

Roedy Green said:
that is one thing Java does not do. I did an experimental layout when
labels were made attributes of data components and a special layout
manager placed the labels.

It is true though that Java components can have invisible names.

When I wrote that, I was thinking in particular of the labelFor() method
on JLabels, which I vaguely recall being there for the benefit of
screenreaders, though I can't find documentation supporting that belief
right now.

- Oliver
 
O

Oliver Wong

Roedy Green said:
Java strings and arrays are limited to 2^31-1 chars. 2,147,483,647
2 gig.

I think 2 gigs also happens to be a limit on the amount of RAM that can
be access by most 32 bit architectures, so we could say at that point, it
becomes a "hardware" issue rather than a "Can your language do this?" issue.

- Oliver
 
O

Oliver Wong

Oliver Wong said:
When I wrote that, I was thinking in particular of the labelFor()
method on JLabels, which I vaguely recall being there for the benefit of
screenreaders, though I can't find documentation supporting that belief
right now.

I've found it now:

http://a11y.netbeans.org/focusableLabels.html

"The problem is that in many dialog boxes, important text is stored in
JLabel components or disabled JTextAreas. Screen readers cannot read text
that is not in focusable components.

JLabels are not focusable unless they are connected (using labelFor) with
another component (such as a JComboBox)."

http://ewic.bcs.org/conferences/2005/accessible/session5/paper1.pdf

"When using Swing’s JLabel class to provide a label for a component, call
JLabel’s setLabelFor() method to associate the component with its label. If
both the displayedMnemonic and labelFor properties of a Swing component are
set, the component’s label calls the requestFocus() method of the component
specified by the labelFor property when the appropriate mnemonic is
activated."

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top