Now, I love Ruby on Rails. Really love it. I’m using it for business and for pleasure. And it’s now got me writing boring scripts in Ruby, just to learn the language better. And, you know, it’s a lovely language. So while advocacy and promotion of RoR as a way to develop your webapp is all well and good (because, after all, it’s one framework (albeit a pretty darn good one) amongst many), every now and then the hype bandwagon strikes. Like in this introductory article on Sitepoint, which contains the cracker:

“…without Rails, Ruby is nothing!”

Oh dear.

Rails might have brought Ruby to popularity, but seriously, that sentence is as big a pile of nonsense as any I’ve seen. It’s these kind of sentences, uttered off-hand by Rails-converts still in awe of the hype-bandwagon, that damages the Ruby community – and makes you look like an arse.

Memo to self

19 March 2006

Memo to self: bash profile is in /etc/profile. Not anywhere else, they don’t work. No idea why. But next time you need to alter your $PATH – it’s there.

So I’ve been fiddling with Rio recently. I’m trying to write a little script to find and replace throughout a directory – and all its subdirectories, recursively. Given the end result of this might end up being an application based upon Rails, it seemed best to write this in Ruby. And I remembered someone (Tiest, I think) mentioning Rio at one of the LRUG meetings. So I gave it a shot.

Rio is, in short, lovely. It acts as a convenience wrapper around a whole host of modules – including Kernel, File, Dir, and others – and basically makes reading and writing files a doddle. It’s also quite powerful, and makes batch operations across directories really easy, once you’ve figured it out.

So my global find/replace script comes down to this:

rio('dirname').all.files.skip(/^\./).do |eachfile|
   eachfile < eachfile.contents.gsub("search", "replace") end

And that's it. Obviously, this being gsub, "search" can be replaced with any regular expression of your choosing. I'm sure I could do it faster in sed/awk/grep, but I'm not as familiar with them as many - and this way around, I can patch this snippet into a larger Ruby application. The skip clause forces Rio to ignore files beginning with a dot, as .DS_Store and friends cause it problems (it seems).

Anyhow, I'm very impressed with Rio - saves a lot of faffing with read and write modes - and can highly recommend it if you need to faff with the file system in Ruby.

Rails and Hypercard

22 December 2005

Gavin mentions the idea that Ruby on Rails might just be the new Hypercard – something I may or may not have discussed with him.

I think he’s right. After one of the London Ruby User Group meets, someone commented that all Rails really needs now is a killer easy-front-end for page layout, or an IDE for apps of some form, and it could really hit the jackpot. I immediately thought of Hypercard; it had the requisite simplicity, grace, and convention, and would be nicely suited to Ruby (just as it was to Applescript).

I’ve mentioned Hypercard before on this site. It was pretty formative in me finding a way I could program computers that wasn’t necessarily reams of code, of first making me aware of UI design, and of making programming fun. Rails has had a similar effect, properly kick-starting me into OO programming, and finally making me understanding and appreciate scripting languages.

The speed of gettings things working, that’s what matters. Not finished – finished might be a long way off – but you’ve always got something to show for your labours. That’s why I like it.

Rails 1.0 (and Locomotive)

14 December 2005

Congratulations to David, and, of course, the rest of the rails-core gang for getting Rails 1.0 out the door. Much promised, long awaited. I’ve been runing 0.13.8 consistently, and decided not to upgrade to the Release Candidates, instead holding out for 1.0.

Well, my Powerbook reinstall went smoothly last weekend, and all that’s left is to install Rails. I was going to follow Dan Benjamin’s excellent instructions, but decided to leave it a few more days for 1.0. That day came early! Unfortunately, life is chocka right now, so there just isn’t time to install it til the weekend. That’s when I gave Locomotive another shot; a self-contained install of Rails, lighttpd with FastCGI, and sqllite. Very impressive, too; just pointed it at a development app, added it to the list, clicked “run” – and there we were in the browser, running on Rails. For the next few days, it’ll let me vent my PHP frustration with minimum hassle. Come the weekend, I’ll install 1.0 proper. Can’t wait to get back on the railsroad…

Symphony finally launches

08 December 2005

Symphony, the slightly-awaited publishing/blogging app from 21degrees (who don’t have a website – it now redirects to Symphony) that’s been under wraps for yonks, finally launches. According to the marketing gumph, it gives you the “power and flexibility to make your dream website a reality“.

Maybe – but I’m not sure it’s going to when it’s using XSLT, of all things, as its templating language! It’s not too complex, but it is a fussy, very un-plain-english way of defining templates. It’s a similar problem to the one I have with WordPress, which just uses PHP functions rather than any abstract templating language. Neither are particularly difficult, but they are fussy, and they’re not like HTML – which is something many people may know.

In fact, looking at it again, their use of XSLT to make a “for-each” loop is just horrid. So in short: nice idea, but I can think of an awful lot of people who’d be put off by XSLT, no matter how compliant it is.