Writing On Ruby and Backbone.js

Jun 2013

Writing is about composition, argumentation and ideas. This makes writing very similar to programming.

Not suprisingly, David Heinemeier Hansson, main author of the Ruby-on-Rails framework, mentioned books about writing as path to become a better programmer. What we as writers discover is: Style is hard, finding the right words, applying grammatical rules and sharing preferences.

This is what I am practicing the last months on a book idea. I want to show how small server-side and client-side components can be combined for better interactions with users. The book is about combining ideas from Ruby and JavaScript.

Ruby has been a great tool in my programming expeditions. Ruby is about a programmer’s happiness. Ruby provides some of the cleanest and most elegant syntax for a programming language I know of. Syntax is crucial. Ruby allows to form expressions that are very close to the line of thought we do in everyday thinking:

 Journey.new.visit(barcelona).take_photographs([segrada_familia, beach]) 

Recently, I feel that Backbone.js provides an interesting extension to this line of thinking. In contrast to Ruby, however, Backbone.js communicates differently with a programmer. Backbone.js provides hooks for ‘listening’ to events, and ‘rendering’ and ‘transport’ of data. So, the set of verbs for in Ruby and Backbone is similar and different (think on the verbs: save, find, render, each, map, rescue). However, the similar and different semantics are very relevant to the server or browser environments where the verbs are used.

Additionally, Ruby and Backbone (with Underscore.js) provide nice ways to compose objects, and encapsulate processes and data. Whereas in Ruby-on-Rails, we intuitively can work with storage and HTTP, Backbone.js provides Views, Events, and (also) Collections and Models. The similarities and differences among server and client will be the topic of my book**, that I hope to publish after the summer. My blog updates will be less frequent therefore.

** It is the topic of the talk I will be giving at Rubyday.it 2013 in Milano

Leave me feedback

Follow me on Twitter here.

comments powered by Disqus