Sifteo Cubes are a novel idea first publicized in a TED talk in 2009. In January 2011, Sifteo invited a limited number of people to join the early release program by pre-purchasing their starter kits. The $100 kits sold out quickly, and customers received them about three months later. I was one of those customers.
I don’t have, or spend, a lot of time on games. But I was intrigued by their soon-to-be-available SDK. As a developer, I was interested in seeing if this platform “had legs” by trying it out. I also wanted to get in on the ground floor as a third-party developer.
The SDK (Software Development Kit)
Fast forward to September. I’m personally tired of waiting for the Sifteo SDK, and my cubes have collected dust for the last six months:

This is the box of stuff I don't quite have a place for, in my office. I walked past it today, remembered that I had them, and decided to see if they ever got around to releasing that SDK.
I’ve been waiting since I ordered my early release cubes the first week of the year. I was led to believe the SDK was just around the corner. My interest was primarily in development, so they got my $100+ under false pretenses. I’m not saying they lied or did this on purpose, but the end result is the same to me.
Part of me wonders if they didn’t want to complete with third party developers on the core apps they had in the works. This is based on their failure to answer even simple questions until recently – such as, what language/platform will be used? I couldn’t think of a simpler and more readily available answer to give. Developers resorted to studying screen shots of code to take their best guess. Java and Python were the front-runners of the guessing game, but both were wrong: C# is the winner.
Sifteo has traditionally been very tight-lipped about their SDK release schedule, claiming several times that they didn’t have a date in mind, wanted the SDK to be solid, and so it would take however long it would take. Of course, this was well *after* developers like myself had paid to be part of the early release program. Again, even if they had the best of intentions, my end result is the same as if they’d deliberately mis-led me.
Signing up for their SDK-specific mailing list, I only received a couple e-mails over the months. They were general marketing blasts targeted to consumers. It turns out, I was really just signing up for their general mailing list. Ironically, I’ve since learned that their blog has been posting SDK-related info, that I *didn’t* receive via e-mail. I didn’t know they’d publicized a September SDK release until today (09/28/2011). Of course, it’s starting to look like it was just as well, since it doesn’t appear that they’ll actually *have* a September release.
The latest word from Sifteo staff is that the SDK should be ready within a week, pushing the release to early October:
The explanation given is that they have a small development team, and SDK development/documentation took a back seat to consumer-facing issues. That’s a reasonable response, mostly, but it would have been more useful and appreciated months ago.
The Product
The cubes themselves are novel and fun, but limited. Far from the “tiny blocks with brains“, as Time Magazine called them, they are simply small color screens with motion sensors and bluetooth connectivity. They don’t run apps, your computer does. The distinction is lost on many people, which is why I think reviewers have overlooked it thus far. Your computer must be nearby and running the Siftrunner application. You can’t switch games on the cubes themselves – you must go back to your computer to do this, as well. The cubes are merely new peripherals, like a mouse and small screen rolled into one. My kids can’t play them on long car rides, unless I bring my laptop to actually run the applications the whole time.
Bluetooth means you can’t stray too far from your computer. And despite the fact that the apps are actually running on your computer, which presumably has internet access, there’s no support for using your internet connection. This would open a whole new dimension of game play. Because of their simplicity, any game played on the cubes could easily be played against online players. The bandwidth requirements would be very small.
Product Comparison
Let’s put on our Consumer Reports hat for a moment, and contrast Sifteo with similar handheld platform: Cube World. My oldest son was into these for a couple years. Similar in size, they have a low-resolution black-and-white display which allows you to interact with funny stick people.
Like Sifteo cubes, Cube World cubes can detect motion. Roll your cube over and over, and the tiny person trapped inside rolls around as if bound by gravity. Keep it up, and he actually vomits digital blocks. Put multiple cubes together, and the stick people can interact. They have different games and toys, and seeing the interaction (sometimes playful, sometimes antagonistic) is fun.
Value
Cube World lacks a color display, multiple games, wireless connectivity, or the complexity of Sifteo. But they’re also not tethered to a computer, and the price ($25 a pair when they were in production) allowed you to buy a dozen cubes for the price of the Sifteo starter kit ($150 for three cubes and a charger).
With limited input options (movement, and placing cubes in proximity to one another), Sifteo cubes are limited as a gaming platform. For another $20, you can walk into your local Sears and buy a brand new Nintendo 3DS. I haven’t played a Sifteo game yet that keeps my interest for more than half an hour. Speaking as a parent with a lot of road trip experience, you get a lot more peace and quiet for your dollar with the DS.
Summary
Suffice to say, I’ve been disappointed in Sifteo so far. They’ve done a great job of marketing. They got my $100 commitment before they ever had a physical product to sell, and they’ve gotten a lot of publicity from the media.
MIT degrees and TED exposure can only *start* a business. At some point, you have to deliver the goods. I can’t speak to consumer satisfaction. That will bear itself out soon, since I believe cubes have started shipping to the general public. From a developer’s perspective however, Sifteo’s debut falls short.




