Beautiful Greenfield Apps with Gravatar, Disqus, and AddThis

Our company sponsored hackathon is over, but I'm still trying to grok all the new tech I got to play with. If you haven't already, check out Part 1 of our hackathon story to learn about how MVC3, Bootstrap, and OpenID featured in our application.

It is really amazing what free external services can do bring additional functionality to your web application. During the hackathon I got the chance to add three services to app that really made it feel whole.


I first learned about Gravatar when I found it being used on the MemphisJUG website. This free service let's users set up one profile pic to rule them all. If a website know's your email address, it can pull the associated Gravatar using a pretty simple image link. The necessary HTML for your web application to use a Gravatar is:

< img src="" />

You merely replace HASH with a MD5 hash of the user's email address and the magic is done.

Well, almost. Turns out getting an MD5 hash appears to require another step in .NET. I might have some basic lack of understanding about hashing, but my thought is that the code required to get an MD5 hash is much too complicated. Why this isn't just a built-in extension method on String is beyond me.

Instead the process involves using the System.Security.Cryptography.MD5 class, byte arrays, and a String Builder. Luckily I found a blog post that explained all this.  You can find it and additional details on Gravatar images in the links below.


If you've been using the web at all, you've probably already stumbled upon Disqus before. Disqus allows you to post comments to pages, using a variety of login providers. But the magic of Disqus is that it is just a javascript widget, so sites can start supporting Disqus in matter of minutes.

To get started, register your site on Disqus. Get the "Universal Code" and change the javascript to include your site's shortname, a unique identifier for your site in your Disqus account. Make sure the pages you want to include Disqus are linked within your application with canonical URLs. While all the rules for the rules for URL normalization may not be required, we did notice that a link that gave a different URL, but pointed to the same page, pulled up two different sets of Disqus comments. Then just drop in the Javascript widget and you're done.


If there is one thing that changes way too often online, it is the current up and coming social network. AddThis is another easy to use javascript widget to quickly get some often desired functionality, namely the ability to share links on a social network. AddThis takes it a step farther: 1) It supports a very large number of social networks and 2) It dynamically can choose which networks to show by default based on how which services individual users have selected before. Combined with a plenty of customization options, analytics, and other features AddThis might be the social sharing plugin to rule them all.


While digging into a greenfield project is a good time to explore what you are capable of, it also is great time to check out what free services are already out their. Using javascript widgets and external resources can quickly give you features that may take hours or days of development to create on your own. Our hackathon project was much more feature complete because we could utilize tools like Gravatar, Disqus, and AddThis to provide the social integration required of Web 2.0 applications.

Beautiful Greenfield Apps with MVC3, Bootstrap, and OpenID

I haven't done much greenfield development in the past year. So when the company sponsored hackathon was announced this year, I was a bit wary. Could I keep up with the speed demons out there when I had spent so much recently in low gear, slogging through legacy code?

Luckily there were plenty of resources for my team to use when we got started. We're only a couple of hours into the hackathon, but I wanted to record and share some of the stuff we've used so far.

MVC3 Templates

Since I was so rusty with greenfield development, I did do some excercises before the hackathon to get back into that mindset.  The links below handle straight forward new MVC3 applications. We hadn't decided on a persistence strategy before the hackathon, so I also got some practice with Entity framework. If you haven't seen Entity framework in action before, it really does seem well suited for the type of rapid development that a hackathon imposes.

CSS patterns via Bootstrap

Now while the examples above quickly give you a very functional web application, they are ugly. No one is going to attract users with the default CSS in the MVC3 templates. Now a hackathon is not the time to do a focus group; we need at least a basic set of UI patterns. We could have stolen the design patterns from work, but that wouldn't make for a good blog post. Instead we pulled the in the CSS and JavaScript from the Bootstrap project by the Twitter team. This is a pretty great open-source set of design documents which really gives the application a modern look and feel. It even has a NuGet package to ease the implementation.

OpenID via DotNetOpenAuth in MVC3/Razor

Now you don't get to have your app branded Web 2.0 if you're still asking users to create yet another password/security question on your site. OpenID is the de facto standard for solving this problem (Suggestions to use Facebook Connect were laughed at derisively). Unfortunately OpenID has somewhat of a bad reputation for ease of implementation. So imagine our glee when we found a NuGet package for OpenID in Razor no less. We did have some trouble finding the blog posts on how to use the package properly, but I've listed the links below to save you the trouble.


