Saturday, February 07, 2009

C# versus C++ versus Java performance comparison

The performance comparison of C#, Java and C++ was always a controversial subject. Many people who are unfamiliar with JIT'ed environments claimed anything runs on JIT is too slow compared to C++. On the other hand people who actually use Java and C# usually claimed the otherwise that performance impact is negligable. Here's a nice chart I've found that a friend in freenode IRC server pointed me. These benchmarks are done by Matt R Warren (aka Moridin8 in irc.freenode.net) and his original site is http://www.csharp-architect.com


According to below chart, choosing C++ just for the sake of performance doesn't seem very feasable to me. Remember : Engineers are expensive and servers are not!




75 comments:

Dinh said...

Please run PHP and Ruby on Linux. PHP is not optimized for Windows. Therefore PHP is deadly slow on this platform

Anonymous said...

Please make sure you run with server jvm on windows - java is not using it by default (as opposed to linux).

If possible, make the benchmark bit longer - 3-4 seconds hardly gives any chance to dynamic optimization and penalizes longer startup times. One minute for java should be more than enough to offset those factors.

Jack Park said...

Engineers are expensive and servers are not!
Servers may be cheap, but the real cost of the energy to run those servers is increasingly more expensive. The fewer servers required to ship bits, the better.

Isaías Alves said...

if.. if.. if...

Java is the best language... have the perfect api with all resources needed to development.

Sorry PHP, sorry ruby, sorry microsoft.. But java is the best!!!

Anonymous said...

Great chart and graph.
It would be very interested to compare the performance using multicore programming or concurrent or threaded programming.
For example, we had an application written in C# which had an horrible performance. However, we made some exercises found in the excellent book "C# 2008 and 2005 threaded programming", by Packt Publishing (http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book), and we could multiply performance by more than 3,5 in a quad-core CPU.
Therefore, I think it would be great to see a performance comparison taking into account modern multicore computers.
Besides, the Garbage collector would enter in action. And, the results should be very interesting for the developers interested in the best performance.
I work with both Java and C#.

Isaías Alves said...

if you say about a garbage collectors. On this aspect, java and c# its equals... because the language patterns and design its very equals..

Uses of garbage collector set the java on the top of ranking... Yes.. show the graphic using this method.

And C#? Yes.. C# to.. Sun creates.. Microsoft Copies..

Good for .NET programmers...

Im to develop in Java and C# to...

But.. the .NET framework not help the C# language in performance and in a best programmer methods.

Thanks

Anonymous said...

What about memory usage ?

Anonymous said...

Hi,

I would actually like to see the code. I beleave, that your results are correct for typicaly written programms. But in C++ you can optimize and optimize and optimize until the last register is your best friend and the pipelines are your lovers.

Anonymous said...

I guess the numbers come from The Computer Language Benchmark Game (http://shootout.alioth.debian.org/) and/or the windows port at http://dada.perl.it/shootout/

Jesse said...

Can you please detail the compiler settings used for each compiler tool? Thanks.

Anonymous said...

A lot of fucking spam over here... Ruby 1.8 is old and slow. It should use Ruby 1.9

Anonymous said...

What configuration of server?
PHP correct working on Unix optimizet server.

Zsolt Sandor said...

"But in C++ you can optimize and optimize and optimize until the last register is your best friend and the pipelines are your lovers."

Yes, and you have to pay the development costs. That way we can say that hand written assembly code is the best... who the hell will pay out the 100x development time?

Isaac Gouy said...

All those things that previous commentators have said are missing from this "performance comparison"

- run PHP and Ruby on Linux
- make the benchmark bit longer
- multicore
- memory usage
- the code
- the compiler settings
- Ruby 1.9
...

are shown on the website these programs were taken from

The Computer Language Benchmarks Game

Unknown said...

When I bought my computer and I didn´t know how to use java graphics, so I decided looking for information in a webside and I found an useful information that helped me a lot.. Now I am interested in to do the best investment and I found a webside very useful and interesting called costa rica investment opportunities , I think it´s a very wonderful site.

Anonymous said...

Interesting post. Too bad it's completely inaccurate.
1) The claim in this article finds no ground in reality - the performance difference is noticeable by end users.
2) I find these numbers hard to believe. Really hard to believe - I mean, they show C# being faster than C++.
It doesn't matter how fast C# is, C++ will always be faster, because by definition it does less.

Anonymous said...

"Engineers are expensive and servers are not!"
Look around the world there are more Engineers than servers.

Anonymous said...

Thanks for the information

http://extreme-java.blogspot.com

Belch Echo said...

Would you please do a better graph? Use a bar chart or something.

Anonymous said...

"The claim in this article finds no ground in reality - the performance difference is noticeable by end users."
Facepalm... This is because C# is easier to learn => more unskilled novices make more software.
C++ is more difficult => there is less novices, more pros => more fast and robust software.
C# apps being generally slower doesn't mean c# is worse than c++ at all. It doesn't have to do anyhing with its performance. In good hands, any tool is nearly perfect.

