|
Last Friday, July 11th I participated in the day one of ShoesFest. Shoes is a tiny Ruby GUI toolkit developed by _why. With Shoes it's very easy to make nice, small desktop apps that run on Windows, Mac OS X, and Linux.
The purpose of ShoesFest was to spend the day hacking together Shoes apps, finding bugs, and helping _why with cross-platform stability. From that perspective, I'd say it was a resounding success. Here's my recap of how the day went for me.
Prep Work
I've been following Shoes for a long time. Right now Vying Games is strictly a webapp, but I've been keeping an eye on the various Ruby GUI libraries in case I'd like to develop some related desktop apps. Some of Vying Games is already open source -- like the libraries for the game rules and the AI for the bots. So, going into ShoesFest I knew that I'd like to build a UI on top of those libraries.
My libraries are packaged up as gems. RubyGems has become the standard way of packaging Ruby code, but Shoes has had kind of an indifferent relationship with RubyGems in the past. Shoes is actually completely self contained. It comes with it's own copy of Ruby, and an array of prepackaged libraries. If you already have Ruby installed it doesn't use it. If you already have a bunch of gems installed it doesn't use them either. Instead, your Shoes app tells Shoes what gems you want and it installs them separately:
Shoes.setup do
source "http://vying.org"
gem 'vying-pure'
gem 'starbots'
end
require 'vying'
So, a week or so before ShoesFest I wrote a tiny Shoes app just to test that I could get access to my gems. The above code worked beautifully, so I decided to give ShoesFest a try.
A number of people have requested that _why package Shoes as a gem, and he's made it pretty clear that he prefers this approach. Shoes is mostly C, incorporates the Ruby interpreter and libraries, and several different UI libraries (some of which are platform specific). Setting up the build process for Shoes, targeting Windows, Mac OS X, and Linux, was, I'm sure, no small feat. The result is one small installer with everything you need for a nice little Ruby environment.
I will be curious to see how gems with their own C extensions will work out under Shoes. In the above sample I request the 'vying-pure' gem. This is actually the 'vying' gem minus its C extension (pure == pure ruby).
The Day of ShoesFest
I got up early, logged into #shoes and started with my goal of porting the UI for Breakthrough to Shoes. The channel was quite active, and I have to admit to only skimming most of the conversation throughout the day. I was mostly preoccupied with programming.
It didn't take long to get the board and images for the pieces drawn. I didn't start to run into trouble until trying to manipulate the board. My first attempt at change the color of a square on the board (highlighting it when clicked) met with failure. Shoes wouldn't allow me to change the color of a Shape I'd already drawn. So, I refactored the code so that I could redraw a portion of the board. Crash. Calling clear on an in memory image (an imageblock in shoes parlance), would crash Shoes under Linux.
I created the simplest app I possibly could that exhibited the crash, and informed _why about it. He was, by the way, very active on irc fixing bugs and helping new shoes developers. Rather than wait for a bug fix, I cut the code for highlighting squares and moved on.
Next, I tried to change the mouse cursor to a hand when over a piece that could be moved. Another crash. This time _why had the fix out before I hardly had time to move on.
I was on the verge of having a working Breakthrough app. So, naturally, I spent the next hour or so tracking down a bug of my own creation. After fixing my bug, I had a working Breakthrough app.
I spent a couple hours after that working on animating movement of the pieces, and adding drag and drop. My code's a little sloppy, but works nicely.
Finally, I added a few finishing touches, a paragraph explaining the rules for Breakthrough. A bot opponent. A hot-key to start a new game. Nothing even close to what a real desktop app would need, but good enough for a small demo.
Packaging
Shoes comes with a little packager to build a compressed archive of the files that compose your Shoes app, creating a .shy file. In my case, I had one source code file and two images. Found another bug. The packager was hanging. This time I hunted through the Shoes source code until I'd found and fixed the bug myself.
Shoes also comes with a packager to wrap Shoes and your app up into a single executable for deployment. At the time of ShoesFest I was under the impression that this packager wasn't completely working, yet, so I decided to skip trying it.
Final Result
I uploaded my Shoes Breakthrough app to The-Shoebox and announced it on #shoes. And, to end the day on a slightly anti-climatic note, it turned out the gems weren't loading on Windows and Mac OS X. So for the time being, my app only works on Linux.
My code is available at Github:
Thoughts on Shoes
I think Shoes has a promising future. I'd like to see it become the Ruby GUI, but it still has a long ways to go. I worry a little that the future for Shoes rests a little too much with _why. He's a great programmer, and he's done an excellent job with Shoes. I'd just like to see a core team of a handful of people. _Why's stated recently that he plans to devote another 3 years to the development of Shoes. This is great, and hopefully over that span of time we'll see more core contributers. I've been following Shoes on Github, and I've noticed that _why has been receiving more patches lately. I'll take that as a good sign.
Overall, I enjoyed working with Shoes. There's another ShoesFest scheduled for July 25th, which I also plan on participating in.
|