We've gotten off to a great start with our hackathon application. There are a great number of resources for greenfield application development on the Microsoft stack, especially for enterprise-y developers like me who don't usually get the opportunity for this kind of development. MVC3 templates, Bootstrap, and DotNetOpenAuth give developers a great tool-set to become Web 2.0 in a few short hours.

Intro to Memtech: Java - Deconstructing Hello World

Last time we took a rapid fire tour of the basics of Java syntax. Somehow this still doesn't explain everything you find in the simplest "Hello, World" Java app.  In this post we'll try to make sense of the following code.

public class Example
  public static void main(String args[])
    System.out.println("Hello, World");

We already know that 'System.out.println("Hello, World");' prints to Console output, but how and why are still beyond us. First let's take a look at the first line. Java is an object oriented language, and 'public class Example' is defining an object type Example. It is public, so any code can access it. 'public static void main(String args[])' should look very familiar to a C++ programmer. This line defines a function that is called when this file is called from the command line. The 'String args[]' is an array of the command line arguments. 'Static' means the function can be called without creating an instance of the Example object; 'void' means it doesn't return anything. 'main' is the special sauce that gets us that command line behavior.

Additional object oriented concepts such as inheritance and polymorphism are well supported in Java. Check the directory InheritanceAndPolymorphism in the code sample link below for examples.

I was lucky enough to be taught Java as part of my undergraduate college experience. I don't say that sarcastically, Java is a wonderful language despite what you might hear online. Every language is designed in a series of trade offs to fit the use cases it might find itself in. As we've already discussed, Java has a very wide selection of use cases in large part to the JVM. The JVM somewhat muddies the waters between traditional compiled languages vs. interpreted ones, even more so because of JIT or Just in Time compilation. You compile Java code ( .java files) once to Java bytecode (marked as .class files). Then the JVM can JIT compile or interpret the bytecode. There is also software which will perform native compilation, AOT or Ahead of Time compilation (which I'd call traditional compilation).

The JVM was a bigger accomplishment than the Java syntax James Goslings created at Sun Microsystems in 1995. It has created a whole ecosystem of languages from dynamic Groovy to functional Scala. Java is a great way to introduce yourself to that platform and to explore the options it opens to you.

All of this was written in anticipation of the "Intro to Memtech: Java" talk that I gave last Monday. The talk went well and I'm happy to share my code samples and slides from the talk.



I also used the fantastic code samples from Ben Von Handorf's DevLink 2011 Mobile Smackdown presentation. Details on the presentation and a link to his code samples can be found on his blog post linked below.

Intro to Memtech: Java - Java Syntax

In the last post, we setup an Android development environment. We also setup our first Android app in "Hello, World" in cut and paste fashion.  That's all fine and good if you already have a good handle on Java syntax, but what if you're still in the dark on that subject? In this post, we'll cover the basics of Java syntax.

//this is a comment
int i;  //this is a primitive integer variable declaration
i = 2 + 2; //this is an assignment statement

Java has a C-style syntax, so chances are it already looks pretty familiar. It is a statically typed language and uses infix notation for most operations. Semicolons delimit the end of statements, so it is possible to stack multiple operations on one line, but not usually recommended.

String s = "This string is immutable."; //Strings are objects, not primitives
String s = "This assignment creates a new string." 
//The old string is garbage collected by the JVM

Java is an object oriented language.  Two other important features are that Strings are immutable and unreferenced objects are automatically deleted by the Garbage Collector.  Garbage collection can be expensive, especially in real-time applications.  So performance can take a dive on something something like:

String s = "";
/*This "for loop" repeats this block of code 99 times
  It subtracts 1 from the initial value of 99 assigned to 'i' on each pass.
  It exits when the boolean operation 'i  > 0' equates to false */
for(int i = 99; i  > 0;  i--)
  //The '+' operator appends strings.
  s = s + i + " bottles of beer on the wall. " + i + " bottles of beer. \n";
  //The primitive i is automatically converted to a string.
  s = s + " Take one down, pass it around. " + i + " bottles of beer on the wall. \n";
  //Notice the '\n' end line character

Each time we make an assignment to 's' we create a new unreferenced string which must be garbage collected. Java does have a few primitive types, such as integers. Luckily, primitives each have a Wrapper class that allows you to use it when you need it to act like an object. In the last example we get the 'i.toString()' method called each time we concatenate 'i' with a string. Some additional syntactic sugar known as auto-boxing makes other conversions invisible.

int primitiveInt = 42;
Integer integerObject = new Integer(13); 
//Create a new Integer object that wraps a value of 13
integerObject = primitiveInt;
System.out.println(integerObject);  //prints 42 in the console

If you've noticed we also snuck in Console output, a control structure (the for loop), and a boolean operation ('i > 0' or 'i' is greater than zero).  Chances are that all looks familiar and you had no trouble reading it, even if you don't 'know' Java. In the next post I'll go into how to get a running program with these types of statements, what the 'System.out' means in the last example, and an explanation of packages, classes, and methods.

Intro to Memtech: Java - Setting up your Android environment

Last time we went over the spectrum of use cases for Java as well as took a glance at the variety of web frameworks available for the JVM. That's great for self-exploration, but what else do I have to show you about Java?

While web application frameworks obviously have a lot to say (in a lot of different ways), Java's role in the mobile space (in my opinion) is more compelling. While Java has been in the mobile space for a while, the popularization of the Android OS by Google has really changed the landscape. Android runs a Java compatible virtual machine called Dalvik. If you've been following along so far in this post series, you already have 2 of the 3 downloads needed to develop on Android, namely the JDK and Eclipse.

Go to and download the Android SDK or Software Development Kit. Windows gets a nifty installer which fires off a separate download for the Android SDK Tools. On other systems you'll need to refer to the documentation to fire off that download from the Android SDK and AVD Manager utility. Refer to the documentation for the Android SDK setup while those download to get your bearings. The next step is to get the Android Development Tool or ADT Plugin for Eclipse (remember that readily supported plugin architecture?).

You can follow the directions linked above but note that there is currently a bug in the ADT plugin that causes the emulator to fail to launch if the SDK location contains any spaces (by default in Windows 7 it will be in the "Program Files" directory). When firing up Eclipse you can use the default workspace. After completing the ADT Plugin installation, you'll still need to setup an AVD or Android Virtual Device, a kind of system image for the emulator. You can reach the Android SDK and AVD Manager utility now from your OS (Start menu in Windows 7) or from within Eclipse under "Window -> Android SDK and AVD Manager". Follow the directions in the last link, but I suggest you use SDK 2.1 as that will let you reach a high percentage of devices (unless you're making an app for a tablet, for which I suggest the 3.x branch).

