Java better than C++ | Lives Here | | Join Date: Sep 2006
Posts: 12,070
| | |
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.
|  | Moderator | | Join Date: Jul 2006 Location: The Netherlands
Posts: 4,139
| | | re: Java better than C++
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:
| | Lives Here | | Join Date: Sep 2006
Posts: 12,070
| | | re: Java better than C++ Quote:
Originally Posted by ronverdonk 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...
| | Newbie | | Join Date: Oct 2006
Posts: 11
| | | re: Java better than C++
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.
| | Lives Here | | Join Date: Sep 2006
Posts: 12,070
| | | re: Java better than C++ Quote:
Originally Posted by Starasoris 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
|  | Administrator | | Join Date: Feb 2006 Location: South West UK
Posts: 6,463
| | | re: Java better than C++ Quote:
Originally Posted by r035198x 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?
| | Lives Here | | Join Date: Sep 2006
Posts: 12,070
| | | re: Java better than C++ Quote:
Originally Posted by Banfa 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?
|  | Moderator | | Join Date: Sep 2006 Location: Minden, Nevada, USA
Posts: 6,403
| | | re: Java better than C++ Quote:
Originally Posted by r035198x 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.
|  | Expert | | Join Date: Sep 2006
Posts: 5,830
| | | re: Java better than C++ Quote:
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.
|  | Moderator | | Join Date: Sep 2006 Location: Minden, Nevada, USA
Posts: 6,403
| | | re: Java better than C++ Quote:
Originally Posted by drhowarddrfine 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?
|  | Expert | | Join Date: Sep 2006
Posts: 5,830
| | | re: Java better than C++
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.
|  | Expert | | Join Date: Jun 2006 Location: Seremban, Malaysia
Posts: 1,630
| | | re: Java better than C++ Quote:
Originally Posted by r035198x 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.
|  | Expert | | Join Date: Sep 2006
Posts: 5,830
| | | re: Java better than C++ Quote:
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 |  | Moderator | | Join Date: Jul 2006 Location: The Netherlands
Posts: 4,139
| | | re: Java better than C++ Quote:
Originally Posted by drhowarddrfine 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:
|  | Administrator | | Join Date: Aug 2006 Location: Dublin, Ireland
Posts: 11,114
| | | re: Java better than C++ Quote:
Originally Posted by ronverdonk 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
|  | Expert | | Join Date: Sep 2006
Posts: 5,830
| | | re: Java better than C++ Quote:
Originally Posted by ronverdonk 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.
| | Lives Here | | Join Date: Sep 2006
Posts: 12,070
| | | re: Java better than C++ Quote:
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.
|  | Moderator | | Join Date: Oct 2006 Location: New York, United States of America
Posts: 3,428
| | | re: Java better than C++
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
|  | Administrator | | Join Date: Feb 2006 Location: South West UK
Posts: 6,463
| | | re: Java better than C++ Quote:
Originally Posted by drhowarddrfine 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.
|  | Expert | | Join Date: Sep 2006
Posts: 5,830
| | | re: Java better than C++ Quote:
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!"
| | Lives Here | | Join Date: Sep 2006
Posts: 12,070
| | | re: Java better than C++ Quote:
Originally Posted by Banfa 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.
|  | Expert | | Join Date: Sep 2006
Posts: 5,830
| | | re: Java better than C++
Agree. Can anyone program in Windows without Visual Studio?
|  | Moderator | | Join Date: Sep 2006 Location: Minden, Nevada, USA
Posts: 6,403
| | | re: Java better than C++ Quote:
Originally Posted by drhowarddrfine 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.
|  | Moderator | | Join Date: Sep 2006 Location: Minden, Nevada, USA
Posts: 6,403
| | | re: Java better than C++ Quote:
Originally Posted by bartonc 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?
|  | Administrator | | Join Date: Feb 2006 Location: South West UK
Posts: 6,463
| | | re: Java better than C++ Quote:
Originally Posted by bartonc 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.
|  | Expert | | Join Date: Sep 2006
Posts: 5,830
| | | re: Java better than C++
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.
|  | Moderator | | Join Date: Sep 2006 Location: Minden, Nevada, USA
Posts: 6,403
| | | re: Java better than C++ Quote:
Originally Posted by Banfa 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?
|  | Expert | | Join Date: Sep 2006
Posts: 5,830
| | | re: Java better than C++
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.
|  | Administrator | | Join Date: Feb 2006 Location: South West UK
Posts: 6,463
| | | re: Java better than C++ Quote:
Originally Posted by bartonc 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. - BOOL bRet;
-
-
while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0 )
-
{
-
if (bRet == -1 )
-
{
-
// handle the error and possibly exit
-
}
-
else
-
{
-
TranslateMessage( &msg );
-
DispatchMessage( &msg );
-
}
-
}
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.
|  | | | | Forums
Visit our community forums for general discussions and latest on Bytes
/bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 229,155 network members.
|