Anonymous said...

>It doesn't matter how fast C# is, C++ will always be faster, because by definition it does less.

Seems you have little experience in both systems... C# _doesn't_ actually do more. .NET environment is basically the same C++ compiler except it does it on-demand. Its code output can be (and often is) 100% identical to that of C++. The only thing C# does "more", is forced garbage collection. You're right, if you're writing a hello world program. If there is a garbage collection while the program is printing "Hello, World!" then that might be problem.

But if you're writing a complex application, C#'s garbage collection is a plus. Why? Because C++'s ugly RIA does more. Imagine there a lot of functions, and each time it acquires, initializes and destructs. There is also reference counting out there -- and it does a lot more than C# as well (right to memory each time).

General memory allocation system does a lot more in C++ than in C# (it has bump pointer allocation).

C# may be still a little bit slower (thoough already comparable) just 1) it's not so mature as C++, still developing 2) Microsoft loves to do things gradually, to buy as many new versions as possible.

Anonymous said...

Good article. This is a good article explaining which is better for beginners. http://mytechrant.com/?p=6

Javin @ OutOfMemoryError in Java said...

This word makes the whole post classic "Engineers are expensive and servers are not", quite true and that's why Java rules because of ease of development and availability of expertise.

Hrishi Sharma said...
This comment has been removed by the author.
Hrishi Sharma said...

Java Devs say C# is inferior , whereas .Net developers bite th'm the other way round.........