The instructions for setting up an AVD end by landing you squarely in midst of a Android "Hello,World" style example, which I suggest you finish to test your setup. When you finish you should be able to create a new Android project in Eclipse and successfully get the "Hello, World" app to run within the emulator. In my next post, I'll start digging into the syntax of Java so you can make sense of the app you've brought to life.

Intro to Memtech: Java - Use cases and Web Frameworks

If you've already read my last post, you're already setup with a Java development environment.  Hopefully, you've take the time to explore a bit on your own.  In this post I'll talk briefly about where you could expect to use Java as well as what choices you have in terms of web application frameworks for the JVM.

You can do anything with Java, really nearly anything. You can make a game or embed software in device. At my day job, we write Java that controls the HVAC systems of our clients via the Niagara framework. Java also is used extensively for server side back-end programming for sites such as Twitter. Java has had a role in mobile applications for a long time, most recently in its role with Android (more on that later). You can make a web application with it, either via applets (not exactly modern, but not useless) or using a web application framework.

I don't claim to have deep insight into selecting a Java web framework, but out of the choices there are four I'll mention.  JSF or Java Server Faces, Apache Struts, and Spring appear from a cursory search to be the most broadly used, although the error bars on my meta-survey are pretty wide. The dark horse in this race is a cute framework named Play. All of these purport to be MVC style web frameworks, although many others are closer to adapted desktop or MVVM style application development. My ill informed suggestion is to check out Spring and Play first, based purely on watching a single presentation on the former and a couple of articles on the later.

