My 2013 In Books

books

 

Thanks for keeping track of this Goodreads

Rethinking GUI Programming Paradigms

I have to say the current state of programming and application development do bother me. I feel after so many years of programming, making things like desktop applications and web applications should be a lot easier.  Over the last few years I have done a lot of application development in a bunch of technologies like Java, SWT, Flash, HTML/JS and more recently Objective C. And yet our development environments (or IDEs) are pretty much the same as 20 years ago with vi or emacs. I have a lot of friends who have really good ideas and yet they are pretty daunted by the idea that they could build their applications themselves, and I dont blame them. Most of the advice programmers give them is to read a couple of books and download Textmate.

Their have been a lot of “GUI builder” applications over the years and pretty much all of them have been panned by “real” developers. The usual (and often justified) reason has been that they generate crappy code. Its shocking to me why GUI development remains such an afterthought in todays world.

Did Flash get it right?

Like it or hate it, Flash was probably one of the first tools that got it somewhat right. Its success and now the reason it gets panned, is because it made it very approachable for someone who was not a programmer to get something in their mind out on the internet. The ability to draw a shape and then attach some behavior to it in code was huge.

This was my path to it too. I came to the US persuing my graduate degree in VLSI Engineering (chip design). Somehow I got a job at a University Learning Center with a very loose mandate: the director of the center had a lot of ideas on e-learning with video and had just seen some Flash video sites and was fascinated (remember Flash video only came around in version 6 of Flash). My role was to “make something cool for e-learning and video”. I had never programmed before but had some experience with Flash animation, mostly making small animated movies hoping to get on Atom Films someday.

In about 6 months I had gotten really addicted to Flash since for the first time, my animations could respond to the user. Because of Flash, I quit VLSI and moved to Software Engineering, with my final thesis in creating cross language bridges between GUI and non GUI parts of an applicaiton (using Flash and Java). The approachability of Flash back then was my gateway drug to programming. Flash has since “matured” to a real programming language but I feel at the cost of the approachability the earlier versions had.

Ugh Java

Moving to the Software Engineering team was a bizarre experience. The Graduate School was a Java school and I got started working in Swing. It was crazy! I could do any kind of UI in Flash in a heartbeat but getting Java to render a custom designed button was virtually impossible (so we always stuck to the default lookAndFeel). Actually back in the day, I don’t think there was even a Java IDE like Netbeans that we used. Everything was written in VI and then compiled by using the command line.

Interface Builder: A good idea that was never completed ?

Working with Interface Builder, the tool used to develop User Interfaces for Mac apps,  for a while, I see the thought process that must have been going on when it was being developed. The concept of laying out the UI and tying it to the application logic components is a good one. But IB feels like the team was disbanded halfway into the project. The tool as it stands right now is such a pain to understand that most new developers who get into Objective C programming try to avoid it as much as they can.

The 280 Atlas IDE for Cappuccino seems to have taken the IB concept and extended it to the web. I like this better than IB if for nothing else than gathering all application windows in one. The floating canvases on IB get annoying really fast.

http://www.viddler.com/simple_on_site/1db9bf4d

Drag and drop application development:

I love this video. I am sure to scale this to “real” GUI development would be a significant amount of work, but that would be the holy grail (at least for me)

http://vimeo.com/moogaloop.swf?clip_id=1105302&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1

3d physics simulation with Wiimote from Balazs Serenyi on Vimeo.

The same idea is also echoed in MIT’s Scratch project. Scratch declares its mandate as making it easy to “create your own interactive stories, animations, games, music, and art”. While the focus seems to be towards animation and getting kids to learn programming concepts, can it be extended to real world projects ?

Another interesting project that surfaced recently was Sikuli. Check the video on that below. My favorite part of this was that the “script” actually references the images that behavior is assigned to. You dont need to understand variables at this point (You may need to to write business logic if you have to, but thats a bridge you can cross later)

Human-readable “code” with Ruby and Cucumber:

Just getting started with the Ruby programming language, I have been really impressed by its focus on readable code. An open source project called Cucumber is also fascinating. I haven’t done any work with it but have attended a few sessions on it in different user group meetings. Cucumber takes the readability of code even further with a goal of having non technical folk be able to define a site’s functionality very granularly.

Final thoughts: Enough with the text editor already

Using a pure fast text editor for developing applications seems to be the badge of a real developer. But writing lines of  text to express ideas in my head seems to be a paradigm that should have evolved a while back but hasn’t. Am I overly simplifying the problem? Possibly. But after so many decades since the inception of programming there is very little to justify the high barrier to entry it presents to most newbies. To me the current state of programming feels like the state of mobile phones before the iphone and the ipad. Whatever anyone’s feeling on Apple are, its hard to deny how much they humanized computing.

Its time to do that for programming too don’t you think?

Some other related interesting stuff

  • The Adobe design team recently posted some thoughts on improving the programming experience in Flash.
  • Some good thoughts on XCode UI enhancements

Thank you Apple, May I have another…not!

Word on the street:

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.

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?

oEmbed and why its a big deal (specially for video sites)

WordPress version 2.9 came out this week and one of the features that made me sit up and take notice was the new support for oEmbed for embedding content (Thanks Brajeshwar for the link). oEmbed is one of those things that I feel not enough people know about, well at least in my circle. The oEmbed specification basically allows you to query a url and retrieve the significant embedded content on that page. The idea was concepted by Leah Culver (formerly of Pownce, the Twitter on steroids app that didn’t make it) and her announcement post on the spec is a good read to understand more about the idea.

So what this means is, now to embed a video from YouTube (or any other site that supports it) at a page http://www.youtube.com/abcdef, WordPress users dont have to copy paste an embed block of code, they just have to paste the link to the video in their post and WordPress will automatically swap the link with embedded video. While this is convenient for people like me who run our own blogs, its a huge deal for the less technical users on hosted WordPress blogs who may not know how to use the embed blocks or may not be allowed arbitrary html in their posts. Thats a huge deal for syndication! The specification goes beyond video of course and includes any embedded content, like slideshows, presentations etc. And of course WordPress doing this is great but I imagine a lot more applications will start using this feature soon.

I have to admit, after the collapse of Pownce, I thought oEmbed would not go anywhere but the sites listed on the WordPress feature post are a lot of the big players.

oembed

Its great to see a good idea go beyond the product that spawned it.

Google AppEngine App issues on Snow Leopard

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 free time so I figured I’d modify this “lab” project that a few of us worked on at Comcast Interactive Media a few months ago.

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 Google’s documentation, 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’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 here. Ta daa! That worked.

Note, if you are using the command line dev_appserver.py script to run your application, check out this post here

Dispelling the FUD! Silverlight is NOT on the iPhone!

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.

Here are the facts. Microsoft User Experience Platform Manager Brian Goldfarb stated:

“We’re translating the content to support the MPEG2 v8 [decoder] format that the iPhone format; we’re moving it to their adaptive streaming format. So it’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’s the critical thing for our customers.”

Microsoft, Adobe and Apple have all proprietary adaptive streaming formats. For a better understanding read this article on Apple’s adaptive streaming on NewTeeVee.

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’s solution may need the Flash Communication Server to step in. But the perception of “free” 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.

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.

Crazy!

First impressions on Google Wave

So after a tormenting 24 hours without a wave account I finally got my invite last evening (Thanks @blamborn and Mat). So I figured I’d chronicle my first day’s adventures and add to the wave conversation on the intertubes, especially since just the day before I had blogged about what I thought Wave was about. I have a few friends on Wave already so it wasnt a complete case of the empty room syndrome, but my impressions might change once my contact list there reaches any critical mass.

First off: the interface. Quite a few people have talked about Wave looks pretty, (it even has drop shadows and rounded corners), but quite frankly, they are a waste of space here and actually hurt the UI. The gap between the modules is way too much (separator bars should be much thinner), and rounded corners dont really allow modules to butt up against each other too close. I have no idea whats going on with the smart scrollbar on the right hand side of the message window and why it only scroll to a fraction of the size of the main document. Besides that is okay, definitely not as minimalistic as Google has a reputation for.

My first couple of Waves were to myself, I added a couple of robots from the Robots gallery, but most of them didnt work for me. The idea of such extensions is interesting though this is pretty much the same as Yahoo Mail Apps or Zimbra mail or Yahoo Messenger plugins. Not really a new idea or that revolutionary.