Nested Comments in Ruby on Rails, part 2: Controllers and Views
January 26, 2011Part 1 of this series came out exactly 3 months and 3 days ago. Special thanks to a reader named Edward who prodded me to finally add the controllers and views to this.
Going beyond the model layer for nested comments introduces a new programming idiom: recursion. Some ruby developers may not be familiar with it – especially if your experience is mostly web-related, where the need doesn’t come up as often. Recursion in a nutshell is the act of a method calling itself. If you’ve seen Inception, The ability to have dreams within dreams within dreams means those dreams are recursive. If you haven’t seen the movie, think of russian matryoshka dolls. You won’t experience star-studded special effects with the dolls, but you’ll at least get the idea of recursion.
Unlike russian dolls or most of Leo’s recent work, recursion in software is potentially infinite. Practically speaking though, it’s more like the doll thing. After all, a system only has so many resources, and recursion is expensive in this regard – the method must copy itself in memory at each layer, local variables and all. On the plus side, they tend to be lightning fast compared to standard iteration using loops. And in our case, we’ll be hitting the database at each layer. We’ll ignore the dangers in our simple app, though.
Routing
Let’s start with our routing file:
# config/routes.rb NestedComments::Application.routes.draw do resources :comments do resources :comments end resources :posts do resources :comments end root :to => 'posts#index' endWorking backward, we’re making our Posts controller’s index action our default route. That’s just to get the app functional. Next comes something interesting: nesting our comments inside of our posts. Interesting, but boring. Finally, the main event: nesting our comments within our comments!
Before you get too excited and start pulling out your Nana’s childhood russian doll set for comparision, this isn’t true recursion. It’s well documented that nesting resources any more than two layers deep is painful and unnecessary, so think of this as the lamest russian doll ever.
Controllers
First, our Posts controller, which is less exciting:
# app/controllers/posts_controller.rb class PostsController < ApplicationController def index @posts = Post.all end def show @post = Post.find(params[:id]) end def new @post = Post.new end def create @post = Post.new(params[:post]) if @post.save redirect_to posts_path, :notice => "Your post was created successfully." else render :action => :new end end endWe’re setting up a pretty standard restful resource here, with a couple actions skipped for simplicity. Now the comments controller (get those dolls ready):
# app/controllers/comments_controller.rb class CommentsController < ApplicationController before_filter :get_parent def new @comment = @parent.comments.build end def create @comment = @parent.comments.build(params[:comment]) if @comment.save redirect_to post_path(@comment.post), :notice => 'Thank you for your comment!' else render :new end end protected def get_parent @parent = Post.find_by_id(params[:post_id]) if params[:post_id] @parent = Comment.find_by_id(params[:comment_id]) if params[:comment_id] redirect_to root_path unless defined?(@parent) end endIt’s not much bigger, but there’s a lot going on here! First, since comments are nested, we have to look for a parent. We’re only creating comments in this example, so we only have those related actions. Comments will always be shown on a post page.
The really exciting part is after a successful comment creation. How do we redirect back to the post page? For all we know, this comment could buried down 12 layers of replies. All we really have access to so far is the parent of the object. This necessitates a new model method:
Recursive functions are often short and sweet for two reasons: they’re already complex by nature, and adding more code than necessary would make them unmanageable. Also, they’re getting a lot done in just a few lines. In this case, the second line is the key: if “commentable” (the parent object) is a post, return that. Otherwise, call this same method on the parent, which will in turn check if *it* is a Post, and so on.
I could have written it shorter, like this:
In fact, I did at first. But the extra code that checks and sets an instance variable is caching the result. This way, if we call the same method on an object more than once, it stores the result for future use. Remember, recursion can be expensive – especially when the database is involved.
Views
Finally, it’s view time, with one more bit of recursion for fun.
Or post views are standard scaffolding mostly, with the exception of the show view:
Notice we have the partial app/views/comments/_comment.html.erb. We’re calling this for each of our post’s comments. Nothing too fancy here. Now, for the partial itself:
# app/views/comments/_comment.html.erb <li class="comment"> <h3><%= comment.title %></h3> <div class="body"> <%= comment.body %> </div> <p><%= link_to 'Add a Reply', new_comment_comment_path(comment) %></p> <% unless comment.comments.empty? %> <ul class="comment_list"> <%= render :partial => 'comments/comment', :collection => comment.comments %> </ul> <% end %> </li>This partial is recursive! The comments controller doesn’t have a show method, because we’re never going to view a comment by itself. Instead, the show-like code is in this partial, and at the end it checks to see if *this* comment has comments. If so, it calls the partial again on the whole collection. The end result is a nested, bulleted list of comments. This is not very sexy if you fire up the code yourself, but it’s a great starting point.
Summary
Hopefully this article as done a good job of explaining both recursion, and how to use it to achieve nested comments in your applications. If you’re new to recursion as a concept, haven’t seen Inception, didn’t inherit russian dolls from Nana or receive them as a snazzy graduation present, and my explanation somehow fell short, it’s a well documented programming idiom. There are tons of resources online, so take the time to learn this powerful tool, then learn not to overuse it :)
Please download the code and play with it if you want to learn more – the code is fully test-driven so you can see how that works, which is just as important.
On a final note, I’m tempted to do a follow-up article with ajax and some nicer formatting. Perhaps in 3 months and 3 days…
Tags: comments, nesting, polymorphism, posts, Rails, recursion, recursive, Ruby, ruby on rails
Posted in Database, Rails, Testing | 5 Comments »