Java Vs. C#: Which Performs Better In the 'Real World'?
Nerval's Lobster writes "Software developer Jeff Cogswell writes: 'Let's compare Java and C#, two programming languages with large numbers of ardent fans and equally virulent detractors. I'm not interested in yet another test that grindingly calculates a million digits' worth of Pi. I want to know about real-world performance: How does each language measure up when asked to dish out millions of Web pages a day? How do they compare when having to grab data from a database to construct those pages dynamically? The results were quite interesting.' Having worked as a professional C# programmer for many years, Cogswell found some long-held assumptions challenged."
When talking about large-scale websites the language is hardly relevent. There are as many high-traffic sites running on C#, Java, PHP or whatever. When facing large scale other factors play a much larger role. The only exception is when you're talking Facebook or Twitter scale: Facebook has practically reinvented PHP and also has some parts of their code in C (or C++, not sure) and Twitter made a switch from Ruby to Scala in order to handle the onslaught of users. The results mentioned in the article (accepting 2000 requests takes 600ms longer when using simple code) are not that interesting in this context.
It would seem that the U.S. Dept. of Homeland Security are C# fans.
What political party do you join when you don't like Bible-thumpers *or* hippies?
What aspects of a language matter to you and how do you weigh them?
As your worst developer on the team.
I've used both and really haven't seen issue with either. I have a slight preference for C#, personally, but it all comes down to your design, architecture, and implementation that will slow you down.
I personally would expect one to win in some regards and the other to win in others. My concern is that C# is too tightly bound to MS platforms. Java isn't perfect, it isn't the write once run everywhere that was promised, but the port from Java on MS to Java on Linux, Mac ... will most certainly be better.
That is enough that I would prefer Java over C# on my projects. Of course there are always outside parameters that might be enough to tip the scale.
What a useless test.
Tells you nothing about what is suitable for your requirements.
Never answer an anonymous letter. - Yogi Berra
Why is it so hard to write a summary nowadays? The point of the summary is not to hide information, the purpose is to provide the information so readers don't have to search it.
Here is the result, right at the end of TFA: "Java is the clear winner here."
I have seen it often said that when a slashdot headline ends in a question mark then the answer is no.
Both runtimes are very heavily optimized, if you need something to run fast, either will work very well for you assuming you code it well and use appropriate libraries/frameworks. As compared to (non-native) Ruby/Python for example which can run code far slower - the JVM and CLR are much more comparable to each other.
I don't really see the value of this guy implementing low-level HTTP stuff in a very naive manner - he's not using modern approches that have been around for a decade (NIO and such) - so the value of any conclusions is essentially worthless.
A much better site for comparing microbenchmarks (with all appropriate warnings attached) would be: http://benchmarksgame.alioth.debian.org/
I used to see a fair number of errors(crashes) that were both java and .net on many huge sites. But now I primarily see errors from crashing java sites. That could be due to people dumping .net, .net cleaning itself up, or .net programmers getting better. Personally I don't use either (did years ago) but the huge number of errors that I would see on what should have been well developed sites is what kept me away going back to either.
Now on smaller sites I see PHP crashes but I would expect to see more people using PHP on smaller sites and more people using it badly.
What I would love is a survey from say google showing what technologies are used on sites getting 1,000,000+ hits per day and what their error rate is?
C# programmers get paid more.
Most linux users don't know this, but the man pages were named after Chuck Norris. Chuck Norris fsck'ing hates noobs!
did anyone notice that this test uses a very carefully crafted test environment? isn't that the opposite of a real-world test?
Windows 8 Metro doesn't use .NET.
Cheap dig aside, you tested Java by using a C# client, so actually what you tested was C# to C# and C# to Java and concluded that C# to C# makes a lot faster connections.
I can also save you the time and tell you Java on Windows machines is a complete dog, and on Ubuntu, it's a lot faster for the same hardware. So if you tested Java on Windows and concluded it was a dog, well yes it is, why is that?
... if the author makes the stupid assumption that Java and .NET are useful to build web pages only.
Before I get modded troll, I'd like to point out that there is a really awesome C++ toolkit for web development and it will blow your mind. It's called Wt and it makes your applications fully OOP and a joy to develop in. One really awesome feature is that it is Boosted and another awesome feature is smart with regard to data. It will use where apropriate (usually you use the AJAX version of a control or mark a function for export to javascript) AJAX rather than statically filling your page. The result are some really easy to code fast websites.
Slashdot's rate-of-post filter: Preventing you from posting too many great ideas at once.
The scenarios you put forward as metrics are far too wide in scope to be any use. so Apples or Oranges which one is better?
These tests were also just as simple as calculating Pi a thousand times. Based on the description, I was hoping for some tests where a website with a dozen or so complete views with significant bindings were created in both Java and C#. Instead it was just an HTTP request or a page that printed the date.
Different frameworks and web servers are going to use varying amounts of overhead, so simple tests really only calculate that overhead. If you are going to provide benchmarks that actually have some meaning then they need to test complex enough behavior to mimic real world usage.
These tests basically just show that Tomcat is faster than IIS for simple scenarios, or perhaps that ASP.NET MVC 4 adds more overhead to page requests than JSP does. Whether this overhead is meaningful when you are processing rich real world web pages is not covered by these tests.
-- All that is necessary for the triumph of evil is that good men do nothing. -- Edmund Burke
...for web servers means including benchmarks for pages with back-end database interaction.
Nobody is going to pay anyone for either Java or C# for pages which merely serve up static content.
C#/CLR is much quicker when directly responding to HTTP requests; Java/JVM is a bit quicker when going through the popular web servers / stacks Tomcat and IIS.
== Jez ==
Do you miss Firefox? Try Pale Moon.
The question is would you like to be hung or firing squad neither of them is very good.
No sir I dont like it.
C is the clear winner. Maybe that why its 1 number in TIOBE Programming Community Index
However choice of programming language has a lot to do with what you want to do.
If you want to create jobs to processing millions of records locally, C/C++ would be better.
If you want to have secure web based jobs, Java would be better.
If you want to create Windows GUI applications, C# would be better.
Basically its horses for courses.
This article was obviously written by someone who has no idea what the state of the art is in performance web serving. If you know anything about high scale web technology, skip it.
.Net framework is fast, the ASP.net framework will be. That isn't the case. Running load testing on hello world test cases is silly. If you are interested in the real world, try testing with real world applications. The author also doesn't seem to understand that the JVM or .Net runtime will compile bytecode using JiT methods (Just in Time compiling). Finally, if you have skilled developers, it doesn't really matter what language you use. Architectural issues like data storage and caching are much more important than language.
Where to start complaining? Don't roll your own http server. You probably don't understand what you are doing, and you will get weird results. Using Windows as a platform for a java web server is pretty silly. The author incorrectly assumes that because the
Test 2: A function to generate a "full web site", (actually a simple web page with all the elements and trivial content). Java beats C# hands down.
Conclusion:
1. The testing guy has absolutely no idea of how to write low level function efficiently.
2. The testing guy's idea of a "full web site" is woe fully inadequate. He could have been the guy designing "full continental breakfast" in Roach Motel Inc.
sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
"Real World?" If we're all not in the real world then we must be living in imaginary space then. Seriously, I see the C#/Java thing coming down to a matter of enterprise choice vs. performance of the language. You'll find big shops running WebSphere/Weblogic and those running JBoss to deploy enterprise apps. There's still a lot of folks deploying with tomcat, which is a great tool. Microsoft has done well over the past few years in improving IIS / .NET scalability where it now can compete with Java EE deployments. 5 years ago you couldn't say that but now the differences are becoming more narrow. I like Java and use it. I like C# and use it as well. My biggest concerns with both is that largely, they're in the hands of two very large vendors. Java has at least more open push on it but again, Larry Ellison will dictate largely what happens to Java and IMO he'll milk it for every penny he can get. C#/.NET not only sells OS licenses for MSFT but it also gets used as a toy as well.
It would be really nice I guess if both of these were truly in the public domain as to prohibit Oracle and MSFT from having direct control over how the languages evolve and are licensed.
Harrison's Postulate - "For every action there is an equal and opposite criticism"
I thought the main reason to use java was to be OS independent. When your web page on Linux couldn't handle the load you could just move your code to a bigger Solaris or IBM box. Or when the PHB says he doesn't trust BSD to be secure he can move it all to Windows.
I've not worked with c#. Is it multiplatform like java or are you stuck with running it on Windows?
Dyslexics Untie!
There's no mention of how he did JVM warmup. These benchmarks probably just indicate speed that the JVM and C# runtimes can interpret byte code, which is a very bad measure of performance in production. Also, mention of tuning anything in the runtimes, etc.
The smith makes the tools, the tools do not make the smith.
The tests the author does not even close to a "real world" scenario. The conclusions drawn are meaningless and the article poorly written. I want the time I spent reading it back!
I wouldn't consider timing a few thousand requests from one client during at most a few seconds to be representative for real-world performance.
Also, the author attributes the speed-up he sees when he repeats the test in the Java setup to optimizations done by Tomcat. It may have been the hotspot compiler being done optimizing, and the word cache doesn't appear anywhere in the article.
I've seen enough Java programmers looking down on .NET and vice versa based on nothing more than prejudice, and it's always nice to see someone who apparently is part of that divide recognise the other side may have merits. But as a benchmark it's not very useful. I've done enough similar small tests myself, but I've always recognized how limited they are and never felt it was important enough to publish an article about it.
I assume the Java HttpServer class used is the one that is bundled with the Sun version of the JVM. This class is not officially part of the JDK and is known to be slow. I am definitely curious about the insanely slow speeds he found. Anyhow, most Java developers who want to embed an http server would turn to Grizzly.
There are 0x40000000 types of people: those who understand 32-bit IEEE 754 floating point, and those who don't.
He gave appalling numbers on his connection test which hasn't been my experience. So I'm curious why his connection test is so out of wack. Tomcat config perhaps?
However I take back his C# to Java test, he says he repeated it on Java to Java and got similar results, (but no numbers).
As a developer who has been working on Java, J(2)EE apps for well over a decade, I know that the configuration of the JVM and of Tomcat (or other application servers) makes quite a bit of difference on an application's performance. C# and Java are both likely good choices, but the comparison in the article was FAR too simplistic to have any relevant meaning.
For Tomcat, tuning the number of threads used for processing requests, accept counts, etc. is absolutely necessary. Also, the author did not specify how his database was configured, ie. the maximum number of connections, memory, and so on. If you configure a large number of concurrent requests in Tomcat, where each request fetches data from the database, you may have many threads blocking while waiting on a connection from the database pool. And we haven't even started in on the real-world tools like Hibernate and its caching capabilities.
JVM parameters are also essential to get right. If you don't assign the JVM enough heap space, or if you don't select the right garbage collection settings, you're setting yourself up for trouble.
Also the comparison of JSP v. servlet is total nonsense. JSP's are compiled first into a servlet, which is then compiled to a class file - the only difference versus a servlet is that the servlet is precompiled to a class file prior to deployment. So the first request to the JSP will obviously take a bit longer, but then the time to serve pages should stabilize.
No graphics, no rigor in method, terrible writing. Dice needs to slap slashdot upside the head to kill these off. They're actually worse than the bitcoin stories.
Well.. maybe. Or Maybe not. But Definitely not sort of.
The actual test for a web platform is more along the lines of "how many simultaneous requests can this handle while still giving acceptable performance?" It doesn't matter if one of them can deliver one webpage 10ms faster than the other if it's going to fall apart at 50 requests.
It's kind of interesting for academic curiousity that Java's HttpServer class is that awful, but these tests don't tell you anything about real world performance.
-- "So they told me that using the download page to download something was not something they anticipated." - Bill Gates
It's like arguing over whether Batman is a Technologist or a Scientist.
"But the reality is, almost nobody actually writes a low-level HTTP listener; instead, they tend to use existing HTTP servers."
Which is the point where I stopped reading since it obviously wasn't real world by his own admission.
For those who seek perfection there can be no rest on this side of the grave.
This is definitely an apple to oranges comparison as far as the CLR vs JVM because you're not just comparing them. You're also comparing IIS/Apache and MVC/whatever java has performance.
I suspect that one of the major reasons for C# being slower though is because Microsoft insists on making everything very magical and very fragily tied together with reflection. Why are views not compiled at compile time? No one knows. Why is reflection required to hook views to models to controllers? "because it's cool". Microsoft tries to make their statically typed language work with a pseudo-dynamically typed framework, and it ends up having crap performance(out of the box) as a result
I actually made an alternative framework("BarelyMVC") because of this. In my framework, I use reflection magic only once, and only because doing it manually is difficult, has no benefit, and has a marginal performance impact. I have staticly compiled views that have nearly no performance impact(it's just string concatenation). My routing engine doesn't rely on transversing folders and searching for specially named classes with attributes, you pass in a lambda to get the model/controller you need. I don't rely on magical attributes and naming schemes for core functionality. Now, of course, my framework isn't as "pretty", but when debugging time comes, it's very clear how everything is connected.
Graphs and charts, that brilliant and extremely high demanding tech from the XV century, that still didn't manage to be available to author of the study.
Because when your operating system doesn't come from Microsoft, you can "See Pound Salt" when trying to run C# code.
#naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
The issue with this article -- can't use wall clock time for performance testing. Author needs to monitor CPU time.
In terms of real world performance, C# may be the best (on windows). However, Java and C# are both managed hybrid languages (partly compiled partly interpreted). So in theory the two languages are probably about the same. If you really want to test them out then I'd try a profiler, and see how the code stacks up. I personally stray away from anything .net because it is not well supported on non-windows platforms. However, java has been found to have some serious security holes as of late as well. When planning for the future it's unlikely that you will be able to see how they will be performing a year from now. HTML5, with javascript, and PHP may still be the way to go.
Today, most of (if not all) the reasons for choosing a language are subjective instead of objective (not objective-c). Languages are so similar (at least the fundamentals, not talking about Brainfuck-lang here) that you pick a language based on the platform it targets or just personal feelings.
In short, the Microsoft fanboys avoid more Linux-favored languages (and don't even think about Apple languages); Apple fanboys avoid more Microsoft-favored languages; and Linux fanboys avoid more patent-encumbered, closed-source languages and ones requiring to purchase an IDE/etc. for development. All fanboys avoid what they perceive as "diseased languages" like the plague. However, they will still touch these diseased language every now and then because either they have to for a job or out of pure curiosity.
Being a Linux fanboy, C# is my bubonic plague. This is also in part growing up using Microsoft Visual Studio 6 for C++. For the haters, I actually loved this IDE, but then I found out that none of my code would work on other platforms or even other compilers with Win32 such as Borland++, g++, etc. (we all remember how a variable in a for-loop wouldn't be contained to just that block... terrible). And then when exploring other languages/environments, I couldn't believe my eyes when I could actually see library-level source code -- you have no idea how useful this is. Even though I'll admit that Microsoft has gotten a little better about this (although they still tried to spread FUD using the DroidRage campaign), it's not worth it to me. They've already lost my faith in them as a customer, and I can't see myself ever returning.
Now, a good study would be to remove all of this and determine what languages are either faster to code in, easier to debug/maintain/extend with enterprise-level code, or more readable. But would this study even be useful? The differences would be so minute. Scripting languages are going to be faster to code in, so what's the fastest scripting language to code in? Object-oriented languages will be the easiest to debug/maintain/extend. As for readability, who knows? It's so subjective. We'd have to get a large, random sample size of people that have never seen a programming language before.
Having said all of this, I still appreciate this guy doing the study. Apache has always made top-quality code, and it's good to see that TomCat lives up to it.
Finally, as for sheer speed (and needs to be at least easier than assembly), C will always win.
The G
Really? Why do Oracle claim ownership of the code and even the api to company like Google? Threatering everyone who implement their variant of Java? On the other hand most of the C# library have been release the source code and the language is itself fully approved by EMCA and ISO (check wikipedia for reference), something Java is not (Because Java lacks any formal standardization recognized by Ecma International, ISO/IEC, ANSI, or other third-party standards organization, the Oracle implementation is the de facto standard.). .NET doesn't run only on Windows, Mono is project that exist for a while and it's use in many context. You can developer even application for Andriod phone in C#, because the language is open, you are welcome to make a compiler and re-use it everywhere!
I should have previewed the comment, this sentence is borked:
"out of 1031 requests for that chain in 8 working hours 2045 requests were processed. It's not a public website, so clearly magnitude is different."
It should be just 2045 requests in 8 hours. 1031 is number of types of requests that can be processed.
So what if there is a 25% different in performance? Hardware is cheap. Software maintenance, administration, and licensing is expensive. The most compelling reason to use Java is that I can run it on Linux. That means I can clone VMs for development and testing, copy OS installations, and ship VMs to customers and resellers without having to spend time and money on licensing and activation. It makes development, testing, and deployment easier to automate when possible and hack when necessary for the small guys that don't have volume license agreements. .NET isn't the problem. Windows is.
Go green: turn off your refrigerator.
I've run in-process game bots in C# and the effect on frame rate was negligible or zero. C# is industrial strength, you can use it for anything. In fact the next official MS C# compiler is written in C#, plus Exchange Server is written in C#.
Open Office is slow as hell.
Repeat after me: Open Office is not written in Java, though it uses Java for some optional features. Yon don't even need Java installed to run Open Office, and disabling Java does reduce Open Office startup time since it no longer needs to start the JVM.
But it's a good meme to keep repeating, because when someone says 'Java sucks because Open Office is slow' and they're not talking about startup time, it's a very good indication that they have no clue.
Is it 2003 or 2013?
Java is crossplatform, .NET is Windows only. Unless you want to lock your business forever in arguably declining platform, you won't be using .NET. Given the rise of non-Intel hardware and Linux it's just not a good practical choice to lock development in Windows.
for a decade to the oil/seismic industry. 17 years ago we thought we might need to delegate number-crunching loops to C++/C/FORTRAN. But that has proved unnecessary. Java integrates parameter control, graphic GUIs, and debugging. I cringe when I have to maintain some old C++ stuff. 64-bit JVMs have been a godsend, since we routinely create 100GB heaps. We've supported Java on IBM, Sun and Windows platforms. 64-bit Linux on workstations and clusters is the plaform de-jour.
but I've been working last year or so on a large Java based web development project for a news media company. This project had to be built around Spring framework due to the enterprise CMS we have bought from another company is using it.
Not ranting, but giving my honest opinion, I am quite unsatisfied with the overall outcome. Mainly because, development takes quite a long time as every minor change needs maven compiling, which takes ages unless you have a server as your development machine. Even we opted for custom hardware, still servers hangs up quite frequently due to memory leaks and common solution is to allocate more memory. Finally, I find it pretty difficult to get things stable and functional in the staging/production servers, despite things works smoothly on a local machine/development server.
I don't scapegoat Java language. Once discarded some of the idiosyncrasies (let's face it, all languages has it merits and ugly stuff), I think Java is a nice language to write code. But frameworks are bigger culprits in my opinion. Also some of the early architectural decisions made in this particular project were not sound, and now we are paying a massive price i.e. failed to deliver on time, lot of overtime + cheap pizza, no x-mas bonus, no holidays.
How are things in the C# world? any better? any worse?
On a side note:
I think it is ridiculous to test OO languages for performance, as they never directly talks with the hardware.
Modern web-applications are written with frameworks. For Java you use Spring, J2EE, persistence is often handled by a JPA implementation. A relevant test should focus on a test application, e.g., PetStore implemented with the same limits and without hacked short hands (optimization which will not work for normal applications). The use combinations of the technologies, like REST with JSP or REST with JSF and J2EE and JSF etc. Also evaluate different JPA connection with different databases.
However, the biggest problem in modern applications are badly written DB-queries, which fetch data too often or too large sets and do subsequently DB stuff in application's Java code (sorting, selection etc.).
While I listed only Java technologies, the same applies for C# even though the zoo of technologies is smaller.
The better question would be:
Which back-end is best?
It'd be complicated to test. Put everything on an SSD, so you've removed I/O latency. Put everything on the same/equivalent hardware with a lot of bandwidth between the parts. Then write different webapps using:
* mysql
* postgresql
* oracle
* cassandra
* mongo
* dynamo
* etc
Then you'd have to show the performance of each application at different levels of utilization...that is, after determining what "performance" actually means for a given application.
That would be a pretty interesting benchmark. Ideally, you'd have multiple webapps, so you could have different usage patterns.
For extra credit, you'd write the webapp in multiple languages and run them in multiple containers, just to see if the container made a difference.
If you want to scale, you use WebSphere. The language doesn't matter - nothing else comes close to the way this beast scales. Develop in Tomcat, deploy on WebSphere.
Seeing arguments over which bytecode/interpreted language is faster is like see two drivers at a tractor pull arguing which of their machines pulling a multi-ton sled most resembles a ferrari.
If you think Reflection usage is bad in ASP.NET MVC, you've obviously never seen Spring...
Also, the "whatever Java has" above is "nothing" because the idiot tested a bare JSP running on Tomcat vs. a ASPX running on top of the entire MVC framework on top of IIS. Yeah, no wonder the perf is going to suck; that's a huge amount of completely wasted overhead. IIS can serve a dynamic ASPX page without any of that MVC garbage just fine, thank you... and with that, get rid of all the Reflection and so forth that, while actually useful in seriously enterprise-y organizations where you want to be able to do things like drop-in replacements of one class for another by changing a single line in a configuration file, are utterly wasted on a trivial benchmark like this.
There's no place I could be, since I've found Serenity...
Dude. Open Office is written in C++. It has some plug-ins written in java, but the main bloat is C++.
I was really expecting a "real" real world test.
I would like to see a head to head between, for example, WebLogic Server with Oracle DB vs. .NET IIS with SQL Server.
The test as is, IMHO, is crap.
A lot of your opinion has been shaped by early java developers who insisted on Synchronizing everything, and that made a lot of it run very slow. Most of that has been addressed, and the speed difference between 6 and 7 is clear. I believe, C# doesn't have the escape analysis that is in Java7 that allows it to bypass the heap and allocate some things on the stack instead. That is probably the core of the speed difference, and his first test using HttpServer isn't testing java but rather JNI code that has been neglected for a long time. Its most likely a variant of C and not really Java. A lot of your Java Games are running in the browser as an applet and are severely limited by the Browser. They'd run a lot better out of the browser as a WebStart app or just a regular Application. Java also lacks access to Direct X or any Good OpenGL out of the box. There are some good addons that you can get like lwjgl, but no good ones with a standard JVM. However, I've had more issue with using product based on .NET in production environments. My company has a server that the first request after it's gone to la la land results in a very long wait for the first result because it's based on .net. There isn't a real fix other than making a cron job that hits the server once an hour to make sure that .NET never starts unloading itself from memory. I could always try to convince them that we could just build a better one in house, but that's time and money already spent on the neurotic server. Which one is best depends on the skill set of the developer.
Not kidding. Microsoft makes Microsoft Windows as weak as possible, apparently, to make more money selling new versions.
I ran a similar test like this when I was having performance troubles with one of my QA apps.
I had written it in C# because I was bored and wanted to explore the language a little bit. I ran into issues with threading and performance when ramping up TCP connections and data processing.
I did a line-by-line rewrite into C++ (seriously, I copied the source and translated each line)....and all my performance problems went away.
In my experience, both Java and C# are easy to write, but abysmal when it comes to performance.
I don't trust Oracle any more than I trust Microsoft. I'll agree that C# started out more proprietary in flavor, but that doesn't mean it will end up that way.
Table-ized A.I.
Before reading the article, my prediction would be that there is little difference, but that Java edges slightly ahead. They are extremely similar languages, used for very similar purposes, both compiled to "interpreted" bytecode, and there are only so many ways you can optimise compiling and executing bytecode which surely by now are in use by both camps. But Java is older and has had more time to be optimised, and there is more competition between different VM's, which is why I would expect slightly higher performance from it. Let's see if I'm right...
Please plase please - bring back the vi vs. emacs fights. I need
some thing to entertain me during my retirement.
Thank you very much
Whiskey Tango Foxtrot? The author ineptly reimplemented a non-threaded HTTP server in Java and wonders why his "two classes" do not work well. Please, learn how real Java webapps work - install Tomcat or Jetty and create a simple servlet. Then use "ab" (Apache Benchmark) tool to measure its performance.
This is a really strange article. MVC vs. JSP / static content is not apples to apples, like the first test was.
When you return a view, it isn't static content. Making a call to a controller is also not the same as serving up an HTML page - the controller is instantiated, the action is invoked, and depending on the type of action, a model could be instantiated and bound. It isn't like creating a simple ASP.NET page that has "Response.Write" in the page load, since the ASP.NET page itself is much closer to what a JSP page is.
There isn't really a circumstance for static HTML in ASP.NET, since it all gets rolled into a Response.Write method in the end. I imagine a JSP page does the same thing, and on both ends, the resulting HTML gets cached. This would be the "optimization" he's witnessing from Tomcat. ASP.NET does the same thing.
You'd have to do some stuff in Java to get to the MVC level of complexity, and not just use Tomcat. Vanilla ASP.NET is a more appropriate tool for comparison. As noted in an above comment, you'd probably have to compare ASP.NET MVC to Spring.
Hell, classic ASP performs better than ASP.NET MVC.
You need to restart your computer. Hold down the Power button for several seconds or press the Restart button.
While not very fair I've always tended to judge languages by their outcomes in terms of usability. From freeware utilities to products from large vendors, to websites using certain three letter extensions there have been certain recurring themes I have noticed throughout the years. Perhaps it is all expectation bias or a reflection of the culture of people who would use certain tools.. I won't pretend to know.
Is it fair to blaim PHP for SQL injection vulnerabilities found in PHP apps?
Is it fair to blame Java when an application outputs a stack trace and keeps on truckin as if nothing just happened?
Is it fair to blame Java when an application is as slow as a drunk snail or consumes mind boggling amounts of memory?
I think in the aggregate it might be possible to make the case for the quality of a programming language based on certain properties of a large sample of resulting programs.
What is the most interesting to me is the disconnect in effort spent by language designers to produce these modern languages and actual resulting outcomes. Why is ancient C(++) still soo popular and what gets used to write all of the core software? Why do we still have operating systems, network stacks and web browsers built in C when we have all of these superior languages with all of their holier than thou ivory tower labled features?
When is a _general purpose_ language going to come along that actually enables people to get amazing results which would not otherwise be feasible without the use of said language?
Who wouldn't cringe if they found out the latest version of their favorite browser had been rewritten in Java or .NET? In my view all TFA is doing is comparing the realitive intelligence of two mentally challenged competitors. I actually like both languages...NET somewhat more than Java. I just tend to not like the resulting program that comes out the other end.
If the author will not publish his source code I will: http://pastebin.com/CkJB6h2K
This is a 32 line Scala program. Yes Scala instead of Java but it is based on the exact same SocketServer that the author claims his program uses. It will sit there and listen for a connection, then do a simple imitation of HTTP. It even optionally supports HTTP Keep Alive.
Now to the test. I use the Apache AB tool: http://httpd.apache.org/docs/2.2/programs/ab.html
First without using -k (keep alive):
baldur@neaira:~/tmp$ ab -c 4 -t 10 -n 1000000 http://localhost:5555/
Time taken for tests: 10.000 seconds
Complete requests: 136991
Requests per second: 13698.99 [#/sec] (mean)
So about 13,000 requests per second processed on my old laptop. The author did 2000 requests in 2687 ms = 1344 requests per second or about 10 times slower than my program.
Lets try again with Keep Alive enabled:
baldur@neaira:~/tmp$ ab -c 4 -t 10 -n 1000000 -k http://localhost:5555/
Time taken for tests: 10.000 seconds
Complete requests: 692424
Requests per second: 69242.23 [#/sec] (mean)
So now we are doing 69.000 requests per second or 50 times faster than the authors program.
It might be that my old laptop is 10 or 50 times faster than the setup the author uses. But somehow I do really not think that is it. I think it is extremely likely that the author is a .NET programmer that has insufficient knowledge of Java to code this simple test correctly and that his program is simply wrong. More specifically I suspect that he did not know that you need to use a thread pool to process the connections, or if he did use one, that he used it wrong.
Into different page elements.
It harms readability.
Now compare it against C and C++
lets see the winner there...
I can't speak to C#. But I've written code for a financial exchange in Java with p50 response times around 100 microseconds. p99's are tricker but were still sub millisecond (mostly due to the GC, however we were moving toward zero GC's). Having said that, most developers who write Java would have balked at the unsavory things we had to do to achieve that speed.
I believe we undervalue the effect of the culture associated with languages. My experience is a lot of Java code is utter crap because the community is self reinforcing of bad ideas. I suspect that competent and motivated developers can take either Java or C# or C++ or whatever and make them fast.
I think in the end the system should have written the critical path in C as it has the right level of abstraction needed for low latency. Java or any other relatively high level language is great for supporting systems.
That message was not written by roman_mir, but rather by someone who has compromised his account. There is no way that he could possibly write a message that long on slashdot without religious docrine inside of it - even if a large part of it is just server response lines.
Java and C# are not different languages. They are the same language - much more similar than, for example Medley Common Lisp and Franz Allegro Common Lisp, and those are two implementations which both conform to the same published specification. Java and C# have very slightly different syntax, and slightly different core libraries. But if you can read (or write) one you can read (or write) the other. The compilers work in very much the same way, and even the object code and virtual machines are similar.
Which isn't surprising. Microsoft based C# on its own implementation of Java, changing it (only) just enough to get around legal problems with Sun. It's a very sincere flattery. C# is slightly newer, so it has slightly less legacy cruft. Apart from that, you are comparing apples with apples here. If you want a more interesting comparison, compare Java/C# with Ruby, Python, Lua, JavaScript/EcmaScript or Clojure.
I'm old enough to remember when discussions on Slashdot were well informed.
I agree that for large sites language is not necessarily important. For most large media sites performance is mostly dependent on how well the caching structure is set up. You only hit the servers as often as you need to update the cache. The traffic is served from a combination of varnish/squid and some CDN (akami). If you are serving customized information (billing,user accounts,product catalog) then you may start to talk about load and language performance.
Any ad-serving has to be done "Cache-Control: no-cache" or "Cache-Control: max-age: 10" (or similar small number of seconds), or you simply aren't going to be able to sell ad views. The GMail main pages, the FaceBook main pages, and basically anything where the revenue model is ad-driven (e.g. all newspapers online, etc.) don't cache their front page.
What they do serve out of cache is the CSS, page templates, and a small amount of static content unrelated to their primary reason for living, which is the dynamic content.
In addition, session content is typically not cached, which means that any content dependent upon cookies, hidden fields to get around people turning off cookies, flash super-cookies, and so on, are also not caches, unless you are running an L3/L4/L7 cache, and have session communication between your cache and the back end server on a per request basis. This does not happen a lot, since it ties a site to a particular cache vendor, such as RedBack, Cisco, F5, etc., and each of these vendors is unwilling to have a standard cross-vendor means of doing this because they specifically want the site to experience vendor lock-in, rather than commoditizing themselves.
The session content is the content which is generated and regenerated each time. You can amortize this by having longer session TTL's, but for something like a news site, it's generally easier to re-gen the session from the cookie than it is to keep content alive, and keeping cached content alive. Generally these sites are high connection volume, low refresh rate (assuming people actually *read* your static content), so what gets refreshed are the frame contents for the ads, not the per session information.
This leads to a "work-to do-engine model", where the server handling the session from one request to the next moves around (typically, this is done by using the load balancer in "one-armed" mode so that HTTPS sessions can be maintained, but the response can be fielded by any back end server in the pool). So the Connection: header and HTTP 1.1 persistent connections aren't enough to hang your session data cache on.
So all this boils down to back end server performance being an issue.
At which point, you have two choices: use a compiled language, or use an interpreted byte code language like Java or C#.
The compiled language gives you the best performance, so that means as you scale, you need to throw less hardware at the problem of having enough back end servers (or if using a cloud provider like Amazon, you end up paying them less for virtual servers).
The byte-code interpreted languages are generally easier to manage development on with relatively unskilled labor compared to the compiled languages (the languages are designed to try to preclude as much foot-shooting as possible), and have rather rapid turnaround compared to compiled languages, should you need to make changes. The trade off is that you are going to be throwing proportionally more hardware at the problem in order to scale up. At some point, it's going to start getting really costly, and you are going to be transcoding your byte code and/or rewriting your code to get it into native code instead of bytecode (FaceBook went through this transition by writing a compiler for PHP, in which they originally wrote the site, and it was an expensive, technically meticulous process, which mean that they had to hire top people to do it).
As to picking Java vs. C#, if you aren't expecting to need to scale, and expect to remain a relatively smal
Word of advice to tester: please switch career.
KERNEL PANIC -SIGFAULT AT ADDRESS #51A54D07
I just care for one benchmark: Who is making the better movies?
http://www.youtube.com/watch?v=ALIkp1wkeDs
http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
My biggest question is: which modules is the ASP.Net app using? If it is serving up a single string but running with the default set of HttpModules, there's a lot of unnecessary processing going on. But it's not detailed, so it is hard to say if the test is a fair one or not.
I do not believe that C# does the escape analysis like Java 7, but C# allows developers to directly place objects (anything declared as a struct) onto the stack.
Just taking a poke in the dark, but you probably want to disable the recycling on your server, which should avoid the cron job needing to run. The server is trying to unload the application to cleanup, and when it gets reloaded by a future request, then it forces a recompilation. Relatedly, if the code can be compiled (into a DLL rather than dumped as files onto the server), then it should help ASP.NET from having to also compile the code upon first request as well before even being able to do the JIT.
http://stackoverflow.com/questions/5889284/prevent-iis-from-unloading-asp-net-site
nano
Well gee, let's see. I can definitely say that C# programs do not perform as well on OSX, Linux, or IBM I.
Proverbs 21:19
Java sucks because every client application which depends on it has a huge amount of latency. The JVM takes forever to start, it randomly garbage collects and until JIT kicks in, it behaves like a scripted language.
Who knows how many millions of man-hours were spent by Sun on the JVM, and it still doesn't perform well because it's broken by design. Also, the language itself is ridiculously verbose. Java is the modern day equivalent of Cobol, which should never have gained traction in the first place.
C and C++ are the language that perform better.
Why isn't it used more? It's because performance is not the most important thing in web development.
The most important thing in web development is the ability to get cheap coders with no skills, that can re-use existing libraries to do the trivial things that are needed of them.
While I favour Java somewhat over .NET/C# and this 'test' supports my favourite, I just want to point out that this test is entirely useless. To fall back on the well-worn car analogies, this is like testing which car starts up faster. Who cares, if you never go anywhere? So, the Java server takes a quarter millisecond to processes an empty request compared to one millisecond. Who cares, if you're not actually processing anything in the request? The difference would be lost in the noise of any real-world test.
Whales are everywhere! RUN! RUN FOR YOUR LIFE! If you don't heed my warning, you'll find a gerbil hanging out of your ass and a giraffe trying to gum your pecker.
Working about half of the time in Java and half in C#, I find I am far more productive in C#. I can get the same job done in C# with a fraction of the effort and lines of code because of things like properties (and short-circuit properties), LINQ, async/await, TPL, true generics, structs (and user value types), ref/out and many more language improvements that C# has over Java.
The experiment can hardly be called real world.
Java applications runs on all Operating Systems and Hardware. Does C# run on smartphones, OS X, Linux, Android, tablets, etc?
With all the problems that Java has, about obscure security holes never to be patched because THEY do not really want to fix them
If you disable JAVA ..... taadaaa......MICROSOFT SKYDRIVE ask you for java script!!!!
common!!!!
What is the next step at microsoft headquarters..... to suddenly steal java and javascript manuals?????
"Open Office is slow as hell"
Actually, if you pre-load the
ooffice modules it runs just as fast as MS Office (Word, Excel..)
Timed on a Win7 laptop: 7 seconds each
When I have something performance sensitive I can always work hard to optimize it, and even switch to a different platform
for some small part of the project.
The question therefor is not how fast can I write it, but how easy is it, this has a lot to do about libraries and tools but language makes a difference too.
The JVM environment is an excellent environment to work in, with a plethora of excellent libraries and tools (including the Tomcat server).
Yet the Java language is falling rapidly behind, and C# is rapidly gaining new bells and whistles while Java is stagnating,
I find it mind buggling Java 7 doesn't have lambda expressions.
That's why I have switched to Scala which gives all the good of the JVM in a modern functional yet object oriented language
giving me all the protection of a strongly typed static language yet with minimal boilerplate reminding me of dynamic languages.
Well, obviously there are at least two directions one can approach this question.
From the malicious user's standpoint, Java has been outperforming C# by a very large margin and will probably continue to do so.
This benchmark doesn't isolate C# and the Java components and then measure them. This is relatively common place on Windows with VS and Perfmon. How would you do this level of detailed analysis on *nix. What are the best tools to measure and track the fine grained resource utilization, examine queues, and perform call profiling of code? IMHO the standard mechanisms for JMX are very resource intensive and significantly impact any code performance at load.
is Forth. There I solved all your problems, now, my sad little ants, get on with your lives.