<?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>code zen &#187; Programming</title>
	<atom:link href="http://www.arpitonline.com/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.arpitonline.com/blog</link>
	<description>"I write pretty software"</description>
	<lastBuildDate>Sun, 25 Jul 2010 22:23:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Thank you Apple, May I have another&#8230;not!</title>
		<link>http://www.arpitonline.com/blog/2010/04/08/thank-you-apple-may-i-have-another-not/</link>
		<comments>http://www.arpitonline.com/blog/2010/04/08/thank-you-apple-may-i-have-another-not/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 23:34:38 +0000</pubDate>
		<dc:creator>arpit</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.arpitonline.com/blog/?p=530</guid>
		<description><![CDATA[Word on the street:

Apple&#8217;s new wording on the iPhone SDK disallows cross compiling iPhone apps, like the Adobe Flash CS5 IDE was doing.
Other cross compiler solution vendors like Appcelerator,  Unity and Phone Gap are not sure what this means for them. Appcelerator&#8217;s blog goes down because of dev traffic.
Flash community pretty vocal about this:

Peter Elst: [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 20px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.arpitonline.com%2Fblog%2F2010%2F04%2F08%2Fthank-you-apple-may-i-have-another-not%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.arpitonline.com%2Fblog%2F2010%2F04%2F08%2Fthank-you-apple-may-i-have-another-not%2F" height="61" width="51" /></a></div><div>Word on the street:</div>
<ul>
<li>Apple&#8217;s new wording on the iPhone SDK <a href="http://daringfireball.net/2010/04/iphone_agreement_bans_flash_compiler">disallows cross compiling iPhone app</a>s, like the Adobe Flash CS5 IDE was doing.</li>
<li>Other cross compiler solution vendors like <a href="http://www.appcelerator.com/">Appcelerator</a>,  <a href="http://unity3d.com/">Unity </a>and <a href="http://phonegap.com/">Phone Gap</a> are not sure what this means for them. Appcelerator&#8217;s blog goes down because of dev traffic.</li>
<li>Flash community pretty vocal about this:
<ul>
<li>Peter Elst: <a href="http://www.peterelst.com/blog/2010/04/09/apple-versus-developers-this-time-its-personal/">Apple vs Developers: This time its personal</a></li>
<li>Kevin Suttle: <a href="Apple Reaffirms Control Issues with iPhone 4">Apple Reaffirms Control Issues with iPhone 4</a></li>
<li>Adobe Platform evangelist Lee Brimelow: <a href="http://theflashblog.com/?p=1888">Apple Slaps Developers in the Face</a></li>
<li>Hey a new <a href="http://twitter.com/#search?q=fuckapple">twitter hashtag</a> is born</li>
</ul>
</li>
<li>The larger developer community calls the BS on <a href="http://news.ycombinator.com/item?id=1250799">Hacker News</a> and <a href="http://www.reddit.com/r/programming/comments/bobrx/new_iphone_developer_agreement_bans_the_use_of/">Reddit</a></li>
<li>Adobe will still release CS5 on 12th April as planned</li>
<li>Reasons continue to pile up on why the Apple eco system has started to feel so stifling:
<ul>
<li>Book apps <a href="http://www.marco.org/500743718">cannot use Screen Brightness APIs</a>, so iBooks looks like such a better app.</li>
<li>AppStore <a href="http://www.appleinsider.com/articles/10/04/07/apple_rejected_ipad_app_for_using_pinch_to_expand_gesture.html">rejects app</a> because developer implements (from the ground up) a UI feature thats too close to forbidden iPad gesture (seriously? A forbidden gesture?)</li>
<li>You cannot use <a href="New iPhone Developer Agreement Bans the Use of Third-Party Analytics and Services">third party analytics or geo-targeted ad systems</a></li>
</ul>
</li>
</ul>
<p>The Daring Fireball post talks about how Adobe is screwed now. I dont know about the financial implications, but if nothing else, the CS5 cross compiler has definitely proven how the exclusion of certain runtimes has nothing to do with performance but is a pure power play.</p>
<p>In other news, I am now looking for the cheapest way to get a Nexus 1. Could Adobe and Google please set up something for us refugees from the big A dictatorship?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arpitonline.com/blog/2010/04/08/thank-you-apple-may-i-have-another-not/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Google AppEngine App issues on Snow Leopard</title>
		<link>http://www.arpitonline.com/blog/2009/11/27/google-appengine-app-issues-in-snow-leopard/</link>
		<comments>http://www.arpitonline.com/blog/2009/11/27/google-appengine-app-issues-in-snow-leopard/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 23:23:25 +0000</pubDate>
		<dc:creator>arpit</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.arpitonline.com/blog/?p=414</guid>
		<description><![CDATA[I always seem to trip up on these language version issues. I spent way too much time on this so, as usual with such things, I thought it was worth a post. Early this week I upgraded my work machine (MacBook Pro) and the new machine came packed with Snow Leopard. Today, I had some [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 20px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.arpitonline.com%2Fblog%2F2009%2F11%2F27%2Fgoogle-appengine-app-issues-in-snow-leopard%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.arpitonline.com%2Fblog%2F2009%2F11%2F27%2Fgoogle-appengine-app-issues-in-snow-leopard%2F" height="61" width="51" /></a></div><p>I always <a href="http://www.arpitonline.com/blog/2009/09/10/migrating-to-java-1-6-warning-flex-buildereclipse-wont-work-with-it/">seem to trip up</a> on these language version issues. I spent way too much time on this so, as usual with such things, I thought it was worth a post. Early this week I upgraded my work machine (MacBook Pro) and the new machine came packed with Snow Leopard. Today, I had some free time so I figured I&#8217;d modify this &#8220;lab&#8221; project that a few of us worked on at Comcast Interactive Media a few months ago.</p>
<p>I use the GoogleAppEngineLauncher application to start/stop the apps and it seemed to launch fine once I had the code checked out from SVN. However one part of the application, which loaded some remote data and stored it in the DataStore didnt seem to work anymore. Stilling digging through what could have gone wrong, I ended up isolating the issue with the invocation of urllib2. Looking through <a href="http://code.google.com/appengine/docs/python/urlfetch/overview.html">Google&#8217;s documentation</a>, I tried switching to URLFetch which fixed that part. But a couple of lines later, I tripped over another issue. This time the error was a lot more explicit with some message mentioning a missing __init__ in the 2.6 version of Python. So I tried switching the Python location in the /usr/bin/python to the 2.5 version but that didn&#8217;t work. Turns out to switch the Python version on the launcher, you have to set the value in the Preferences panel for the application as mentioned <a href="http://code.google.com/p/google-appengine-mac-launcher/issues/detail?id=4#c0">here</a>. Ta daa! That worked. </p>
<p>Note, if you are using the command line dev_appserver.py script to run your application, check out this post <a href="http://www.buildcontext.com/blog/2009/05/03/problem-problems-google-app-engine-on-ubuntu-9-04-jaunty-jackelope-python/">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.arpitonline.com/blog/2009/11/27/google-appengine-app-issues-in-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Dispelling the FUD! Silverlight is NOT on the iPhone!</title>
		<link>http://www.arpitonline.com/blog/2009/11/26/dispelling-the-fud-silverlight-is-not-on-the-iphone/</link>
		<comments>http://www.arpitonline.com/blog/2009/11/26/dispelling-the-fud-silverlight-is-not-on-the-iphone/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 21:38:19 +0000</pubDate>
		<dc:creator>arpit</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.arpitonline.com/blog/?p=410</guid>
		<description><![CDATA[This is crazy, do any of these bloggers actually read the announcements? My Twitter/RSS-feed streams are clogged with Silverlight on the IPhone items like here, here and here, and thats just not the case. So lets please get the facts right: Silverlight IS NOT on the iPhone. Or rather the browser plugin called Silverlight isnt. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 20px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.arpitonline.com%2Fblog%2F2009%2F11%2F26%2Fdispelling-the-fud-silverlight-is-not-on-the-iphone%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.arpitonline.com%2Fblog%2F2009%2F11%2F26%2Fdispelling-the-fud-silverlight-is-not-on-the-iphone%2F" height="61" width="51" /></a></div><p>This is crazy, do any of these bloggers actually read the announcements? My Twitter/RSS-feed streams are clogged with Silverlight on the IPhone items like <a href="http://www.infosyncworld.com/news/n/10678.html">here</a>, <a href="http://www.betanews.com/article/Microsoft-worked-with-Apple-for-Silverlight-on-iPhone-says-Goldfarb/1259185079">here</a> and <a href="http://9to5mac.com/silverlight-on-iPhone-35435">here</a>, and thats just not the case. So lets please get the facts right: Silverlight IS NOT on the iPhone. Or rather the browser plugin called Silverlight isnt. </p>
<p>Here are the facts. Microsoft User Experience Platform Manager Brian Goldfarb stated:</p>
<p>&#8220;We&#8217;re translating the content to support the MPEG2 v8 [decoder] format that the iPhone format; we&#8217;re moving it to their adaptive streaming format. So it&#8217;s the same IIS smooth streaming content, the same server, the same point of origin, but now I can get that content to play without any code changes, without any real work, on the iPhone. That&#8217;s the critical thing for our customers.&#8221;</p>
<p>Microsoft, Adobe and Apple have all proprietary adaptive streaming formats. For a better understanding read this article on <a href="http://newteevee.com/2009/06/10/the-lowdown-on-apples-http-adaptive-bitrate-streaming/">Apple&#8217;s adaptive streaming</a> on NewTeeVee. </p>
<p>Now in all honesty, thats cool. So you place a bit of video that silverlight can adaptively stream and if an iphone requests that, IIS will handle that as well. I am not sure but Adobe&#8217;s solution may need the Flash Communication Server to step in. But the perception of &#8220;free&#8221; only works if you are resigned to use IIS anyway, which I am sure a lot of Silverlight shops are anyway. But there is that difference. </p>
<p>However the titles of the posts I read and the followup comment are so WRONG. Silverlight isnt on the iPhone, video that Silverlight could play now plays on the iPhone. </p>
<p>Crazy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arpitonline.com/blog/2009/11/26/dispelling-the-fud-silverlight-is-not-on-the-iphone/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Migrating to Java 1.6 on a Mac (Warning: Flash CS3/Flex Builder/Eclipse wont work with it)</title>
		<link>http://www.arpitonline.com/blog/2009/09/10/migrating-to-java-1-6-warning-flex-buildereclipse-wont-work-with-it/</link>
		<comments>http://www.arpitonline.com/blog/2009/09/10/migrating-to-java-1-6-warning-flex-buildereclipse-wont-work-with-it/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 05:16:24 +0000</pubDate>
		<dc:creator>arpit</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.arpitonline.com/blog/?p=326</guid>
		<description><![CDATA[[Update: Changed the title, added "on a Mac" because everything mentioned here is applicable to that platform alone]
After not looking at it for 4 years, today I started playing with Java again for a new open source project called RedCar, a programmers text editor that is now being ported to SWT and JRuby. Mat is [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 20px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.arpitonline.com%2Fblog%2F2009%2F09%2F10%2Fmigrating-to-java-1-6-warning-flex-buildereclipse-wont-work-with-it%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.arpitonline.com%2Fblog%2F2009%2F09%2F10%2Fmigrating-to-java-1-6-warning-flex-buildereclipse-wont-work-with-it%2F" height="61" width="51" /></a></div><p>[Update: Changed the title, added "on a Mac" because everything mentioned here is applicable to that platform alone]</p>
<p>After not looking at it for 4 years, today I started playing with Java again for a new open source project called <a href="http://redcareditor.com/">RedCar</a>, a programmers text editor that is now being ported to SWT and JRuby. <a href="http://matschaffer.com/">Mat</a> is getting pretty involved in it and he got me curious about the project. However to actually get it to work I had to get the Java 1.6 code to compile on my Mac which was a little tricky. Here are some notes from that.</p>
<p>The JDK 1.6 was part of one of the recent Mac Software updates but what I found out was that the update does not actually change the default JDK/JRE for the system. The first thing I did was to change the symlinks for java and javac as mentioned on <a href="http://blogs.sun.com/cmar/entry/java_1_6_finally_available">this post</a>. That seemed to work and calling java &#8211; version and javac -version seemed to return the correct versions, but running the build file still did not work. After a few other attempts, including trying the <a href="http://note19.com/2008/05/04/how-to-change-the-default-version-of-jdk/">Java Preferences Application</a> without any luck, I finally found <a href="http://memerocket.com/2009/08/06/upgrade-os-x-10-5-8-to-jdk-1-6/">this post</a> that basically talked about the CurrentJDK symlink that apparently my build.xml was using (and was still pointed to JDK 1.5). That seems to have worked. </p>
<p>One last thing. Apparently Eclipse (and Flex Builder which is built on top of Eclipse) doesnt work with Java 1.6 on a Mac. As <a href="http://blog.kischuk.com/2008/05/08/running-eclipse-on-macbooks-with-java-6/">this post suggests</a>, you may have to make a change to the Info.plist for the application to make it run with Java 1.5.</p>
<p>[Update] The Flash CS3 IDE doesnt work with 1.6 as well, so I am reverting back to 1.5 for the time being. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.arpitonline.com/blog/2009/09/10/migrating-to-java-1-6-warning-flex-buildereclipse-wont-work-with-it/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Object Oriented JavaScript Techniques</title>
		<link>http://www.arpitonline.com/blog/2009/07/24/object-oriented-javascript-techniques/</link>
		<comments>http://www.arpitonline.com/blog/2009/07/24/object-oriented-javascript-techniques/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 20:06:29 +0000</pubDate>
		<dc:creator>arpit</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.arpitonline.com/blog/?p=276</guid>
		<description><![CDATA[This post is in response to a couple of conversations I had with some friends around OOP in JavaScript. Over the last couple of months I have gotten really deep into the language with JQuery (which is a fantastic library by the way) so I thought I&#8217;d quickly list some techniques I have been using [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 20px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.arpitonline.com%2Fblog%2F2009%2F07%2F24%2Fobject-oriented-javascript-techniques%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.arpitonline.com%2Fblog%2F2009%2F07%2F24%2Fobject-oriented-javascript-techniques%2F" height="61" width="51" /></a></div><p>This post is in response to a couple of conversations I had with some friends around OOP in JavaScript. Over the last couple of months I have gotten really deep into the language with JQuery (which is a fantastic library by the way) so I thought I&#8217;d quickly list some techniques I have been using to structure my JavaScript code.</p>
<p><u><strong>Creating a very simple class with an instance variable:</strong></u><br />
JavaScript has no concept of classes but they can be mimic-ed by creative uses of the Function object. So for example this is completely valid:</p>
<p><code></p>
<pre>
var vanillaFunction = function(){
	this.name = "vanilla"
}
var instance = new vanillaFunction();
alert(instance.name) //	vanilla
</pre>
<p></code><br />
In the above case, &#8220;name&#8221; becomes an instance variable of the vanillaFunction class. </p>
<p><u><strong>Constructing instance methods</strong></u><br />
<code></p>
<pre>
var vanillaFunction = function(){
	this.name = "vanilla";
	this.sampleMethod = function(){
		return "SampleMethod was called";
	}
}

var instance = new vanillaFunction();
alert(instance.sampleMethod())
</pre>
<p></code></p>
<p>Under the hood whats going on is that the JavaScript interpreter is attaching the Function objects to the vanillaFunction&#8217;s prototype chain. So to add another function, we can append that function right on the prototype:</p>
<p><code></p>
<pre>
vanillaFunction.prototype.getName() = function(){
	return this.name; // returns "vanilla"
}
</pre>
<p></code></p>
<p>Note that these functions have access to the name instance variable defined in the main vanillaFunction class.</p>
<p><u><strong>Creating class variables and methods (kinda):</strong></u><br />
Since all functions are essentially Objects, variables can be tagged on to the function object and then referenced as static class variables.</p>
<p><code><br />
vanillaFunction.classVar = "some value here";<br />
</code></p>
<p>Same way, static functions can be created as well:</p>
<p><code></p>
<pre>
vanillaFunction.staticFunction = function(){
	alert("static function called");
}
</pre>
<p></code></p>
<p>However it should be noted that the static variables and methods do not have access to each other unless explicitly passed during invocation. Personally, I hardly ever use this and prefer static classes as shown below.</p>
<p><u><strong>Creating Static classes:</strong></u><br />
A static class is one you can never create a new instance of. For example, instead of having static methods in a JavaScript class, you can create a static class by declaring your functions as variables on a pure JavaScript Object. This method can be used for example for creating a class of utility functions:</p>
<p><code></p>
<pre>
var utils = {
	trim:function(str, numCharacters){
		return str.substring(0, numCharacters);
	},

	log:function(msg){
		if(console){
			console.log(msg);
		}
	}
}
var s = utils.trim("Good day to you sir", 4);
</pre>
<p></code></p>
<p><u><strong>Creating classes with JQuery</strong></u><br />
To create a class with JQuery, we use the jQuery.extend function which pretty much adds the instance methods to the prototype chain as we saw before:</p>
<p><code><br />
MyClass = function(){<br />
	this.title = "MyClass";<br />
};</p>
<p>$j.extend(MyClass.prototype, {<br />
	toString:function(){<br />
		return this.title;<br />
	}<br />
});<br />
</code></p>
<p><u><strong>Events:</strong></u><br />
Even though the ECMAScript specification defines events and how they work, they are not implemented consistently across browsers. The JQuery event system is much nicer since a) it works cross-browser and b) the event source doesn&#8217;t necessarily have to be a DOM element. </p>
<p><code><br />
var obj = {name:"SimpleObj"};<br />
jQuery(obj).bind("objectChanged", listener);<br />
jQuery(obj).bind("objectChanged", listener);<br />
jQuery(obj).trigger({type:"objectChanged"});<br />
</code></p>
<p>In the above example, we are binding to a custom event of type objectChanged. Usually, I access the event type as a static class variable:</p>
<p><code><br />
var CustomEvents = {<br />
	OBJECT_CHANGED:"objectChanged";<br />
}<br />
jQuery(obj).bind(CustomEvents.OBJECT_CHANGED, listener);<br />
</code></p>
<p>That covers pretty much the basics oF OOP in JavaScript. A lot of metaphors (like private/protected/public accessors) may be missing here but I havent really found that to be too much of a problem. These metaphors have made my code a lot more manageable.</p>
<p><strong>Further reading:</strong><br />
<a href="http://ejohn.org/apps/learn/">John Resig&#8217;s list of lessons in advanced JavaScript</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.arpitonline.com/blog/2009/07/24/object-oriented-javascript-techniques/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
