d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Reading Minoko's Code...
Prev12
Add Reply New Topic New Poll
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
May 7 2014 10:51am
What apps? Are you sure it isn't just the developer and not the language?

Case in point, this thread was created to praise me on some rudimentary c++ I wrote. In comes Krza and code reviews it and finds a ton of flaws in my implementation. I submit to him as I am not a C++ dev as he is. Developers are fallible. That doesn't mean the language is broken.
Member
Posts: 1,241
Joined: Jun 25 2011
Gold: Locked
May 7 2014 11:00am
Quote (Minkomonster @ May 7 2014 05:51pm)
What apps? Are you sure it isn't just the developer and not the language?

Case in point, this thread was created to praise me on some rudimentary c++ I wrote. In comes Krza and code reviews it and finds a ton of flaws in my implementation. I submit to him as I am not a C++ dev as he is. Developers are fallible. That doesn't mean the language is broken.


just did a quick test on my computer:

Code

luke@wheezy:~/Downloads$ time ./helloC
hello world

real 0m0.001s
user 0m0.000s
sys 0m0.000s
luke@wheezy:~/Downloads$ time java helloJ
hello world

real 0m0.123s
user 0m0.096s
sys 0m0.020s
luke@wheezy:~/Downloads$


I'm not saying this is a significant test, but still there is a difference
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
May 7 2014 11:24am
That is hardly a sufficient test.

If you want to benchmark you are going to need to target the aspects of the language which produce the performance gains.

For java this would be things like:

Garbage collection: complex memory management requires complex garbage collection. Java has HotSpot.

Platform targetting: c/c++ is compiled before hand which means it must know the processor ahead of time. This means unless your app is run on a single known processor, you are better off coding s one size fits all. Java uses JIT compilation which basically compiles at runtime, which means it will know the exact processor it is running on. This allows it to apply processor specific optimizations dynamically.

Libraries: Sun/Oracle have built an excellent, performany library for ADTs and common functions. Which are not only easy to understand but also easy to use. The STL is not. Although die hard C++ programmers will argue against this, it is widely accepted that Javas libraries trump C++

Coming back to your test, lets bring up the fact that Oracle's JVM iswritten in C++. This means that given enough time money and engineering you can make C++ as fast or faster than Java. With that said, the reason simple programs that do nothing more than print a statement or run a couple loops will always favor C/C++. Once you break away from that, you allow the langagues performance to shine.
Member
Posts: 1,241
Joined: Jun 25 2011
Gold: Locked
May 7 2014 11:43am
Quote (Minkomonster @ May 7 2014 06:24pm)
That is hardly a sufficient test.

If you want to benchmark you are going to need to target the aspects of the language which produce the performance gains.

For java this would be things like:

Garbage collection: complex memory management requires complex garbage collection. Java has HotSpot.

Platform targetting: c/c++ is compiled before hand which means it must know the processor ahead of time. This means unless your app is run on a single known processor, you are better off coding s one size fits all. Java uses JIT compilation which basically compiles at runtime, which means it will know the exact processor it is running on. This allows it to apply processor specific optimizations dynamically.

Libraries: Sun/Oracle have built an excellent, performany library for ADTs and common functions. Which are not only easy to understand but also easy to use. The STL is not. Although die hard C++ programmers will argue against this, it is widely accepted that Javas libraries trump C++

Coming back to your test, lets bring up the fact that Oracle's JVM iswritten in C++. This means that given enough time money and engineering you can make C++ as fast or faster than Java. With that said, the reason simple programs that do nothing more than print a statement or run a couple loops will always favor C/C++. Once you break away from that, you allow the langagues performance to shine.


Sure I wont deny all that but having done a little Cpp with the Qt library it did seem to be more reactive to me than when I do some Swing. But dont get me wrong I love java too :p

Edit: might be that Ive always coded on somewhat poor machines too, be it at school or at home, perhaps the vm needs much more resources to run as fast as cpp

This post was edited by m0hawk on May 7 2014 11:51am
Member
Posts: 9,803
Joined: Jun 28 2005
Gold: 6.67
May 8 2014 04:37am
Heh, it is true that in certain circumstances, some code may be faster in Java/C# than in C++, but that's not the case if the code has been sufficiently optimized (you can build and pack several implementations of the same function for different processors in the same binary, but you can't enforce cache-friendliness in Java/C#). The true problem is developer time. Is 5-10% speed-up worth 10x more developer time of more experienced devs? The main selling point of Java/C# is not outperforming C++, it's getting reasonable performance and good safety guarantees (hard to shoot yourself in the foot) for a fraction of the development cost and for a lot of apps it works very well. Sure, a behemoth like Visual Studio (C#) does feel sluggish compared to Qt Creator (C++/Qt), but it's still blazing fast in comparison against Eclipse(Java) - though I'm told jetbrains' stuff is vastly superior. The point is, though, your app most likely doesn't need that kind of horsepower to be available and your user won't notice anyway, so you should choose what you're most comfortable with.
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll