<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Why managed code is slow</title>
	<atom:link href="http://littlesvr.ca/grumble/2008/04/08/why-managed-code-is-slow/feed/" rel="self" type="application/rss+xml" />
	<link>http://littlesvr.ca/grumble/2008/04/08/why-managed-code-is-slow/</link>
	<description>The things that piss me off.</description>
	<lastBuildDate>Wed, 18 Jan 2012 16:58:19 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Rob Helmer</title>
		<link>http://littlesvr.ca/grumble/2008/04/08/why-managed-code-is-slow/comment-page-1/#comment-507</link>
		<dc:creator>Rob Helmer</dc:creator>
		<pubDate>Wed, 09 Apr 2008 07:26:28 +0000</pubDate>
		<guid isPermaLink="false">http://littlesvr.ca/grumble/2008/04/08/why-managed-code-is-slow/#comment-507</guid>
		<description>Funny, I&#039;ve been thinking about this a lot the past week or so. Here are some things to consider:

* Java does JIT by default. This is going to do inlining, loop unwinding, etc. at runtime. You can help it do it&#039;s job better if you know (and measure) what it&#039;s doing.
* garbage collection may run at any time, and totally screw your performance. It is tunable though, and is fairly predictable with not a lot of work. 
* a lot of slow Java apps are still a result of bad code - e.g. creating new Strings instead of using StringBuffer in a loop which may take arbitrarily large input data (this is a general pattern of not reusing objects). This is not only be way slower per-invocation but will also fill up memory and make the garbage collector work harder.

Wikipedia has a pretty decent article, actually - http://en.wikipedia.org/wiki/Java_performance

However, all that said, Java has some really decent profiling tools, and if you spend time optimizing your critical paths I don&#039;t think that I/O errors (to take your OutputStream::write() example) are going to have a dramatic effect from VM version to version. There are tons of variables when you&#039;re installing on systems that you don&#039;t control, and it gets a lot worse when you&#039;re talking cross-platform (and not just multiple versions, e.g. kernel for a particular OS).

If you want to make performance improvements, the important thing is to be able to measure the current state and continue to measure as you make changes (e.g. by profiling). The big problem with big C or C++ apps tends to be working around strange platform and toolchain quirks that cause undesirable problems, which having a VM somewhat shields you from as it becomes someone else&#039;s problem :) This of course makes it harder for _you_ to solve, though; when you&#039;re compiling the binary you can call a lot more of the shots (which is both good and bad of course).

I&#039;m not really sure how to measure .net runtime versus java runtime performance. I would not be surprised if only supporting one OS and being able to focus on supporting it&#039;s version-specific quirks was a lot more productive than what Sun is trying to do :) The way that you can call unmanaged code is much easier and faster in .net (P/Invoke) than in java (JNI), and .net obviously uses native UI elements so that&#039;s probably going to help user perceived as well as actual performance right there.

I personally don&#039;t think Java is a reasonable choice for desktop apps for a lot of reasons besides just performance (although that&#039;s surely one). Others include the non-standard UI, lack of distribution channel, and cross-platform focus. .net surely pwns Java on all of these. I think that Java is still reasonable on the server side, but I don&#039;t see how it can possibly compete on the client.</description>
		<content:encoded><![CDATA[<p>Funny, I&#8217;ve been thinking about this a lot the past week or so. Here are some things to consider:</p>
<p>* Java does JIT by default. This is going to do inlining, loop unwinding, etc. at runtime. You can help it do it&#8217;s job better if you know (and measure) what it&#8217;s doing.<br />
* garbage collection may run at any time, and totally screw your performance. It is tunable though, and is fairly predictable with not a lot of work.<br />
* a lot of slow Java apps are still a result of bad code &#8211; e.g. creating new Strings instead of using StringBuffer in a loop which may take arbitrarily large input data (this is a general pattern of not reusing objects). This is not only be way slower per-invocation but will also fill up memory and make the garbage collector work harder.</p>
<p>Wikipedia has a pretty decent article, actually &#8211; <a href="http://en.wikipedia.org/wiki/Java_performance" rel="nofollow">http://en.wikipedia.org/wiki/Java_performance</a></p>
<p>However, all that said, Java has some really decent profiling tools, and if you spend time optimizing your critical paths I don&#8217;t think that I/O errors (to take your OutputStream::write() example) are going to have a dramatic effect from VM version to version. There are tons of variables when you&#8217;re installing on systems that you don&#8217;t control, and it gets a lot worse when you&#8217;re talking cross-platform (and not just multiple versions, e.g. kernel for a particular OS).</p>
<p>If you want to make performance improvements, the important thing is to be able to measure the current state and continue to measure as you make changes (e.g. by profiling). The big problem with big C or C++ apps tends to be working around strange platform and toolchain quirks that cause undesirable problems, which having a VM somewhat shields you from as it becomes someone else&#8217;s problem :) This of course makes it harder for _you_ to solve, though; when you&#8217;re compiling the binary you can call a lot more of the shots (which is both good and bad of course).</p>
<p>I&#8217;m not really sure how to measure .net runtime versus java runtime performance. I would not be surprised if only supporting one OS and being able to focus on supporting it&#8217;s version-specific quirks was a lot more productive than what Sun is trying to do :) The way that you can call unmanaged code is much easier and faster in .net (P/Invoke) than in java (JNI), and .net obviously uses native UI elements so that&#8217;s probably going to help user perceived as well as actual performance right there.</p>
<p>I personally don&#8217;t think Java is a reasonable choice for desktop apps for a lot of reasons besides just performance (although that&#8217;s surely one). Others include the non-standard UI, lack of distribution channel, and cross-platform focus. .net surely pwns Java on all of these. I think that Java is still reasonable on the server side, but I don&#8217;t see how it can possibly compete on the client.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

