Sunday, March 3, 2013

building a tree: my first three weekends with javascript

I guess I have been writing java code for quite a while now, and it still makes my living. But for the last twelve months I have been working in the agency business and I finally wanted to havy some control of whats going on in the browser.

I set myself a simple, but non trivial goal: I wanted a lazy loading tree backed by orient db only using commercial-friendly licenses.

  • Dojo
Being used to the big java-frameworks, dojo looked promising. But the dojo tree is outdated, needs api adapters to work with the current store backend. making the rest store lazy load and adapt the orient db objects still didn't work after two days of code investigation. So I dropped it as a #fail.

  • jQuery/jsTree
I got jsTree with jQuery working quickly. Adapting the json from orient to json for jsTree was simple.
But: unlike dojo jsTree has no concept of a model. So the thought of propagating changes back in to the tree model looks like #pain and made me drop that too.
  • homegrown/angular
Finally I gave myself a kick and grew my own tree with angular (using a recursive template and some css magic). And although I'm a javascript beginner and had little to no idea about angular concepts I got a working tree in less than two hours. I wrapped angulars resource in a service that wraps the orient objects with stuff needed for the tree and rendered the tree with a template recursion. It was so simple.

Conclusion
I didn't look too deep into backbone. Dojo seems a little over-engineered and not consistent in its development state. jQuery is nice sugar, but its not a serious programming framework. I think I fell in love with angular. 

No comments:

Using Mapstruct with Protobuf3