Saturday, June 28, 2008

Ruby on Rails - Rails = SproutCore

The world of Apple fanatics can't get enough of the word "SproutCore" ever since WWDC.  So I decided I'd give it a try.  After reading everyone else's review, I suspected it'd be something like Prototype and script.aculo.us, and  I really couldn't see the need for yet another JavaScript framework for graphics and XHR requests.  I also didn't really see the open-source community going head-to-head with two of its own favorites.
What I found was completely different.  Whereas Prototype and script.aculo.us try to take your webpage and make it more appealing, SproutCore wants to get rid of the page and make sure you are building a web app.  For starters, it comes with its own widget set, so everything from buttons to combo boxes to text editors are themed, or you can just force them to use the system chrome.  But under the hood is the most impressive thing: SproutCore is a complete MVC application, all in static JavaScript, HTML, and CSS.
And some Ruby.  The SproutCore build tools are a lot like Rails, in that they are a Ruby Gem that you get with the traditional

sudo gem install sproutcore
method, and to create a new SproutCore project you type
sproutcore hello_world
at the command line. To see what your project looks like you go into the hello_world directory and type sc-server. Look familiar?  Also like Rails, the initial sproutcore command creates a full directory, and there are many helpers, generators, etc that all build the project for you, so that creating your models, views, controllers etc is amazingly simple.  Views are .rhtml files, just like Ruby on Rails, and are interpreted into static HTML/CSS via erb.  Controllers and Models are JavaScript files, so you can put in whatever JavaScript you want as long as they implement the correct classes and respond to the required events.
When you project is finished you run a single command to turn the whole thing into optimized, static HTML/CSS/JavaScript, and you can then upload that directory anywhere you want it, on any server and it will run.  It can interact with any backend technology, so long as it responds in JSON and accepts standard POST and GET requests.  This is a huge advantage over Ruby on Rails, where hosting is still expensive and finicky to get put together.
SproutCore isn't perfect. It's still pretty young (my installed version is 0.9.11) and the documentation is far from complete.  There are many functions that aren't available yet, but I suspect that a judicious use of other popular frameworks will alleviate that particular pain.  There is the question about loading your entire app into the user's browser, but to understand that you need to realize what arena SproutCore is competing in.

SproutCore isn't, as I first thought, an answer to Prototype, it's an answer to Flex and Silverlight.  Where Flex takes an entire MVC app and wraps it in Flash, SproutCore wraps it in JavaScript (I haven't played with Silverlight yet, because I hate it. Not because it's Microsoft per se; I would have hated it if it was from Google.  I just really don't think we need another plugin-based browser programming language. But that's another article).  This is refreshing because it does away with the plugin and works with native browser technology.

Now I have to say: I really do like Flex.  Adobe has done an excellent job of turning Flash into a business tool, and the AIR runtime is just too easy to use.  But it's clear that Flash on the iPhone is a distant dream, so people who work on that platform are going to lose out.  For that matter, waiting for each individual vendor to implement a Flash plugin for their mobile device is fraught with frustration, so it's nice to have a fallback that will work on any even reasonably standards-compliant browser. 

So my recommendation is to give it a shot. Learning new technologies is always beneficial, and this one seems to be a real up-and-comer, if only because Apple is putting a lot of money behind it.

Tuesday, June 17, 2008

Firefox 3 vs. Opera 9.5

I can't help it, I love Opera. I have paid $60 to the opera foundation (to register Opera 6 and 7) and felt the money was well worth it at the time. After all, Firefox didn't quite exist yet (I discovered Opera 6 when Firebird 0.something was the Mozilla offering) and IE was, is, and will be crap. (I should probably look at the number of IE users I have coming to this site before I say things like this. Naaaaah.) Anyway, even in Opera 6 I saw amazing speed, standards compliance, and innovation (tabs were an Opera thing, remember?) and I was duly impressed.
And now we come to 2008. Firefox 3 is out and Opera is on version 9.5. And I gotta say, I'm impressed on both counts. Here's my first impressions.

Opera


Opera has added a few features, like Opera Link, which does a .Mac style sync of your bookmarks, notes, and other little browser customizations. I have to say that one of the only reasons I've been using Safari on the Mac is that I know that I'll have my bookmarks on all my computers. Opera getting this ability is a definite step in the right direction, and being able to do it without $99/year is a nice thing as well. I realize that there are add-ons for Firefox that will do the same thing, but built-in is always nice. Opera has had a face lift on both the Mac and Windows, but to my mind the Windows theme is far nicer than the Mac one. Again. The new Dragonfly feature is nice, but looks suspiciously like firebug, to my eyes. I can't do any really accurate speed tests right now, but it moves right along, and does a good job rendering HTML and JavaScript as usual. Speed Dial is a feature that I wouldn't install as an extension, but I have to admit that I like it when I have it in Opera.
Opera also has the best kiosk feature I've ever come across in my puff. I've put it to use a number of times with great success.

