By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,556 Members | 1,100 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,556 IT Pros & Developers. It's quick & easy.

Java better than C++

10K+
P: 13,264
OK shoot me, but with the latest additions to java most of the claimed advantages of C++ over java have disappeared and I now wait to get one clear non-arguable advantage of C++ over Java for the software developer.
Oct 4 '06 #1
Share this Question
Share on Google+
28 Replies


ronverdonk
Expert 2.5K+
P: 4,258
See also my entry in this forum's thread Best programming language.

This dicussion is the same as: why is Ford better then GM?
People tend to stick to what they have learned and have coming to like. And if you learned all in's and out's of C++, you usually stick with it until you need something that isn't posisble in C++, only then you will look for a better language. Or maybe curiosity. But usually not on objective, measureable, grounds.

So your statement may be true for you, it maybe not for someone else.

Ronald :cool:
Oct 5 '06 #2

10K+
P: 13,264
See also my entry in this forum's thread Best programming language.

This dicussion is the same as: why is Ford better then GM?
People tend to stick to what they have learned and have coming to like. And if you learned all in's and out's of C++, you usually stick with it until you need something that isn't posisble in C++, only then you will look for a better language. Or maybe curiosity. But usually not on objective, measureable, grounds.

So your statement may be true for you, it maybe not for someone else.

Ronald :cool:
While it is generally true that one prefers what one already knows, for true comparisons this should not be an issue. Just because I've spent more time coding in c than I have in Java should not be something I use to compare the two languages.
Instead we should look at
garbage collection effort, platform dependance, speed, areas of application, paradigm support etc.
It does not matter how many times I have written a destructor in c++, the Java gc is much better for me the programmer and similar arguments...
Oct 5 '06 #3

P: 11
Although Java is more portable across environments, if I had to write some quick and dirty and small program to update something on someones system, it would be in C++.

The only thing that scares me about Java is the reliance on the RTE and library stuff. I also have more of a feeling of what is happening with C++ and what will be slow or fast.

Other than that, I think Java should be encouraged so that it can be ported strait to Linux or vise versa.

Hmm, I Suppose that I really should take another look at it.
Oct 17 '06 #4

10K+
P: 13,264
Although Java is more portable across environments, if I had to write some quick and dirty and small program to update something on someones system, it would be in C++.

The only thing that scares me about Java is the reliance on the RTE and library stuff. I also have more of a feeling of what is happening with C++ and what will be slow or fast.

Other than that, I think Java should be encouraged so that it can be ported strait to Linux or vise versa.

Hmm, I Suppose that I really should take another look at it.
Certainly when correct programming is done,
c++ will be faster than java and c++ will
get you closer to the memory.
My argument is these days speed of a programming laguage
is no longer an issue and getting better
control of memory is also not neccessary
owing to the increasing speed of processors
Oct 17 '06 #5

Banfa
Expert Mod 5K+
P: 8,916
My argument is these days speed of a programming laguage
is no longer an issue and getting better
control of memory is also not neccessary
owing to the increasing speed of processors
Then that must be the platform you work on. When you have a ~200MHz processor and you are trying to stream several megabits/second of data through it then speed of your language and the efficiency with which the compiler converts it to efficent machine code are still big considerations.

And on GC in a embedded application when memory is normally an extremely tight resource then a GC just does not provide enough control of memory allocation/deallocation.

Don't get me wrong, Java is good at what it does and has lots of plus points. It just is not suited to all platforms and to be honest would really expect any 1 language to ever achieve that?
Oct 23 '06 #6

10K+
P: 13,264
Then that must be the platform you work on. When you have a ~200MHz processor and you are trying to stream several megabits/second of data through it then speed of your language and the efficiency with which the compiler converts it to efficent machine code are still big considerations.

And on GC in a embedded application when memory is normally an extremely tight resource then a GC just does not provide enough control of memory allocation/deallocation.

Don't get me wrong, Java is good at what it does and has lots of plus points. It just is not suited to all platforms and to be honest would really expect any 1 language to ever achieve that?
You are right. How we all wish there was just one platform where everything runs on! But to be more honest, which language do you think suits more platforms than other languages?
Oct 24 '06 #7

bartonc
Expert 5K+
P: 6,596
You are right. How we all wish there was just one platform where everything runs on! But to be more honest, which language do you think suits more platforms than other languages?
Since wxWidgets got wrapped for Python, this language (often overlooked on this forum for some reason) now looks native on all platforms supported by wxWidgets. Has GC and is actually readable by a mere human.
Nov 17 '06 #8

drhowarddrfine
Expert 5K+
P: 7,435
which language do you think suits more platforms than other languages?
Assembly. As portable as C and runs anywhere, at least on the same processor. Syntax is pretty much the same no matter what assembler you use and there are few abstractions or ambiguities.
Nov 17 '06 #9

