<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pervasive Code &#187; Python</title>
	<atom:link href="http://www.pervasivecode.com/blog/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pervasivecode.com/blog</link>
	<description>Jamie Flournoy's Software Development Blog</description>
	<lastBuildDate>Mon, 26 Jul 2010 05:29:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Evaluating Future Web Application Technologies</title>
		<link>http://www.pervasivecode.com/blog/2007/11/12/evaluating-future-web-application-technologies/</link>
		<comments>http://www.pervasivecode.com/blog/2007/11/12/evaluating-future-web-application-technologies/#comments</comments>
		<pubDate>Mon, 12 Nov 2007 23:22:30 +0000</pubDate>
		<dc:creator>Jamie Flournoy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[outsourcing]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[strategy]]></category>

		<guid isPermaLink="false">http://www.pervasivecode.com/blog/2007/11/12/evaluating-future-web-application-technologies/</guid>
		<description><![CDATA[Technical Architecture is a Form of Investing. I&#8217;m reminded of this sort of thinking because of recent news from RubyConf 2007.

First, IronRuby joins Ruby.NET in providing a Ruby runtime on .NET. They&#8217;re at different stages of completeness, and building on different .NET runtimes (DLR vs. the regular CLR), but the important point is that Microsoft [...]]]></description>
			<content:encoded><![CDATA[<p>Technical Architecture is a Form of Investing. I&#8217;m reminded of this sort of thinking because of recent news from <a href="http://www.rubyconf.org/">RubyConf</a> 2007.<br />
<span id="more-48"></span><br />
First, <a href="http://www.ironruby.net/">IronRuby</a> joins <a href="http://plas.fit.qut.edu.au/Ruby.NET/">Ruby.NET</a> in providing a Ruby runtime on .NET. They&#8217;re at different stages of completeness, and building on different .NET runtimes (<a href="http://blogs.msdn.com/hugunin/archive/2007/04/30/a-dynamic-language-runtime-dlr.aspx">DLR</a> vs. the regular CLR), but the important point is that Microsoft is investing in dynamic languages. Is it ready for production today? Probably not. But keep an eye on Ruby, Python, and JavaScript if you&#8217;re a .NET developer.</p>
<p>Second, <a href="http://docs.codehaus.org/display/JRUBY/2007/11/02/JRuby+1.1b1+Released">JRuby 1.1b1</a> has been released and as expected is considerably faster (see <a href="http://headius.blogspot.com/2007/11/top-five-questions-i-get-asked.html">item #5 in this link</a>) than the standard &#8220;MRI&#8221; runtime. JRuby joins <a href="http://www.jython.org/">Jython</a> and <a href="http://www.mozilla.org/rhino/">Rhino</a> in providing a JVM-based runtime for a dynamic language, with features designed to help developers mix and match the dynamic language code with Java code.</p>
<p>See the trend here? Python, Ruby, and JavaScript are emerging as the dynamic languages of the future for .NET and Java developers.</p>
<p>The hard work done by Sun and Microsoft to make their VMs work well is being leveraged by the next wave of languages. Threads, high performance I/O, memory management, and portability are all features that are quite expensive to get right, and the .NET and Java platforms have pretty much achieved that at this point. (Piggybacking newer, higher-level languages on these mature runtimes means that you get a mature new language runtime faster than if each language&#8217;s runtime were built from scratch and painstakingly debugged in isolation from the others.)</p>
<p>There are still some hurdles (performance, type safety fears, lack of mass market acceptance, ECMAScript 4 standardization and adoption, etc.), but in 2 or 3 years, things are going to change dramatically in the web application development world. The seeds of this change are already sown, and it&#8217;s just a matter of time. Threads, SQL, OOP, and garbage collection are all features of web application architectures that were initially controversial, but have now met with general acceptance. Dynamic languages are clearly the next step.</p>
<p>Obviously, Java and C# are far from dead, and in 10 years people will still be coding in Java and C#, because as with other languages like C and assembly, the newest and highest-level language isn&#8217;t automatically right for every project. But if you&#8217;re building web applications, most of what your code does falls into the categories of string manipulation, collection operations, or file and socket I/O. Image processing, crypto, full text search, and other CPU-heavy, byte-twiddling features may be part of your application, but you&#8217;re not writing the image scaler, RC4 cipher, or inverted index yourself; those are done in a library, probably written in C, and you&#8217;re just calling it. So your needs are likely to be similar to the sweet spot of dynamic languages: maximum expressivity and the fancy features to let you write clever code, making you productive and making the code as clean and elegant as possible. In other words, they put developer productivity first (lower labor cost and shorter development schedules) at the expense of runtime performance. Since hardware gets cheaper over time but <a href="http://www.laputan.org/mud/mud.html#Forces">code gets uglier over time</a>, this is probably the right choice to make for most web application projects.</p>
<p>Another interesting benefit of layering instead of starting over is that the integration between dynamic languages and Java or CLR languages is much nicer than managed vs. unmanaged code in .NET or, even worse, JNI in Java. That is, it won&#8217;t be a bloody mess to mix and match code, from a technical feasibility standpoint. This matters, because <a href="http://chadfowler.com/2006/12/27/the-big-rewrite">The Big Rewrite</a> is among the <a href="http://www.joelonsoftware.com/articles/fog0000000069.html">Things You Should Never Do</a>. But little bitty rewrites are fine, especially if you have a thorough test suite to help you avoid breaking things. (By the way, dynamic languages are <i>great</i> for writing automated tests.)</p>
<p>Which of these three (JavaScript, Python, or Ruby) is going to be dominant 5 years from now? I don&#8217;t think any of them will be. The dynamic language community is fragmented, and the various vendors and big sponsors of these three languages are fairly entrenched already. Microsoft is investing in all three; Google has standardized on Python and JavaScript to the exclusion of Ruby; Sun has hired the JRuby team; Mozilla is heavily invested in JavaScript; Adobe supports JavaScript in AIR but not Ruby or Python, etc. </p>
<p>In fact, if you encapsulated the glue code sufficiently well, you could mix and match JavaScript, Python, and Ruby in your application, and port your hideous hydra between the JVM and .NET. You would be wasting a lot of effort since the three languages are largely similar, but you could do it. Alternatively, you could create a portability layer between the DLR and the JVM a la WxWindows, and write-once-debug-everywhere in a more productive language than Java.</p>
<p>These are all repugnant ideas, but only because as I write this and as you read this, we probably realize that to attempt this today would be a huge task. But what about in 2010? Probably not so gross. What about an application that could be executed on Silverlight, AIR, Firefox, SWT, and Mono, unmodified? How about a mobile app that runs on smartphones regardless of the runtime (.NET vs. J2SE)? Not gross at all, and not unthinkable if your app is written in JavaScript using some kind of portability layer that doesn&#8217;t exist yet.</p>
<p>In the longer term, JavaScript (a.k.a. ECMAScript 4) is likely to become extremely popular. As far as I know it&#8217;s not quite a perfect fit for Steve Yegge&#8217;s <a href="http://steve-yegge.blogspot.com/2007/02/next-big-language.html">The Next Big Language</a>, but it&#8217;s the closest thing there is, and it has two critical advantages over Ruby and Python that will make it successful: C-family syntax (which makes development tools cheaper to build) and effectively unanimous buy-in from vendors and developers.</p>
<p>So, what about the other dynamic languages that people are using in large numbers today? What&#8217;s going to happen to ActionScript, CFScript, PHP, and VB?</p>
<p>ActionScript and CFScript are pretty close to JavaScript by design; I&#8217;ve read that ActionScript 3 is actually compliant with the ECMAScript 4 draft specfication. It&#8217;s pretty clear that Adobe is betting on JavaScript. In the near future (2 or 3 years) I predict that Adobe will rev its products and support ECMAScript 4 across the board.</p>
<p>PHP and VB.NET/VBScript will hang around for a long time because they&#8217;re approachable and already very popular, but they&#8217;ve already peaked, and will steadily decline as developers switch to C# (on the .NET side) and Rails (on the Linux side), and then JavaScript as soon as a serious web app framework and an ISP-friendly runtime exist. Microsoft will keep investing in VB to keep customers happy; Yahoo will keep investing in PHP because it is so heavily invested in PHP already; new developers will find PHP to be an easy starting point for light duty web development, with tons of documentation and free applications that they can download and hack. But PHP will not inherit the kingdom from C# or Java, and the languages which do achieve mainstream success after C# and Java will do everything that PHP does language-wise, and the market momentum around those languages will make them better than PHP at what PHP does. Developers will ask themselves why they would write the client side and server side in two different languages, especially when the server-side language is more expressive and has better portability and libraries. That&#8217;s not true yet, but it will be in a couple of years. In 5 years or so PHP and VBScript will go the way of Perl CGIs: still used, but by a community a tenth of the size it is today.</p>
<p>What about the new Java-based dynamic language, Groovy? Groovy is interesting, but it&#8217;s too late. The Java mainstream of vendors and developers only recently managed to convince the world of &#8220;serious&#8221; C++ developers that automatic garbage collection and JIT compiled bytecodes can actually work in a high traffic context. The next battle, to promote the dynamic language features that Java lacks but which Groovy brings, will take years to fight. Once a developer makes a decision to not use standard Java, Groovy is on a more or less level playing field with the JVM-hosted versions of Python, JavaScript, and Ruby, but each of those languages has far greater adoption than Groovy, and each of them has greater opportunity for leverage on other runtimes than Groovy. For a Java developer, once the door is opened to other languages, the only advantage Groovy has is that its syntax is familiar. Compare this to JavaScript which web developers also need to know how to use; why learn a third language (Groovy) in addition to Java and JavaScript? Over time the simplicity of coding and debugging in JavaScript on client and server, together with dynamic-language productivity, will overcome the momentum of the Java standard, and web developers using server-side Java now will gradually replace it with JavaScript on the JVM. Conservative attitudes in the mainstream Java community (including Fortune 500 companies and the many offshore development firms that write code for them) will make this take quite a while &#8211; probably 5 years before JavaScript becomes a common part of the architectures that currently use J2EE, and 10 years before Java goes the way of COBOL (maintained forever but not used for new projects).</p>
<p>So in conclusion, keeping an eye on the future value of a technology, including who&#8217;s investing in it and who&#8217;s talking about investing in it, is critical to making your own investments today. In five years you&#8217;re not going to be using the same technology stack that you are today, and your project&#8217;s success and your own salary will be tied in large part to how well you invested today.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pervasivecode.com/blog/2007/11/12/evaluating-future-web-application-technologies/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>J2ME: Write Once, Be Disappointed Everywhere</title>
		<link>http://www.pervasivecode.com/blog/2007/08/19/j2me-write-once-be-disappointed-everywhere/</link>
		<comments>http://www.pervasivecode.com/blog/2007/08/19/j2me-write-once-be-disappointed-everywhere/#comments</comments>
		<pubDate>Mon, 20 Aug 2007 05:37:59 +0000</pubDate>
		<dc:creator>Jamie Flournoy</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[IA]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.pervasivecode.com/blog/2007/08/19/j2me-write-once-be-disappointed-everywhere/</guid>
		<description><![CDATA[We developers and other nerdy folk are used to using strange and klunky applications that do something special, and we&#8217;re used to that trade-off.
Eclipse is an IDE so it&#8217;s hard to imagine it not being baroque and difficult to use, requiring weeks of effort to become productive. JBidWatcher has saved me a lot of money [...]]]></description>
			<content:encoded><![CDATA[<p>We developers and other nerdy folk are used to using strange and klunky applications that do something special, and we&#8217;re used to that trade-off.</p>
<p><a href="http://www.eclipse.org/">Eclipse</a> is an IDE so it&#8217;s hard to imagine it <i>not</i> being baroque and difficult to use, requiring weeks of effort to become productive. <a href="http://www.jbidwatcher.com/">JBidWatcher</a> has saved me a lot of money on eBay so I could probably put a dollar value on how much it&#8217;s worth to endure its bizarre UI. <a href="http://azureus.sourceforge.net/">Azureus</a> is fairly fugly also but it does a very good job and has a deep, sophisticated UI that&#8217;s fairly easy to understand, so despite the eyesore, it&#8217;s at least fairly clear. The common thread among all of these is that they are all written in Java, and that they are so valuable that it&#8217;s worthwhile to overlook the ugly UIs.</p>
<p>Now imagine those sorts of trade-offs, but on already difficult to use mobile devices, and aimed at consumers. Are you making a strategically wise choice by sacrificing usability and control over the user interface, and probably access to platform-specific features such as dialing the phone, in order to save money on development? Adam Breindel talks about this in <a href="http://skipmeamadeus.blogspot.com/2007/08/when-building-smartphone-app-resist.html">When Building a Smartphone App, Resist the Siren Song of J2ME</a>.<br />
<span id="more-42"></span></p>
<p>Adam and I worked on a J2ME application and I totally agree with him about the disillusionment of trying to write a single app that would work across phones. Issues include:</p>
<ul>
<li>Complex and difficult application installation procedures for end-users: How do you install the JVM on the phone? How do you get the plain J2ME app packaged up so that the phone will accept it? Does the app require manual user configuration before use? Is there a different launching process from other apps?</li>
<li>Lack of control of the user interface: hardware details such as how many buttons you have, whether there&#8217;s a stylus, etc. differ from phone to phone, and the API to let you code once and let J2ME handle the layout for each device leaves your code very disconnected from what&#8217;s actually happening on the screen.</li>
<li>Not being able to use recent J2ME APIs because even the latest phones only support older, more minimal J2ME APIs</li>
<li>Not being able to do things on a phone that would seem obvious, like dialing the phone, opening a hyperlink in the phone&#8217;s browser, sending an SMS, or making a network connection. Either these are entirely impossible or require phone-specific or JVM-specific tools and procedures to sign your application, or having the runtime nag the user to request permission to do something that they just asked the app to do for them.</li>
</ul>
<p>For all the noise Sun is making about broad J2ME penetration, the developer experience is quite disappointing, and as a result, the user experience is also quite disappointing. You can look up J2ME features and APIs and get excited, but when you actually deploy your app to a handset, it won&#8217;t load, or runs terribly slowly, or looks awful, or simply doesn&#8217;t do the things that the API says will happen when you call it a certain way. Suddenly the strict J2SE and J2EE logo certification programs make sense, because the J2ME approach of making so much functionality specified but optional leaves developers high and dry. The phone supports J2ME version xyz, but write an app coded to that API that works on the emulator and deploy it to a handset and lo and behold, all those optional APIs turn out to be missing even though the handset is capable of that functionality, and <i>some mandatory API functions are not working</i>. <a href="http://en.wikipedia.org/wiki/Here_be_dragons">Here be dragons</a>.</p>
<p>Case in point: can&#8217;t dial the phone on a Treo 650 (at least, not as of a year ago). The J2ME API tells you how to do it. The PalmOS JVM (made by IBM) lets you make the API call, and returns a successful response. Nothing happens. IBM says they&#8217;re aware of this issue. The end. The docs say you can, the code you write says you did, the phone just doesn&#8217;t do it.</p>
<p>Case in point: Every time you start an application and it accesses the network for the first time on a Treo 650, the user is nagged for permission to access the network. Quit the app and start again, nagged again. IBM has a tool that you can use to sign the app, but you have to use their VisualAge Micro Edition IDE which costs hundreds of dollars to do that. Try and find and download the trial version. A year ago, it was not possible. So, making that persistent nag go away probably costs several hundred dollars. (I never verified that it actually works, just that IBM says the way to sign the app so that it&#8217;s trusted is to do that, and that there was no available free way to get that tool.)</p>
<p>These are minor issues, but they certainly interfere with the quick usage pattern of a mobile app, and make it annoying to use your app. Imagine what that would be like if you had a competitor with a native application for that phone, whose application probably cost them more, but their app is better and the user likes it a lot more.</p>
<p>The important distinction here is not cost, it&#8217;s ROI. It costs a lot to develop a similar application for each smartphone platform, using that platform&#8217;s native tools. It would seem to cost a lot less to develop a J2ME app. But that&#8217;s only if you assume that it&#8217;s OK to abandon features and settle for a horrid user experience in the course of development.</p>
<p>It&#8217;s likely that your goal as a development team is to develop an app that has a predefined feature set that you know the device can support, and a predefined UI design that your mobile-savvy UI people are sure will go over well with users accustomed to that particular kind of smartphone. In that case you will almost certainly fail to accomplish that goal using J2ME. You have to scale back your goal so that you&#8217;re satisfied that you got something kinda like what you wanted working on a bunch of phones, and determined users will probably be able to figure out how to install it and make it work.</p>
<p>I call that phenomenon &#8220;write once, be disappointed everywhere.&#8221;</p>
<p>Let&#8217;s continue talking about cost, though. The native apps may require (or suggest) different programming language skills for different devices. It might seem wise to just write everything in C, but I think that&#8217;s a false economy as well. The phone APIs will differ so much that you will really need a native developer for each platform, not a team of generic C developers who will figure out the individual phone stuff and be freely floating resources that you can assign to whatever app version needs their attention. Smartphones may run Linux, may run Windows Mobile, may run PalmOS, may run Symbian&#8230; these are different operating systems with very different ideas of how applications run and coexist. The platform specific knowledge (APIs, appropriate UI feel, device capabilities) is probably an order of magnitude harder to learn and maintain than the ability to get an application working in a given programming language.</p>
<p>How much of a great C programmer&#8217;s skill is really the C language, and how much of it is proficiency with the available libraries on the platform he or she is accustomed to? I think close to 90% of their professional skill set is platform and library familiarity, and 10% syntax and low-level understanding of how the language actually works.</p>
<p>In light of this (just using C doesn&#8217;t mean developers or code are portable across smartphones), consider that there are high level languages available for some smartphones. What if that 90% platform familiarity means they can use a language and/or development environment that makes them 5 or 10 times as productive, after spending just a few days or a couple of weeks learning the language syntax?</p>
<p>After our very disappointing J2ME-on-PalmOS port experience, Adam found <a href="http://www.handheld-basic.com/">Handheld Basic</a> which initially appalled me (oh no, BASIC!) but turned out to be a great choice. It&#8217;s a flavor of BASIC, so learning the language didn&#8217;t take long, and the support happens to be quite good (<i>lots</i> of code samples) so picking up the library portion of that 90% didn&#8217;t take long at all. I imagine that C# on Windows Mobile is similar. As more and more phone start to use Linux as their OS (which will be a particularly huge improvement for PalmOS based phones), you&#8217;ll be able to use Python, Ruby, Mono, J2SE (a whole different animal from J2ME), TCL, or pretty much any other high level language available for Linux. At LinuxWorld 2006 I saw a development device running unmodified GNOME desktop apps running on a PalmOS device alongside PalmOS apps. There are more options appearing all the time, and with the exception of Handheld Basic, most of them are ports of familiar, mature, well understood desktop languages, with class libraries relevant to mobile devices.</p>
<p>So, I recommend that you work in whatever high level language lets you do all the platform specific stuff you want, and if that means a different language per phone, that&#8217;s actually going to be the least expensive way to get to the apps you actually wanted to build. A big chunk of the scary cost of developing native apps goes away, because native doesn&#8217;t necessarily mean abandoning Java for C. (In fact I found Handheld Basic to be a more productive environment for me after a couple of weeks than J2ME was, despite my ~8 years of full time Java experience before starting that project.)</p>
<p>That pretty much means no reuse for you. Sorry, but that&#8217;s the deal right now.</p>
<p>If that unique-app-per-platform cost is too scary, consider a few ways to save money:</p>
<ul>
<li>For networked apps (aren&#8217;t they all?) ask yourself if there&#8217;s some logic that could just as easily be done on the server as on the client. Is there some complicated parsing code on the client that could be simplified by changing the response format from the server to something that&#8217;s easier to parse?</li>
<li>Can you remove or alter certain features from a subset of platforms you intend to support, so that your premium supported platforms get your ideal app, whereas a few less popular phones still get a nice app, but perhaps one that doesn&#8217;t have every feature available on your premium app. You might be reading this and thinking &#8220;but that&#8217;s what you said J2ME would force me to do! Why is this any better?&#8221; The distinction is that you are in control of the decision of what to leave out to save money, whereas with J2ME it&#8217;s the platform vendor who makes that decision for everyone using their platform. If you&#8217;re writing an address book, not being able to dial the phone is lethal; not writing the code to let the user attach a photo to the entries is not.</li>
<li>Can you move some user-facing functionality to the server to make the client simpler? Maybe there are some rarely-used features that could be done via a desktop or mobile web browser, so you can focus on putting the ten-times-a-day features on the handset, and making those features fast and convenient. You probably already made that trade-off in general, but perhaps for some kinds of handset, you&#8217;ll move the dividing line a little further, so that for users of particularly rare phones, some moderately frequent features can&#8217;t be done on the phone. This could also be a good approach for new handset types: design a &#8220;lite&#8221; app and a &#8220;full&#8221; app version, build the &#8220;lite&#8221; app first on each platform, and let user demand tell you whether the full app is worth it. Your developers can tell you much more accurately how much the incremental functionality would cost, since they already have done the lite version. Maybe you&#8217;d provide a VoiceXML interface, or mobile web browser interface, for that feature so that the user can still do whatever the feature requires while they&#8217;re far from a desktop PC.</li>
</ul>
<p>A final consideration: labor. Maybe you have some Java developers, or C developers, and don&#8217;t have developers good at Handheld Basic or C#, so you&#8217;re not inclined to fire them all and hire new developers to do native apps, you&#8217;re thinking maybe C on every handset, or J2ME, is still the right choice. I still say that you should probably use native apps in native high level languages on every smartphone platform. If you&#8217;re committed to a strategy of good apps on a bunch of different phones, I think I&#8217;ve made clear that native apps are the only way to currently get there; J2ME simply doesn&#8217;t let you make good apps. So what&#8217;s left is C code written by C developers vs. high level code written by C developers who have to retrain.</p>
<p>As I said above, I don&#8217;t see much chance that your developers or your code will be portable across different smartphones if you use C. Maybe you&#8217;ll get 5-10% savings that way (some code ported across phones, or some developer hours shuffled between platform teams). But you&#8217;d get a 5-10x cost saving from using something very modern and high-level instead of C, and the overhead of training for the language would be very very small as compared to the large and unavoidable overhead of having to learn what the handsets can do and how the APIs for the handset&#8217;s OS work.</p>
<p>I suppose that means that if you have a bunch of C developers who lack smartphone skills, you&#8217;re in a pickle, but that situation seems kind of unlikely to me (a mobile app company hires a bunch of Unix and Win32 C developers with no mobile phone skills?). More likely is that you&#8217;d find a mobile developer who is proficient with one or more handset OSs and the best tools for each one, and they may be of the opinion that C is the best choice since they can reuse skills and some code across platforms. I would say that in that case you need to convince them to (or more likely encourage them to do what they were already considering, which is to) go ahead and find a highly productive high level programming language/environment for each smartphone platform.</p>
<p>A final possibility if you have a ton of platforms to target and a pile of killer C programmers is to try and port something like Python across most of your target platforms, or to make a very high-level API or domain-specific language that runs inside your own custom C portability layer. You might be able to find an open source option that you can invest some developer hours in, so that the actual application-specific code that you write on each platform is minimized and portable. But I suspect that this would still be expensive and would result in some J2ME-like UI abstractions that ended up being very unsatisfying in the end.</p>
<p>Best of luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pervasivecode.com/blog/2007/08/19/j2me-write-once-be-disappointed-everywhere/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>&#8220;Ruby faster than Python and Perl!&#8221; ORLY?</title>
		<link>http://www.pervasivecode.com/blog/2007/08/16/ruby-faster-than-python-and-perl-orly/</link>
		<comments>http://www.pervasivecode.com/blog/2007/08/16/ruby-faster-than-python-and-perl-orly/#comments</comments>
		<pubDate>Thu, 16 Aug 2007 23:05:46 +0000</pubDate>
		<dc:creator>Jamie Flournoy</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.pervasivecode.com/blog/2007/08/16/ruby-faster-than-python-and-perl-orly/</guid>
		<description><![CDATA[Ruby faster than Python and Perl! cries the headline. This is based on a benchmark that tests &#8220;i = i + 1&#8221; in a loop, so it&#8217;s a particularly useless benchmark, even in a world of benchmarks designed to test unrealistic scenarios that make the benchmark author&#8217;s product look good.

But wait! A commenter accuses the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://smyck.de/2007/08/15/ruby-faster-than-python-and-perl/">Ruby faster than Python and Perl!</a> cries the headline. This is based on a benchmark that tests &#8220;<code>i = i + 1</code>&#8221; in a loop, so it&#8217;s a particularly useless benchmark, even in a world of benchmarks designed to test unrealistic scenarios that make the benchmark author&#8217;s product look good.<br />
<span id="more-41"></span><br />
But wait! A commenter accuses the poster of cheating! (On a benchmark? No!)<br />
<em>&gt;Ummm…. Why did you test Ruby with less data than you tested Python and Perl? You cheated.<br />
</em><br />
As it turns out, the &#8220;microbenchmark&#8221; scripts for different languages have differing loop counts, so the total run time is super extra especially meaningless as a way to compare language performance.</p>
<p>When I was in 5th grade (age 9) learning AppleSoft BASIC on the Apple ][+ in math class, we wrote programs that did this:<br />
<code>10 X = 1<br />
20 PRINT X<br />
30 X = X +1<br />
40 GOTO 20</code><br />
And we would race each other, starting at the same moment and seeing whose column of increasing numbers on the screen scrolled faster. This was of course stupid because all the computers in the lab were chip-for-chip identical to each other, and probably were all made on the same production run on a single day.</p>
<p>We learned that we could cheat by adding a number larger than one in each loop iteration, which was quickly detected and outlawed. Far more cleverly, someone figured out that you could do something like this:<br />
<code>20 PRINT X: X = X + 1: GOTO 20</code><br />
The same algorithm yielded better performance if it was all written on one line of code. I could be misremembering (it has been 25 years and I don't have a ][+ handy to verify this on) but it was something like that. Anyway, we learned that the same language runtime on identical hardware using the same algorithm could be made to run faster or slower using simple formatting changes.</p>
<p>So does it make sense to compare different languages this way, which may mean favoring one language's idiomatic code structure while hitting a weak spot of another? This is a common, and in my opinion valid, critique of apples-vs-oranges benchmarks: how do we know that the performance difference isn't due to naive coding or configuration on one side and expert tuning on the other side? For that matter, do we know that the benchmark design isn't selected specifically to highlight exceptionally high performance in one area of a product, to the exclusion of embarassingly slow areas that the benchmark designer would prefer that you not consider?</p>
<p>Thus I claim that this benchmark is approximately as valuable as my 5th grade silly hacks. X=X+1, change the number of iterations to suit your bias, or perhaps just don't bother making them the same because it's meaningless anyway. (Z=X*Y and a matrix multiplication are other parts of this benchmark, but they too are so trivial in concept and implementation as to be equally pointless.)</p>
<p>I'm going to guess that the author of the blog post didn't notice the different in loop iterations, or was looking at the per-second values rather than the total run time. But if we're looking at average performance over time, then how long does it take for the performance to stabilize? <strong>Stabi-<a href="http://www.penny-arcade.com/comic/2007/03/30">whatchamaha</a></strong>? Ask <a href="http://www.zedshaw.com/rants/programmer_stats.html">Zed Shaw</a>: look at his list of pet peeves, #3.</p>
<p>Do we know that 0.142 seconds is enough to measure &#8220;language performance&#8221; (really, it&#8217;s the performance of a particular runtime environment being measured) including stuff like garbage collection and JIT compilation overhead? If one language&#8217;s runtime waits for N iterations before JIT-compiling the code, whereas another runtime waits for 5N, how many total iterations do you need to minimize the effect of that?</p>
<p>What happens in JRuby, Ruby2C, etc.? The poster says the tests were run on a MacBook Pro &#8211; what architecture (PPC vs. Intel) were these language runtimes compiled for, with what compiler, blah blah. GCC versions, optimized for certain CPU models, etc. This stuff can make a big difference in CPU benchmarks, which is why proper benchmarks include things like this in their configuration information.</p>
<p>Or are you measuring small script execution time, and >1s runtimes are meaningless for your needs, in which case Java seems painfully slow and Bash lightning fast?</p>
<p>What the heck <em>is</em> being measured by this &#8220;microbenchmark&#8221;? Language fanboy gullibility?</p>
<p>For a less awful benchmark, have a look at the <a href="http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&amp;lang=all">Computer Language Benchmarks Game</a>: &#8220;What fun! Can you manipulate the multipliers and weights to make your favourite language the best programming language in the Benchmarks Game?&#8221; At least they realize how not-terribly-useful synthetic CPU benchmarks of language runtimes are.</p>
<p>Anyway, for most applications, if you&#8217;re choosing your language based on runtime performance, you&#8217;re choosing very poorly. If you&#8217;re choosing your language based on a really awful &#8220;microbenchmark&#8221; comparable in accuracy to the first toy hack of a room full of 9-year-olds, well&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pervasivecode.com/blog/2007/08/16/ruby-faster-than-python-and-perl-orly/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
