Archive for the 'Ruby' Category

Groovy is what it says on the tin

Tuesday, 27th February, 2007

I can’t believe I never stumbled across this before; I’ve seen a few posts about Groovy on dzone.com previously and just ignored them. A couple of weeks ago however I bother to investigate this language - how I wish I’d done this earlier!

I recently bought the second edition of Agile Web Development with Rails, which is good and all but when I scour the net to see where Ruby is on the job front, it’s pretty bleak (at least in the UK if you don’t live in London).

Back to Groovy though; the first time I stumbled across some of the source I smiled - this is what I’ve been waiting for… I can see how the reduction in syntax could make purists turn red faced but from a productivity standpoint, not having to write such overly verbose code that is Java really appeals to me! (probably my nasty PHP habits)

It’s made Java fun again, dare I say it, it’s made Java groovy :) (please put down those tomatoes).

I think stumbling across Groovy now is no co-incidence, what with version 1.0 just out the door and numerous books making it to the shelves. Things went from good to great when I Googled around for some Grails tutorials - the amount that can be achieved in such a succinct amount of code was a breath of fresh air.

Working with PHP all day (not exactly a verbose language), Grails looked like a significant improvement in productivity. Perhaps it’s the pedigree of the developers that have forged Groovy and Grails - PHP has always suffered from it’s low barrier to entry - Grails looks well designed and time will confirm this for me.

I’ve ordered Groovy in Action, and PHP in Action just for the hell of it (I saw Marcus Baker (who ran the PHP London user group until Mar 2007) in the authors list and thought this has to be a decent read since I’ve seen him speak nothing but sense on SitePoint’s PHP Application Design forum).

I’m not the only one who’s enthused… hopefully given Groovy’s heritage and the volume of Java programmers that can make an easy switch; commercial acceptance may be faster than that of Ruby, or at least taken more seriously/readily by big(ger) business.

Prototype’s Array Extensions

Friday, 23rd February, 2007

I had cause to use script.aculo.us at work today, which depends on the Prototype framework. I’ve used Prototype previously (in fact on this very blog!). However, when I dropped script.aculo.us in on the site I was working on, all hell broke loose with my JavaScript breadcrumbs.

I was dynamically populating two arrays via PHP, one for the page captions and the other for the page URLs, JavaScript was then used to combine these arrays by way of Array.push() and Array.join(). After a few minutes debugging I realised Prototype was the culprit, spewing out a wad of JavaScript source all over the page header (innuendo not intended!).

A few more minutes Googling and I’d discovered it was Prototype’s Array extensions at work that had broken things. As explained by David Bergman iterating over an Array using a for (i in array) reveals the extensions added to Array class.

The author of Prototype (being a “Rubyan”) added these extension to bring JavaScript a little closer to home for the rest of the Ruby community. Converting my for to Array.each() remedied the problem - worth noting for future reference and hopefully this will save someone else 10 - 15 minutes head scratching. Thanks to David for his fine explanation and solution to the problem!

First impressions of Ruby (not Rails)

Sunday, 24th September, 2006

Free time has been scarce recently but I’ve slowly been working my way through this tutorial on Ruby. I figured I’d cover all the basics before jumping head first into rails.

Ruby feels like a step forward in programming compared to a step sideways when I’m learning Java. For example, Java and Ruby both have automatic memory management yet in Java there are still four different sizes of integer (byte, short, int and long). Whereas Ruby being more human than machine orientated simply has integer.

A useful feature I’d like to see make it’s way into PHP are the attr_reader, attr_writer and attr_accessor attribute visibility functions. These save a fair amount of code you’d otherwise have to write in PHP and Java when providing accessors and mutators.

I’ve only scratched the surface so far but I can already see the appeal of this language - it’s succinct and the code to functionality ratio is refreshing.

You are currently browsing Mostly PHP MySQL Javascript Linux, some Ruby Java frameworks agile methods but overall web programming and software development in general archives in the Ruby category.

Categories

My Bookshelf

PHP in Action: Modern software practices for PHP Agile Web Development with Rails
xhtml 1.1 compliant   xhtml 1.1 compliant