Firefox


And then there's Firefox, the jewel of the open source community. It's fast, light (even lighter now that they've fixed some of the memory leaks that plagued version 2) and infinitely extensible, it's the browser that does what you want. The vanilla install has some nice new features, like the super-easy bookmarks, bookmark tagging, smart bookmarks that allow you to move back and forth over your history easily, and (finally!) full cocoa compliance on the Mac. Firefox has looked (and occasionally performed) like crap on the Mac for a while now, so it's nice to get some real widgets. No, it's not important, but it is nice. Contrary to Opera, the default Firefox skin is far nicer (in my opinion) than the Windows default. I kinda like that. But at the end of the day the reason we all keep using Firefox is the lovely extensions. I'm writing this in ScribeFire, with AdBlock Plus and ScriptBlock both keeping me safe from web nasties.

Overall


Overall, I have to give the nod to Firefox.

Friday, June 13, 2008

Flex Builder 3: Impressive

I spend an inordinate amount of time writing about Eclipse-based software.  I have to say the platform has grown on me, but there are things about it I still don't like.  One is the all-or-nothing approach to different vendors' add-ons.  I use Aptana, Zend Studio, and now Flex Builder 3, all of which are based on Eclipse.  The problem is this: I could use one base install of Eclipse and install all three of these as plugins, and they would each bring their own perspectives, views, menus and suchlike.  Theoretically, they would all stay out of each others' way and the whole thing would work beautifully.  In my experience doing that however, it meant that context menus were insanely long, there were tons of choices that didn't apply to what you were doing in case you started doing something else, and the whole mess took forever to load.  I eventually deleted the whole thing and did three separate installs.  The problem with that, of course, is that you have three identical copies of the base software, but with hard drives as large as they are these days that's not much of a problem.  

But this wasn't meant to be a continuation of my Eclipse rants.  I meant to write about Flex Builder 3, which I am impressed with, IDE platform to one side.
Flex, which Adobe hopes will be the next big thing instead of Silverlight, or AJAX, is really just Flash dressed in business clothes.  Gone is the timeline, gone the library of images and movies and bits, and everything focuses on what you would do with Flash if you were going to use it for websites instead of cartoons or games.  I approve of that.  Flash and the Flash IDE are great for web animation and games, but the Flash plugin has far too much power to be used only for Homestarrunner.com.  (the only web animation I've ever liked, by the way)

Flex lets you make things that do work.  It's designed from the ground up to work with AJAX-style HTTPRequest objects and accept data from remote sources in plain text, XML, JSON, or RPC notation, your choice.  It is built to easily display multi-page forms, and making transitions between pages is as simple as giving the transition you want an id in the XML source code.  I've done RPC-type stuff in Flash 8, and while it's possible, it isn't fun or easy.  It's both in Flex.

Much has been made of the AIR framework, allowing you to write apps in Flex and deploy them to the desktop, so all I'll say is "You can write apps and deploy them to the web or desktop. That's cool".

Most Flex apps will have three parts: the XML (all in the mx: namespace) that defines the objects in the app, the Actionscript that defines what the app does, and the server-side code that gets and sets data for the app.  The first two parts are handled in Flex proper, while the third can be written in any language with which you are comfortable.  I mostly use PHP, but RoR works just as well. As long as your server understands the requests coming in (GET or POST, by the way) and can send intelligible responses back, you're set.
The XML part is very similar to XHTML, with specialized options for more advanced forms or displays.  XHTML doesn't have a , but MXML does have an that accepts external data and lays it out in a scrollable, editable table.  Tags have predictable id properties, will accept style, height, width, and other properties that you would expect to give them if you were writing XHTML.  The Flex Builder application makes all this easy to do with good tooltips and a context-sensitive help menu that usually lists the API for whatever component your cursor is in at the top of the list, a far cry better than Flash 8's help function. Unlike any other WYSIWYG editor I've ever used, I rarely find any reason to argue with the code the "design mode" editor writes.  If you know what you're doing you can set farily complex style rules on things from design mode and the code will be clean and valid.  There are advantages to being in charge of the IDE and the parser.  the namespace is tightly controlled, and I appreciate that.

Actionscript is Actionscript, so if you've ever used it in Flash you're ready for Flex.  I've been told it's quite similar to JavaScript, but, embarrassingly, I've never gotten around to learning JavaScript.  Sorry.  On the plus side, Flex apps will run on any browser that allows Flash, no JavaScript required.  

All in all, I only have two problems with the Flex builder: the first is the Eclipse strangeness mentioned earlier. The second is the price.  I got Flex Builder for cheap because I'm an employee of a university.  Most people pay hundreds of dollars.  (although they are giving it free to students).  To my mind, charging a lot for the IDE isn't a clever way to take over the internet.  Yes, the API is free and open-source, but writing the code entirely by hand without a debugger and code tips and all that isn't fun, and few people will do it.  

Still, in spite of these two drawbacks, Flex is an elegant solution to getting content rapidly designed, tested and deployed, and in a world where almost everyone has Flash installed on their computers, It's an attractive alternative to AJAX.  Give it a shot.

Tuesday, June 3, 2008

Tents and Computers

I was in the desert recently, doing some old-time family camping and jeeping.  My wife and I used to backpack all the time, but with two kids it gets very difficult to fit into a backpacking tent and fit all your gear into you backpacks.  So we threw in the towel and got a family camping tent.  It's actually called the "Family Camper 7"  It is big enough for 8 adults, so two adults and two kids (with all gear needed for a 1-year-old and a 3-year-old) just fit.  The tent is made by Springbar, a company here in Utah that's been making quality tents forever.  We have proof of this: We were camping with my wife's family, and at our camp we had our brand-new springbar, my in-laws had their "new" Springbar (25 years old) and their "old" Springbar (35 years old). My brother-in-law also had his "new" Springbar that he bought used for $75, which we figure is probably about 50 years old.

What, you may be asking, am I doing talking about tents in a tech blog?  The ages of the tents involved should answer the question.  If you take a look at a Springbar, you can see why they last so long.  They are solid canvas with heavy-duty zippers.  The pole system is simple, built out of steel poles instead of fiberglass, and is external.  One person can pitch a tent in about 20 minutes, two people in about 10.  All the seams are doubled over and double-stitched, so you don't have to worry about one coming open.  Yes, these tents are much, much more expensive than ones you would get at Costco or other places, but if they last upwards of 50 years I would say it's worth it.  

Forgive the partisan view, but this is strongly reminiscent of the way Apple does things.  My father-in-law, the same one that has two Springbar tents, also has an original PowerMac, an original iMac, and (finally) an original Intel iMac, which I made him buy when I got tired of doing tech support on OS 7.  But the computers are well-built, well-designed, and durable.  they cost more, but they last, and they are something that you can be glad you own for a long time. 

Don't get me wrong; there is a place for inexpensive tents that you can take anywhere, and there's a place for do-it-yourself tents.  My cousin's husband has a "tent" that is a pole and a blanket. He uses it for snowcamps, and it's perfect for what he does for a living. Carrying a 70 pound tent  in his pack is just a little stupid. All I'm saying is that there is great value in having something that is simple because it was well thought out before it was ever built.  

Thursday, May 22, 2008

Delicious Library: Still pointless

So, about 1.32 years ago I got a copy of Delicious Library as part of the MacHeist bundle. And I thought, "Wow now I can keep track of all my books, music, and DVD's." And dutifully started scanning them all into the Library with my built-in iSight camera, just like a good little Shipley-ite. Then when the world-renowned David Pogue reviewed DL, I thought, "See? It's cool to spend hours scanning things!" Also like David Pogue, I got a bit bored with scanning things after a while.

Then came the real boredom: what to do with the product after I'd scanned everything in. I could look at my books, but for some reason I never think "I'd like to read a book. I don't want to go to my bookcases, look at my actual books, and choose one to read. So I'll go to my iMac, look at pictures of the covers of my books (except for the ones that are out of print or aren't carried by Amazon) and choose one there. Then I'll go to my bookcases and pick it up. The same goes for music and DVD's. I have a database for music. It's called iTunes, and it does a much better job of picking up all my album covers than DL/Amazon.

"But wait!" I hear you screaming, almost rabidly, "What about checking books out to your friends! Now you know exactly who has your books, movies, or DVD's, and when they're due back!" Yes, I could do that, but tell me, what kind of looks to do you think you'd get if you said, "sure you can borrow that book, but first I need to create an account for you in my library software, check it out to you, and assign you a due date" I tried it a couple of times. Mostly the response I got was "Umm, never mind. I guess I don't want to read it all that much anyway." And nothing says "you are a true friend that I love, respect and value" like a "hey, you know that book you borrowed from me? It's two days late" email. So if DL is meant to keep all your books/music/videos/games in your library and alienate people, then the checkout feature does a great job!

At the time they were promising DL 2.0 "any day now™" And now, they're promising version 2.0 "any day real soon now!™" So we may soon get to see what features will be in version 2.0 that make it more worth my time than version 1.6.

But I'm not holding my breath.