I started a wave with Mat and another friend Nick and started working on a cheatsheet for Freemarker, a templating language for Java that we use at Comcast Interactive Media. Here it got kinda interesting, but the formatting options were a far cry from google docs (but thats okay considering the early beta stage here). What was really crazy was that people were adding to the content by “replying” to the original message. What I really thought we should have been doing was adding to the main document which is editable at any time. What this made me realize that there is indeed a difference between a conversation around a document and the document itself. Wave blurs the difference which makes you think a lot more on what should go where.

Nick later discovered the with:public search on wave that just showed all public waves, some with a lot of live editing going on. Cool! … or wait, isnt this what Yahoo chat was (I used to be a fair addict to Y!Chat in my teens). Heck, even the waves sounded like chat rooms: “Utah Wave Users”, “JQuery Users Wave”, etc.So I tried going into a couple of *rooms* and they were pretty chaotic. A few of the wave starters were trying to maintain some order in there (“please dont append to this part”, “please start new waves for smaller topics”, etc). Yeah I left pretty quick.

So here are my thoughts:

  • The idea of a blended medium is interesting but communication is indeed of differnt types: conversations, collaboration on a document, announcements do need different visual cues even if not different applications. For example, could a wave be *marked* as a conversation (chat or email) and then it could force a temporally sorted exchange or marking it as a document could force all conversations/comments on a sidebar.
  • The idea of robots appending content to a messages is powerful. I can imagine quite a few uses for it (you know, like bots do on IRC)
  • Gadgets on Google Wave could be awesome
  • Google Wave will definitely have an app store in the near future
  • Wave definitely needs an SMTP gateway asap that translates email to a “dumb-wave” or a conversation wave as I mentioned in the first point here.
  • I think a good use case for it is for a personal notebook. I use Evernote right now to jot down thoughts etc, but Wave could be a pretty awesome note taker that I could occasionally share a note from

So what do you think. Do you like it? Think it’ll be the future of email? (my opinion, not the current version but something it morphs to)

Migrating to Java 1.6 on a Mac (Warning: Flash CS3/Flex Builder/Eclipse wont work with it)

[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 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.

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 this post. That seemed to work and calling java – 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 Java Preferences Application without any luck, I finally found this post 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.

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 this post suggests, you may have to make a change to the Info.plist for the application to make it run with Java 1.5.

[Update] The Flash CS3 IDE doesnt work with 1.6 as well, so I am reverting back to 1.5 for the time being.

Object Oriented JavaScript Techniques

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’d quickly list some techniques I have been using to structure my JavaScript code.

Creating a very simple class with an instance variable:
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:

var vanillaFunction = function(){
	this.name = "vanilla"
}
var instance = new vanillaFunction();
alert(instance.name) //	vanilla


In the above case, “name” becomes an instance variable of the vanillaFunction class.

Constructing instance methods

var vanillaFunction = function(){
	this.name = "vanilla";
	this.sampleMethod = function(){
		return "SampleMethod was called";
	}
}

var instance = new vanillaFunction();
alert(instance.sampleMethod())

Under the hood whats going on is that the JavaScript interpreter is attaching the Function objects to the vanillaFunction’s prototype chain. So to add another function, we can append that function right on the prototype:

vanillaFunction.prototype.getName() = function(){
	return this.name; // returns "vanilla"
}

Note that these functions have access to the name instance variable defined in the main vanillaFunction class.

Creating class variables and methods (kinda):
Since all functions are essentially Objects, variables can be tagged on to the function object and then referenced as static class variables.


vanillaFunction.classVar = "some value here";

Same way, static functions can be created as well:

vanillaFunction.staticFunction = function(){
	alert("static function called");
}

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.

Creating Static classes:
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:

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);

Creating classes with JQuery
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:


MyClass = function(){
this.title = "MyClass";
};

$j.extend(MyClass.prototype, {
toString:function(){
return this.title;
}
});

Events:
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’t necessarily have to be a DOM element.


var obj = {name:"SimpleObj"};
jQuery(obj).bind("objectChanged", listener);
jQuery(obj).bind("objectChanged", listener);
jQuery(obj).trigger({type:"objectChanged"});

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:


var CustomEvents = {
OBJECT_CHANGED:"objectChanged";
}
jQuery(obj).bind(CustomEvents.OBJECT_CHANGED, listener);

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.

Further reading:
John Resig’s list of lessons in advanced JavaScript