Sunday, October 12, 2014

Experimenting with Clojure + Ember.js and ClojureScript with Om

For a personal project I want to make a web app with a "rich client" interface. I had originally planned to write this app in Haskell with the Yesod web framework. However, as much as I like Haskell, I do still have occasional time wasting problems with cabal, Yesod, and sometimes with non-pure Haskell code. My gut feeling is that I will get things done faster if I use Clojure.

In the past I have experimented using Clojure and Ember.js but until today I have not spent much time with ClojureScript and Om (I have written web apps using ClojureScript, so the learning curve is trying to use Om).

Getting started with Om is straight forward. I used the chestnut lein plugin to create a new Clojure + ClojureScript + Om project. The chestnut plugin is very nice - it set up a reasonable development environment without having to go through a learning curve. After experimenting with the generated project, I then starting substituting in code from David Nolen's Om tutorial into the skeleton project that the chestnut lein plugin created.

I am not much of a user interface expert, and I am not sure how much time I will devote to learning Om. If I earned my living doing web apps, this learning curve would be very worthwhile. I usually use simple tools to make web apps like: Ruby + Sinatra, sometimes Rails, often Clojure + composure + hiccup.

A few years ago I did experiment with Ember.js and created small projects on my github account to experiment with Ember.js with various backend services. Today I cleaned up my embers-clj sample project. I removed the use of the old noir library and made this a straight-up compojure app. I also changed the JavaScript Ember.js application to remove two deprecation warnings.

I am leaning towards using Ember.js, mostly because I already am familiar with it. I also like the combination of Ember.js with a node.js backend (my started project for Ember.js and node.js is also on github). There are advantages to using JavaScript for both client and server sides but I like Clojure better.

1 comment:

Dmitri Sotnikov said...

I found Om to be rather complex as well and ended up using Reagent ( instead. I would definitely recommend taking a look at it if you're looking for a ClojureScript React wrapper that's simple and effective. I actually ended up adding support for it in Luminus, so setting up a project for Reagent is as simple as lein new luminus myapp +cljs