Developer Happiness with Volt Framework

heri
Product dot IO
Published in
4 min readSep 9, 2015

Looking for fresh events? HeyMontreal wants to show you what to do in Montréal today.

This simple app answers the recurring question in family visits and Montréal exploration: “How do you find interesting new events?” Facebook lets you keep up with your interests but does not lend well to discovery. Sites like voir.ca or camuz are great to find up-and-coming cultural shows but not comprehensive or fresh. I pictured instead a page where top suggestions would emerge, and if you have more time, also discuss with others.

With that in mind, the site had to be dead simple, mobile-friendly with relelvant results and good i18n for international travellers. More importantly, it had to be developed fairly quickly with minimal maintenance as I only had a couple of weekends to work on it.

This direction eliminated from the get-go Ruby On Rails. If developing an app with Rails was a blessing 10 years ago, now it has become extremely complex:

The growing complexity of frameworks (Rails) from @ryanstout

As single page apps become more common, more and more logic becomes duplicated between the front-end and the back-end. Developers find themselves having to write ugly API glue code to pass data between the server and the client.

This is when I came across Volt Framework.

Volt is a MVVM ruby framework. It compiles Ruby to Javascript with Opal (see here). The same code can be run on the browser and the server, which removes the boilerplate of front web development and lets you produce apps in minimal time.

These are Volt’s strengths that I liked.

Isomorphism. Reuses same code on front-end and back-end, which leads to faster development.

Reactive bindings for the DOM. Any user changes are reflected seamlessly to other connected clients and to the database. For example, you can code a chat app with only a few lines. On the view side:

On a controller:

And that’s it! You have a chat app with full reactive front-end. No database configuration, no model setup, no javascript. View on github

Components. It’s fairly easy to code UI components, such as text fields, date and time inputs, user login, Google Maps and package them in reusable building blocks for applications. You can think BIG and have entire single page apps made available as components. I can imagine an admin component, nice navigation or video view components being made available to the community.

Promises is Volt’s Graceful handling of asynchronous calls, and is used on the client and server. For example, database queries return a promise. Bindings on the front-end also take promises which will render when the promise resolve. See how it’s much more readable than the callback hell you usually see in node.js:

Different stores available: cookie, page, database, local storage (i.e. the user’s browser), flash etc.. What’s remarkable is that none require configuration. If you choose, new attributes can be added on the go. For example, here, I decided to add “created_at” to new comments, without having to do anything to the model comment.rb

All these are elegant solutions that other frameworks tried to handle with distinct complex machinery. Volt puts all of them together in a concise and clear way, and makes me happy.

Even if Volt Framework is fairly new (currently v.0.9.5), it already packs a lot of interesting features for developers interested in building small isomorphic apps, and has a nice active community on gitter.

Performance wise, the compiled code runs slightly slower than the same in comparable JS frameworks but then again, you can keep working in Ruby :)

The result is developer happiness. It’s the same feeling with the first screencast by DHH in the early days of Ruby on Rails, before you had to bundle install 30 gems before being able to start anything.

Next I am going to write how I used a persistent Bayes Classifier to make sense of all the data on heymontreal, and the use of Font Awesome for i18n apps

--

--