bartonc
Expert 5K+
P: 6,596
Assembly. As portable as C and runs anywhere, at least on the same processor. Syntax is pretty much the same no matter what assembler you use and there are few abstractions or ambiguities.
Yep. I began my illustrious (ha-ha) carrer writing in assembler (moto style) and still enjoy thinking like a compiler (as an intelectual challange). But seriously, abstaction is what good languages do well, is it not?
Nov 17 '06 #10

drhowarddrfine
Expert 5K+
P: 7,435
That's right and it can be helpful but it adds to the confusion. I started out in hardware so assembly was the only thing. Actually, coding in hex. I do the same as you. I visualize pointers in C as the actual register pointing at a memory address. When code starts 'dereferencing objects' I get a little crazy.
Nov 17 '06 #11

sashi
Expert 100+
P: 1,754
OK shoot me, but with the latest additions to java most of the claimed advantages of C++ over java have disappeared and I now wait to get one clear non-arguable advantage of C++ over Java for the software developer.
Hi everyone,

Java? C++? which one? I prefer to use C++ as it enables pointers, pointers can be very handy. Some of my friends even claim that Java is the mother of C++? Any review on that? Good luck & Take care.
Nov 19 '06 #12

drhowarddrfine
Expert 5K+
P: 7,435
Some of my friends even claim that Java is the mother of C++? Any review on that?
They may be talking about the OOP part of C++ but C is the mother of C++. Bjarne Stroustrup worked at Bell Labs with K&R and never worked at Sun.

In fact, Bjarne himself says Java inherited C++ features. Bjarne Stroustrup
Nov 19 '06 #13

ronverdonk
Expert 2.5K+
P: 4,258
That's right and it can be helpful but it adds to the confusion. I started out in hardware so assembly was the only thing. Actually, coding in hex. I do the same as you. I visualize pointers in C as the actual register pointing at a memory address. When code starts 'dereferencing objects' I get a little crazy.
Those we the days! I think C and embedded assembler is still the way to do it, best of both worlds. At least you have some feeling for the computer and its inner workings. OOP and Windows spoiled all that, it's like assembling Lego bricks now.

Ronald :cool:
Nov 19 '06 #14

MMcCarthy
Expert Mod 10K+
P: 14,534
Those we the days! I think C and embedded assembler is still the way to do it, best of both worlds. At least you have some feeling for the computer and its inner workings. OOP and Windows spoiled all that, it's like assembling Lego bricks now.

Ronald :cool:
Since I've never used either language commercially I won't comment on preformance of C++ vs. Java.

One point I would like to make is C is the first language I ever learned and I believe sometimes that all programmers should have to learn it as a rule. The basic understanding of C provides a progammer with an understanding of the rules of programming that is just not provided in my experience with instruction in C++ or Java.

I remember in college a student asked the Java lecturer if a method was like a function. To which she replied, there are no such things as functions in OO programming.

What do you think?

Mary
Nov 19 '06 #15

drhowarddrfine
Expert 5K+
P: 7,435
I think C and embedded assembler is still the way to do it
Ronald :cool:
Great minds think alike. I have no use for anything else.
Nov 20 '06 #16

10K+
P: 13,264
In fact, Bjarne himself says Java inherited C++ features
That's the point. Not only did it inherit C++ features, but lots of features from other languages.
Nov 28 '06 #17

Ganon11
Expert 2.5K+
P: 3,652
HTML beats all. O_o