Alternatively, the JVM supports a number of other languages, complete with their own web frameworks such as Groovy on Grails or Scala using Lift.  Clojure, jRuby, and Jython also have associated web frameworks. Each language/framework combination is going to express a different opinion on software development. Correspondingly, some of these combinations are going to be much better or worse depending on your needs and style (e.g. enterprise vs. startup, dynamic vs. functional) so make sure to take your time evaluating at least a few of the major contenders before investing a lot of time in any.

Hopefully you've now got an idea of where you should be looking for tools and ideas for future projects.  In my next post I'll be taking a look at setting up an Android development environment in preparation for our code sample.

Intro to Memtech: Java - Setting up your Java environment

I'll be presenting an introductory Java talk at LaunchMemphis in just a few short days.  I've been working hard to get prepared, including updating my Java development environment.  I don't plan on spending too much time on it during my presentation, so this post will be a little more in depth explanation of what I've got going on.

For all the downloads listed I used the x86/32bit versions.  I tried an all 64bit environment, but it wasn't stable.  I'm not certain which download was responsible for this instability. Your mileage may vary.

The first thing to know about developing for Java is that you need Java installed.  Most computers already have Java installed, but the Java you know and love (or love to hate) is actually the JRE or Java Runtime Environment.  This includes the JVM or Java Virtual Machine, libraries, and other components needed to run Java applications. But you already run Java applications just fine, you want to develop them too. For that you'll need the JDK or Java Development Kit. Info on the Java 7 JDK can be found at  From there you can download the Java 7 SDK from  as well as browse the API documentation produced from the javadoc tool. On Windows an automated installer with default options will get your JDK ready. I do suggest uninstalling any previous versions of the JRE (e.g. Java 6 or earlier).

While it is completely possible to develop in Java with nothing but a text editor and a command line, I don't recommend it.  The de facto standard of Java development is the Eclipse IDE or Integrated Development Environment. Eclipse gives you all the breadth, depth, and weight of an open source IDE. It also gives you all of the negative characteristics you could infer from that description as well. Eclipse is big, slow, and a grab bag of features. It is built extensively around a plugin model that allows it to be used with a variety of languages, in a variety of contexts. But that diversity and malleability comes at the cost of a unified user experience and speed.

Because of the breadth of usage and plugin model, you're probably going to bump into Eclipse anyway. New technologies often have Eclipse plugin support before other IDEs. Once you've been in the Java space for a while, be sure to try out Netbeans and IntelliJ. Both have cleaner, snappier UI but lack some of the flexibility of Eclipse. Getting back to Eclipse, you're going to get a lot of options when you go to download Eclipse. I suggest you pick Eclipse Classic. Eclipse comes in a lovely archived folder which can run from anywhere, but I suggest you don't put it in the program files directory. Windows 7 at least doth protest too much. It is quiet as a lamb if you extract it to the root of the C:\ drive.  Dig into the folder and pin it to your taskbar, or make a shortcut to access Eclipse more easily.

If you've followed along so far, you should have your Java development environment setup and Eclipse installed.  Congrats, you have all you need to start exploring Java. In my next post I'll talk about the areas where Java is used and the web frameworks available for the JVM.

Seven Languages in Seven Months

I finished reading my copy of Seven Languages in Seven Weeks last month.  I've been stewing on it a bit as I've started to dig into Code Complete 2.  Haskell, Clojure, and Erlang were by far the hardest languages to grok, even when compared to the venerable Prolog and obscure Io.  Tate's choice to place them at the end of the book was well advised, as many of the ideas gracefully intersect in later languages.  In particular I felt like the Prolog unification sections played nicely into some of the functional languages.

Clojure does feel like a decent next step for the JVM, but I still enjoyed Scala much more. I'm also not a fan of the name since I'm just getting my head around closures. Erlang was an interesting language, but I'm not sure what I'd program in it. That's probably an effect from my lack of experience in the concurrent paradigm. I felt that Haskell had a somewhat superficial treatment in the book, particularly the concept of monads. This was a language I was expecting to be blown away by, but partial functions don't seem to add much from a cursory exploration (if you already have first class functions).

Code Complete 2 is a very different book, both in content and in style.  I find myself enjoying it a lot less, even though the information provided on formal development process is something I probably need to commit to memory.  I'm still committed to reading it for now, but I hope that it picks up later on since it is a pretty thick book.