I would love to listen to the views of those who are .Net(C#) cum Java developer..... :p

wholesale cheap jerseys said...

The server may be cheap, but the real cost energy to run the server is more and more expensive. The fewer the server may need to position the better.

Cheap Nike NFL Jerseys said...

If possible, make the benchmark bit longer - 3-4 seconds hardly gives any chance to dynamic optimization and penalizes longer startup times. One minute for java should be more than enough to offset those factors.

Anonymous said...

I have write nice article about caching object in C#. You can find it here: http://blog.szulak.net/programming/caching-objects-in-c/

Invest said...

Amazing insight. C++ runs the fastest on GNU Linux. For my developing needs, I choose c# for my work and Java for my own projects, because Java has free IDEs and C# needs Visual Studio. Performance on windows-wise, I prefer c#.

Anonymous said...

Can we get an update of this chart for 2014?

Unknown said...

or 2015?

dev said...

thanks for providing such a great article, this article is very help full for me, a lot of thanks sir
finance project for mba
finance topics for mba project
Ignou Synopsis

dream girl said...

I have saved this link and will return in a Income tax filingcouple of months, when I need to build my first blog. Thank you for the information.

DILIP KUMAR said...

Much gratitude to you for such an extraordinary sum for the post you do. I like your post and all you share with us is ground breaking and extremely enlightening, I may need to bookmark the page so I can come here again to get you, as you have made a splendid appearing.

satta result
satta king
satta chart
satta matka result
satta matka
satta king online Result
satta
gali satta
disawar result

Suresh Dasari said...

Good comparison on c#, Java and c++

Abhishek said...

Good comparision

Anonymous said...

Awesome read, keep up the great work! for more Tutorials

today ipl match prediction said...

ipl season 13 winner prediction

ipl bhavishyavani

ipl today match astrology prediction



IPL Toss Astrology

Today Match IPL Bhavishyavani


ipl bhavishyavani 2020

FIFA WORLD CUP said...

thanks for sharing such great blog
Technology News
Tech news
SEASONS
MOVIES
ANIME
ENTERTAIMENT
RELEASE DATE
WEBSERIES

FIFA WORLD CUP said...

thanks for sharing such a great blog

ENTERTAIMENT

sonam said...

We are providing the best ispa sevices in singapore in woodlands with all safety measures. We have been awarded for the best business in 2019. You can also book your appointment online .We are providing our best in the industry.
cheap massage singapore
massage parlour singapore

shivam said...

We basically deals in graphic tees for men in india,best men's activewear online india and polo T-shirts for men in india.

mass international
polo T-shirts for men in india

shivani said...

Thanks for sharing such a useful article regarding blogging, you have cleared all my doubts
Clinical Psychologist & Psychotherapist in India
Qualified Mental Health Professional in India

sachin said...

Contact us for loving and independent Call girls in delhi gurgaon. Our Escort service is available 24x7. We provide hot girls.
Female escort full night services in Delhi NCR
Hot female escort services in Delhi NCR

shivani said...

We trained students for NDA navy and airforce, we are providing the best coaching in minimum fees. It is the best institute in all over in Dehradun for NDA airforce and navy coaching

Top airforce coaching center in Dehradun
Top Air force X group, Y group, Coaching center in Dehradun

shanti said...

We have 10 years in addition to of inclusion and involvement with planning private sun oriented plans. We give a wide scope of administrations in this division going from deals to interconnection. Our group has an inside and out comprehension of AHJ and Utility necessities and know about different codes and compliances.

Solar PV Design Services
Residential Solar permit plans

SANYA said...

We are providing corporate services in singapore like company registration singapore,business registration singapore and company set up singapore etc.We provide our expertise in taxation to individuals and a wide range of businesses.
company registration singapore
business registration singapore

kajal verma said...

russian call girls in allahabad
housewife escorts service in allahabad

Anonymous said...


Escort Service in noida
call girls in noida

ipldevta said...

IPL Astrology 2021

IPL Bhavishyavani Prediction

IPL Prediction Astrology 2021

Today IPL Toss Bhavishyavani 2021

IPL Toss Prediction 2021

IPL Match Prediction Astrology 2021

Today IPL Match Prediction 2021

IPL Bhavishyavani Astrology 2021

pro blogger said...

mashvo
netflix mod apk

pro blogger said...

mashvo
netflix mod apk

Anonymous said...

karolbagh Escorts
Lajpat Nagar Escorts
Lajpat Nagar call girls
nehru place Escorts

Rj Zillionz said...

TKO Carts
TKO Extracts
TKO Edibles

rj said...

Glo Extracts

Unknown said...

Buy DMT
Buy DMT Online
Buy DMT Online USA
DMT sale
Where to buy DMT
Order DMT Online
Purchase DMT
Where can I DMT
Where to purchase DMT
Buy Changa DMT
DMT Online Store
buydmtdrug.com/shop/

Essien said...

Greatly information from blog. Thanks for sharing your ideas. Click for more info. easy info blog

lucy said...

Runtz Crew California

janvi verma said...

I will definitely use this information in the very near future.

hr services company

hr services

rj zz said...

Raw Garden Carts

Antony Silvado said...

Are you still looking for the best place to purchase quality chemicals online? Purechemshop.com is the best place to purchase chemical of all kinds. Purechemshop.com is one of best online marketplace to purchase chemical online at best prices
Purechemshop.com
Purechemshop.com/product/buy-mescaline
Purechemshop.com/4-Mec-Drug

tommy said...
This comment has been removed by the author.
Unknown said...

Am located in Pennsylvania State you can
either come pickup or we arrange shipping
To begin I will start by asking you
some questions, sorry for all the Questions
just to be sure my
kittens are going to a good home.
Are you a breeder?
Are you use to this breed?
Do you have kids?
What is your occupation?
Give me a Brief Description of your Environment?
Are you sure that you are going to take care of our kittens?
Where exactly are you located? With this
information I will be for sure that you are going to
take good care of the kittens,
attached are pics of the kitten

janvi verma said...

thanks for providing such a great article, this article is very help full for me, a lot of thanks sir
hr support
hr company

SEO Royale said...

No question this is an exceptional post I obtained a whole lot of knowledge after reviewing good luck. The theme of the blog site is outstanding there is virtually every little thing to review, Brilliant post.
Archives
eprimefeed.com
Latest News
Economy
Politics
Tech
Sports
Movies
Fashion

B2B Marketplace said...

You can use some tools present on the internet for beautifying your write-up.
Buy apparel and textile machinery in india
Apparel and garment machinery suppliers

kashif said...

i am a professional web blogger so visit my website link is given below!
softtakes
Java Development Kit for Windows
MEGAsync Crack
Zoom Meeting PC for Windows
Adobe Premiere Pro for Windows CC

Driver Booster for Windows
Windows 7 Ultimate Free Download
Nox App Player for Windows
videoprocvlogger4.1
Adobe Photoshop

mike penns said...

Its my greatest pleasure to come across your blog with so much useful information thanks for sharing.
black-sphynx-cat
hairless-cat-adoption

mike penns said...

We really enjoyed every single bit of time spent on this awesome blog.
Please just click on our links for great and greater content.

apple-gelato
sticky-buns-strain
runtz-og

Healthandfigure said...

enjoy guys this site information

mahilao ko josh ki goli ka naam

Mai ek doctor hu name (dr mahesh chand) maihealthcare doctor hu mai health se problem presaan logo ka ilaz karta hu ajj kal aaplog dekh hi rahe honge ke ajj kal log health se related problem se kitne presaan hai

Abhishek said...

Wind Cool AC Trading LLC is the complete solution for Trane Chiller parts, Carrier Chiller parts, Carrier Compressor Parts, York Compressor Parts, Bitzer Compressor Parts in Dubai, Chiller & Compressor parts sourcing. Including new generation & old generation compressor, chillers . For more visit on- https://www.windcoolac.com/

misbah said...

Sketch UP Pro 2023 Crack is a powerful 3-D construction software produce for a sever variety of represent software.

nee said...


Playstation 5 / Playstation VR2 / Playstation 4 / playstation5 console / playstation5 camera / playstation 4 console / playstation 4 controller playstation 5 restock sony playstation 5 stores contact info :: +16573580970

karl said...

Buy NCLEX without Exam
Buy SSN
buy US Driver’s License

karl said...

Buy Cloned Cards
Cloned Cards Shop
Buy Cloned Visa Cards
Buy Cloned Master Cards