Seriously, though, I think it's a matter of preference. I'm only a senior in High School, but I've already learned VB, Java, and C++. I've been learning C++ pretty extensively lately, so I'd say I'd be better at programming using C++. But I remember when learning Java that it seemed more user-friendly - closer to the english language, so concepts were easier to understand. But this is all a matter of preference. As someone already said, 'best' is a relative term. For example, if I were to try and tackle a project with several classes using inheritance, etc, I would use Java, since that makes a lot more sense to me (and I haven't run across unexplained problems in Java like I have in C++). If I were to try and tackle other types of problems, I might use C++, since it is generally faster on my computer and the material (syntax, etc) is still fresh in my head. But would I say any is better than another? No, I don't think I could say that.

But VB is lame. :P
Nov 28 '06 #18

Banfa
Expert Mod 5K+
P: 8,916
C is the mother of C++
More like an older sibling I'd say.

The latest versions of C have borrowed features from C++, if you look at the development paths of C and C++ you will find that you can just about find a point where they both inherited from the same predecessor but that development is then along separate branches with exchange of ideas happening in both directions between the 2 branches.

On the occasions when I have used Java I have tended to find it irritating, most recently the most irritating feature was the IDE I was using assuming that it needed to compile everything in the source tree despite some of the files being C++ files, but when I tried to remove those files from it's compile source tree it deleted them from the disk too, where as I wanted them on the disk I just didn't want it to compile them. Sort of "If I can't compile them then no-one can".

I really really really hate programs that think they are somehow more inteligent then me.
Nov 28 '06 #19

drhowarddrfine
Expert 5K+
P: 7,435
I really really really hate programs that think they are somehow more inteligent then me.
It's why I struggle so with high-level languages. This was years ago but I remember when three of us hardware engineers were told to start writing our code in C. You'd hear these yelps from the other rooms when guys would find pointers and data not winding up where they were supposed to and cries of "I don't have these problems when I write in assembly!"
Nov 28 '06 #20

10K+
P: 13,264
More like an older sibling I'd say.

The latest versions of C have borrowed features from C++, if you look at the development paths of C and C++ you will find that you can just about find a point where they both inherited from the same predecessor but that development is then along separate branches with exchange of ideas happening in both directions between the 2 branches.

On the occasions when I have used Java I have tended to find it irritating, most recently the most irritating feature was the IDE I was using assuming that it needed to compile everything in the source tree despite some of the files being C++ files, but when I tried to remove those files from it's compile source tree it deleted them from the disk too, where as I wanted them on the disk I just didn't want it to compile them. Sort of "If I can't compile them then no-one can".

I really really really hate programs that think they are somehow more inteligent then me.
One day I'll start a thread about these IDEs that have been thrust upon us.
Unfortunately many beginners are starting out on IDEs these days, practice I think is unhealthy for the programming community.
Nov 28 '06 #21

drhowarddrfine
Expert 5K+
P: 7,435
Agree. Can anyone program in Windows without Visual Studio?
Nov 28 '06 #22

bartonc
Expert 5K+
P: 6,596
Agree. Can anyone program in Windows without Visual Studio?
Yep! With native look and feel using wxPython extentions (wrapper of the C++ wxWidgets) We get free database without MS, too.
Nov 28 '06 #23

bartonc
Expert 5K+
P: 6,596
Yep! With native look and feel using wxPython extentions (wrapper of the C++ wxWidgets) We get free database without MS, too.
Can anyone else program on Windows without Visual Studio?
Dec 2 '06 #24

Banfa
Expert Mod 5K+
P: 8,916
Can anyone else program on Windows without Visual Studio?
Yep, I've been writing Windows programs in C since 1989 when it was Windows 2 and before Visual Studio existed.

I could very easily write a Windows program making direct API calls using any bog standard text editor if I chose.
Dec 2 '06 #25

drhowarddrfine
Expert 5K+
P: 7,435
There's two. heh.

I've downloaded the console version of VisualC++, I think it's called Visual Toolkit, and played with that. It's the compiler with tools but no gui.

I've written a few small apps in assembly for Windows, too. But now I do everything in FreeBSD and have no use for any of that.
Dec 2 '06 #26

bartonc
Expert 5K+
P: 6,596
Yep, I've been writing Windows programs in C since 1989 when it was Windows 2 and before Visual Studio existed.

I could very easily write a Windows program making direct API calls using any bog standard text editor if I chose.
Does "if I chose" mean that this is not really a practical solution, but merely possibility?
Dec 2 '06 #27

drhowarddrfine
Expert 5K+
P: 7,435
You can, it's just that a lot of people nowadays seem lost unless they have VS. Partly because they have to manage all the files manually or set up another IDE to do so. It's just kind of funny when I see someone ask a question about how to do some code and they say, "Well, go to tools->options-> in VS...".

I'm exaggerating a little but it sure seems that way.
Dec 2 '06 #28

Banfa
Expert Mod 5K+
P: 8,916
Does "if I chose" mean that this is not really a practical solution, but merely possibility?
No it's really not that hard it is just easier to use an IDE particularly for resource editing,

First write a Window Handler Procedure

Then in WinMain

Register a Window Class (this is a construct of Windows nothing to do with C++) with RegisterClass
Create a Window of that Class with CreateWindow
Enter a message loop.
Expand|Select|Wrap|Line Numbers
  1. BOOL bRet;
  2.  
  3. while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0 ) 
  4. {
  5.    if (bRet == -1 )
  6.    {
  7.       // handle the error and possibly exit
  8.    }
  9.    else
  10.    {
  11.       TranslateMessage( &msg );
  12.       DispatchMessage( &msg );
  13.    }
  14. }
And that is all there is to it, of course if you want menus and other resources you will need a resource file too, those can be written by hand but even before Visual Studio existed there where GUI programs to do the resource editing.
Dec 2 '06 #29

Post your reply

Sign in to post your reply or Sign up for a free account.