I'm working on a "Intro to Java" presentation to given in two weeks at LaunchMemphis.  I've already picked out a "textbook" in the form of the tutorials from Oracle.  They seem to be the only documentation that is up to date since the release of Java 7. I'm still contemplating what will be my "advanced" demo after the traditional "Hello, World" app. I'm tempted to see if I can get a CRUD app running on Heroku with the Play framework, since I expect a fair number of web developers to attend.  I'm afraid that may be too many moving parts.  Also my experience with the Play framework is non-existent right now.

If you have any suggestions or requests for demos or content please leave them in the comments. Thanks!

Hello, Android

I skipped thru half a dozen "Hello, World!" examples of Android over the past week.  None of them were better than the ones available at which have not only the "Hello World", but also a section called "Hello Views".

Creating a new Android project in Eclipse already "Hello, World"'s for you, so I probably wasted some time flipping thru the different examples of that.  The views however are numerous and varied.  I had time to page thru the examples for several Layouts (a way to style views) including Linear, Relative, Table, and Grid.  The grid example is the most exciting, since it also gives you a taste of event management and introduces you to a "Toast" (brief informational message, think JavaScript alert) as well.  I can see using this to get "iconic" with an app's design very easily.

I've been tossing around in my head project ideas for my first toy project, post intro.  I'm considering some type of RPG style game, perhaps emulating or using the in-app billing features.  It just seems to be a very compelling business model.  The Free-To-Play model let's people try before they buy, and then to pay only what they think the game is worth.  I think this is going to be one of the major payment models for games for a long time to come.

One of the difficult things about a RPG whoever is that it seems to defy attempts to structure the experience.  I think this is why it works so well in meat-space around a table, and always seems to be missing something while around a screen.  Trying to figure out how to organize this code is going to be a challenge, especially since I'll need to take android development idioms into account as I learn them.

Hopefully, I'll find some examples online.  I'm starting my exploration with the StackExchange question below.

Intro to Android

So I bought an Android phone earlier this year.  It is the first smartphone I've owned.  Previously I had one through work and so did my wife.  I think we've both become hooked on continuous connection to the hive-mind (i.e. internet).  It will probably be a facet of our lives for the foreseeable future.

I picked an Android phone because I believe capitalism fails when companies try to control too large of a vertical slice of a market.  It is big a turn off when hardware makers and phone carriers write, modify, or limit my software choices. Android helps, but does not solve this problem for me completely. Therefore I've had a strong desire to root my phone and put this issue to bed.

But I haven't.  The shady characters, suspicious downloads, and arcane instructions required to get to true freedom just haven't been worth the time.  That may be finally changing.

I spent the last weekend at CodeStock, a fantastic developers conference with a very ugly mascot.  I got a chance to meet and listen to Jason Farrel speak about Android development, in Eclipse and IntelliJ no less.  Having watched everyone at work get their own pet mobile app running and feeling armed with some knowledge of my own, I felt inspired.  The only measurable success so far is a compilable example project in Eclipse, but I figured I'd share some of my notes from setup all the same.

1)  Eclipse might not know where your Android SDK is located.  You'll need to set this up in the "Preferences" menu.

2) There's a lot of stuff to download.  Luckily I already had Eclipse (for normal Java development), Java (see Eclipse), and the Android SDK (abandoned rooting attempt).  In addition you'll need to install the Eclipse plugin which took a bit of time.  Pack a meal if you plan to make a day of it.

That's all for now.  Hopefully I'll have more info soon!

Blowing up a simple install

If there is one thing that's gotten me frazzled lately, it would be understanding how to get the latest Ruby to run on the latest Rails on the latest Ubuntu.

This has been a major pain point for me, in small part because apt-get doesn't want to let me get the latest and greatest packages.  It wants me to accept the months delayed versions.  I've heard that "Rails 3/Ruby 1.9.2 are still in beta!" and "No one is adopting them yet!".  This seems to be either untrue or irrelevant.  Rails 3.0 is stable, Rails 3.1 is in beta.  Adoption is good enough, books are being written and I have full confidence this is where I want to be.  I'm into Ruby on Rails for idealistic learning, not for pragmatic work.

In large part however, this has been a pain because my Linux skills are woefully inadequate.  Wget, xargs, sed? I have no idea how to use these things in practice. Oh, I have a cheat sheet on my wall at home.  I've probably read the man file once for a few commands. I once even setup a cronjob with ed. But I know my limits.

So when someone told me that rvm (Ruby Version Manager) was the solution to all my woes, I said "Great!... Why doesn't it tell me to install it with apt-get on their website?"

I want to be very clear here.  I am not saying the rvm tool, documentation, or website are not wonderful.  I am saying "I am ignorant of Linux and this (representative of all *nix programs) install process was intimidating for me."  I'm sure with additional Linux competency and package management experience the installation would look like a cakewalk.

Let me put all of the glorious bounty of the rvm install process out for you.
  • user$ bash < <(curl -s
  • user$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
  • user$ source .bash_profile
  • user$ type rvm | head -1
  • user$ rvm notes
  • user$ rvm install 1.9.2
  • user$ rvm use 1.9.2 --default
The steps above could almost be written in Sanskrit for all I know.  There are several things I was confused by.
  • user$ - I didn't immediately identify this as the command prompt.
  • bash - Why do I have to call this explicitly?  Isn't my terminal already some flavor of bash?
  • << - I have no idea what this actually does.
  • curl - Why do I need this when I should already have wget?
  • echo - Why do I have to echo this string?  Note, I've only ever used echo for "Hello World".
  • >> operator - I really hope this means append.
  • .bash_profile - Ouch.
The .bashrc, .bash_profile, and .profile configuration files confuse me to no end.  I have no idea which one I should use, when I'm told it usually is wrong.  I tried all three and finally got it to work after having my terminal open as a "login script".  I have no idea of the unintended consequences of this action.
  • source - I know it means reload the configuration file, but I wish it actually was called reload.
  • rvm | head -1 - I don't know how this works.
  • rvm notes - Big Ouch.
I need to read the notes to find the dependencies, but I don't know why I need them, and only some of which are visible in the Ubuntu package universe directory.

I did eventually finish the install and learned a few things along the way.  RVM actually has a Basics of RVM page which actually does explain some of the issues above, although I didn't see it until after I had resolved them.  I hope that forcing myself to continue these kind of explorations will help me learn the basics of scripting that I've seemed to skip over in my IT career.

Prologue to Prolog and Scaling Scala

Seven weeks has been completely thrown out the window, but I have managed to down two languages during our last interlude.  I'm currently in the depths of Erlang, a language I've enjoyed for a long time as a conceptual mystery from afar.  Seeing actual syntax doesn't seem to kill any of the allure.

It is a good thing Prolog and Scala come before however, as concepts in each help segue  into the heavier functional programming languages later in the book.  Scala I had already seen, and fallen in love with.  I've noticed recently however that there has been a bit of a push back against it.  Apparently the Scala typing system that appears beautiful to me, is a pain to others.  Prolog on the other hand I had merely heard of quite simply described as "old".  I knew nothing else about it beforehand.

Turns out Prolog is a fairly interesting language.  It feels a lot like SQL (which I'm not certain would not have been a better choice for this book) with constructs that appear to create a database like table and query over it.  You build up a description of a problem, not logic to solve the problem.  Prolog then queries these rules and gives back a working solution set using a set of pattern matching constructs.  This gives you a great answer to questions that have one unambiguous answer (or a logically defined set of correct answers).  Performance however sometimes leaves something to be desired.

Scala still makes me feel giddy.  It takes so much of the Java boilerplate and throws it out the window.  Functional programming seems to live in peaceful coexistence with object orientation.  It seems like the only downsides Scala can claim all seem to be positives to me.  Namely they are Java compatibility, object orientation (and mutable state), and strong, static typing.  The first two seem to be a question of style, persons who find either addition distasteful dislike it being available for other developers in the language.  Personally, I find that a weak argument.  Pragmatically Java syntax and object orientation are useful tools in some contexts.  Strong, static typing seems to be more about taste.  Rubyists and other dynamic language proponents seem to dislike any static typing.  Static typing does seem to buy you performance and definitely offers refactoring capabilities however.  I think it really is a wash, if you've become accustomed to either, the other will feel alien and wrong.

In the end I don't think I'll be writing a lot of Prolog, but I have gotten a few new ideas about what I can use a SQL database for.  Scala still seems to be the city on the hill for the JVM, but it seems not all programmers are interested in traveling to Zion.  Too bad they can't learn to savor the flavor.

Visiting the Future in Io

So seven weeks might be a bit optimistic.  I spent the greater part of a week trying (unsuccessfully) to get Io to compile on my Ubuntu box.  The intricacies of compiling C code from source have been one of many obstacles that have kept me away from contributing from open source.  I haven't had any luck before and Io was no exception.

Eventually however I stumbled across the windows binaries and gratefully dual booted into my Windows 7 partition.  The binaries gleefully worked on the first try.  Io was a very nifty language once I finally got to use it.  Slots, terminology I had actually heard first from a Java library, make up an object.  Objects are just collections of slots.  Slots contain objects.  Confused yet?

It isn't confusing if you know Io's cousin, Javascript, already.  Both languages are prototype languages, they don't use classes but merely clone existing objects for inheritance.  Objects are basically hashes (i.e. dictionary).  In Io everything is an object including methods.

Io has some interesting behavior, particularly in relation to concurrency.  Instead of the pre-emptive multitasking I'm used to in Java, Io goes for coroutines instead that politely pass execution from one to another.  Two currency constructs, one I'd heard of and another foreign, are also extremely easy to implement in Io.  Actors, the known, are simply instated by send an asynchronous message to an object (messages are basically method calls).  The unknown was a construct known as Futures.  These are simple objects from most perspectives, the difference being that a Futures value is filled by an asynchronous call.  If you try to access the object before the call finishes, you automatically block execution while you wait.  All of this behavior is baked into the object, no extra code required to access the value.

I've already started digging into Prolog and I hope to give you some idea of what I find soon.  Hopefully my seven weeks in theory won't double in practice.

Metaprogramming and the Magic Black Box

As you might have read in my last post, I'm trying to get some additional reading in this year.  One the of the books I got for Christmas was Bruce Tate's Seven Languages in Seven Weeks.  I've polished off the reading for the first language, Ruby.

Overall this is an enjoyable book so far.  One point of irritation however is the references to answers at the back of the book, which were never published.  Not only is this irritating because it should have been an easy typo to fix, but because the best parts of the book so far have been the example problems.  I thoroughly enjoyed thinking through the problems and the lack of answers (which I wouldn't miss as much if references had not been made to them) reduces my understanding of the author's perspective.  Frequently I found myself wondering if I was missing some basic aspect of the language (particularly a bit of syntactic sugar in Ruby) when solving a problem.  Perusing blogs helped to some extent, but often I felt like the example answers I could find were missing some elegance that Tate had in mind. If they didn't have some significance, why did he choose that problem to print?

Metaprogramming in general has been one section of Ruby that I've been extremely interested in learning how to apply appropriately.  Seven gives a good synopsis and certainly shows how it can remove boilerplate code.  It is part of the magic of the Rails framework, but I still remain unconvinced as to its place as a part of a programmer's standard kit.  I think there is a balance to be found between boilerplate overload and metaprogramming negative space.  When you hide the context of an operation inside the black box of metaprogramming I think you lose a fair amount of perspective into the design of a program.  Simpler (concise) becomes more complex (abstraction).  We risk losing ourselves in the metaphors.

Hopefully, I'll find a use case that makes me really appreciate the magic box of the method_missing and related tricks in Ruby and other metaprogramming toolsets.  Until then I'll probably just piggyback on the frameworks like Rails that have used it so well.  If you feel like explaining why method_missing is awesome, please do so on the StackOverflow question below.

Memphis Java User Group

Last night was a great start to 2011 for the Memphis Java User Group (  We had four presentations, the first of which was a wonderful explanation of the mathematical concept of Monoids, a concept in the same vein as the popular functional programming buzzword Monad.  The extensive code sample was done completely in Java.  Take that Haskell.

After dinner three speakers, including myself, gave talks on their personal learning goals for the year.  The other speakers gave a great overview of the categories of NoSQL databases and introduced me to a language I've never heard of before, Gosu.  Since these were all local speakers I'm looking forward to hearing in depth talks on each of these subjects once they've gotten a chance to dig into them.

My talk covered two books I received for Christmas, "Seven Languages in Seven Weeks" and "Code Complete 2", as well as HTML5 and the hosting service Heroku.  Check out my slide deck below.

You can download my presentation slides from if you'd like to peruse them offline.