CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • 5.0 Saloon »
  • JS MVC framework decision time
Pages: [1]

Author Topic: JS MVC framework decision time  (Read 5055 times)

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
JS MVC framework decision time
June 03, 2014, 05:53:03 pm
One of our GSoC students is proposing to use AngularJS to implement his project - https://civicrm.org/blogs/rajgo94/mail-blast-ui-mockups-and-plan-coming-weeks.

I think we want to make sure this is the right JS MVC for the project overall before he starts coding using it. I don't want one student's prior experience or enthusiasm for working with a popular or cool technology to drive our decision on this, as I don't think we should support more than one of these frameworks. I don't have a strong view on this but alternatives include Ember and Backbone.

Totten suggests in http://forum.civicrm.org/index.php/topic,30900.msg132631.html#msg132631 that it would be useful to have a JS MVC as part of the 5.0 technology stack and I agree.

Eileen brainstorms using AngularJS as a replacement for pages at http://forum.civicrm.org/index.php/topic,32127.msg139369.html#msg139369.

Some old brainstorming and still useful thinking about requirements and ideas for replacing profiles is found at http://wiki.civicrm.org/confluence/plugins/servlet/mobile#content/view/73924905.

D8 will use Backbone. I don't know about WordPress current or planned versions. I don't think we should put weight on what Joomla! is doing.

Here's an intro comparison of them http://readwrite.com/2014/02/06/angular-backbone-ember-best-javascript-framework-for-you#awesm=~oGaFpemHa1163A. See average tab of http://www.infoq.com/research/top-javascript-mvc-frameworks for Angular lead. See sample code in various frameworks at http://todomvc.com/. See strong lead in google trends at http://www.google.com/trends/explore#cat=0-5&q=angularjs,%20backbone.js,%20ember.js,%20knockoutjs&date=today%2012-m&cmpt=q. I couldn't find a good category at builtwith: http://trends.builtwith.com/javascript/framework.

From skimming I think the biggest differences are that backbone is slimmer and less opinionated and often ends up with coders producing repetitive boilerplate even if better programming might avoid that. Angular is very opinionated and can lead to coders fighting to work around its approach/strictures. A purported benefit is that it encourages coding styles that are more testable. Ember seems to be in between on both. Although some of the links I provided suggest angular is far ahead on market share other sources suggest the newer entrants have as good or better momentum. I haven't done enough research to come to a conclusion. But knowing would be crucial to my vote for one over another. CiviCRM previously invested in switching away from dojo to jQuery iirc partly on market share as well as DX grounds.

Thoughts and recommendations?
« Last Edit: June 03, 2014, 08:13:05 pm by JoeMurray »
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: JS MVC framework decision time
June 03, 2014, 09:00:34 pm
1) I like really like the chart at infoq.com. The builtwith.com link seems a bit out-of-tune with other measures of buzz/popularity, but the links seemed interesting.

2) For anyone who hasn't seen it, https://github.com/civicrm/civicrm-core/tree/master/tools/extensions/org.civicrm.angularex is an example of implementing an extension for CiviCRM 4.5 using AngularJS.

3) Anecdotally (after doing a significant project in Backbone and medium project inAngular), I've found it much easier to do basic things in Angular than Backbone. With Backbone, you spend a tremendous amount of time learning/negotiating over plugins and resolving basic questions of app organization. Also, I think Angular's document/tag-oriented paradigm is more accessible for folks who were weaned on webdev. There are some parts which take a bit of learning (like writing new "directivies"), but I think the overall learning-curve is more steady/welcoming.

4) Overall, in terms of Angular vs Backbone vs Ember, there are more similarities than differences: in all cases, they provide a bigger community and more structure than our current codebase, but none is a silver bullet, and all require that we (as a community) make a significant investment towards reimplementation. You could flip a coin to choose between the JS MVC's... and I'm not sure it would affect the bottom-line.

5) IMHO, the big decision is how to structure that reimplementation. One approach is to keep our current form/view-layers and only rewrite the business logic.  Another approach is to go screen-by-screen and try to reimplement each screen "in the Angular way" (or "in the Backbone way" or "in the Symfony Form way" etc). But I'm +20 on the architecture Eileen mentioned. You might describe it as "webform_civicrm-everywhere" (but without Drupal or Webform). Most or all of our forms should be generated by an abstract form system that supports data-bindings, reflection, user-configuration, etc.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: JS MVC framework decision time
June 05, 2014, 01:07:57 pm
I don't think we've made an 'final decision' about which framework to use for core work in the future (Tim, correct me if I'm wrong at this point).... BUT it should be noted that Tim and Kurund are building the new CiviCase Configuration UI functionality using Angular. This will be part of the 4.5 release and is mostly working and viewable in the sandbox (code on GitHub in master branch).
Protect your investment in CiviCRM by  becoming a Member!

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
Re: JS MVC framework decision time
June 05, 2014, 01:20:46 pm
So I would say we are sliding into a decision. It is good that after developing experience with AngularJS no red flags have been raised.
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

Jeremy Proffitt

  • I post occasionally
  • **
  • Posts: 63
  • Karma: 2
    • Mobius New Media
  • CiviCRM version: 4.4.x
  • CMS version: Joomla 2.5.x/3.x / D7
  • MySQL version: 5.1.x
  • PHP version: 5.3.10+, 5.4.x
Re: JS MVC framework decision time
June 05, 2014, 07:20:04 pm
I can't really weigh in on the selection for the JS framework, but I do want to add another +20 for completely restructuring the relationship between the forms and the business logic. I don't know if I quite agree with the webform analogy, but the point is well made. As long as the Civi business logic is doing more than providing data to the forms, we are going to be pushing uphill, regardless of the framework on the frontend or the CMS.

**Normally I would have had a lot to say about "ignoring Joomla", but on this particular point, Joomla is doing little, so not much to see. Joomla's JForm is analogous to webform, except it's part of core. A few major developers are using Backbone for upcoming releases, but JS MVC really isn't on the roadmap at this point.
Jeremy Proffitt
Mobius New Media
IRC: JP_EzoD

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: JS MVC framework decision time
June 05, 2014, 07:49:08 pm
I took a look at the new angular UI & it's really nice to use

http://drupal.sandbox.civicrm.org/civicrm/a/#/caseType/1

Although the theming lets it down a lot - feels like 50 shades of grey (/blue / periwinkle) with a big patch of white in the middle. The clean white look is the modern thing. the blue & grey look was modern a few years back.

I'm sure a themer could make some good, relatively simple, suggestions - I would probably just review each patch of grey & say 'could this be white / modern instead' & maybe round the corners on some of the other input boxes.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: JS MVC framework decision time
June 07, 2014, 05:49:23 am
I agree with Tim when it comes to AngularJS vs Backbone. I personally found it is much easier to get up to speed with angular than backbone.

We are planning to use AngularJS was mailing blast UI project.

Kurund
Found this reply helpful? Support CiviCRM

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: JS MVC framework decision time
June 08, 2014, 02:03:49 am
I've done two major BB projects for Civi and none yet in Angular, so I can't compare them but I can say I was underwhelmed by BB and feel ready to try something else. +1 for what Tim said about a steep learning curve with not much payout at the end.

But I'm truly excited for the new form system we've been discussing and eager to get started. Once we've released 4.5 I hope we can start that project in earnest.
Try asking your question on the new CiviCRM help site.

Kevin Cristiano

  • I’m new here
  • *
  • Posts: 22
  • Karma: 0
  • CiviCRM version: 4.x
  • CMS version: WordPress
  • MySQL version: 5.6
  • PHP version: 5.6
Re: JS MVC framework decision time
June 08, 2014, 11:35:52 am
From a WordPress perspective, WordPress has adopted backbone.js.  In discussing this with a lead developer (Andy Nacin) who was part of the decision making process, they felt that to insert a MVC into an existing project, backbone was best -- this is not to say that WordPress felt that backbone was the best MVC, just best for the WordPress project.


JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
Re: JS MVC framework decision time
June 09, 2014, 08:53:46 am
Thanks everyone. I feel good momentum to move forward with Angular for the moment, even if this is not a full and final decision.

One question/concern I have is whether we might end up with WP or D8 pages running backbone with a CiviCRM DOM element trying to run Angular and having conflicts between the two. It seems like an edge case, but I am unsure how pervasive the use of BB will be on the CMS pages into which we need to embed CiviCRM. I would guess the events models are properly namespaced, so this is likely just my ignorance showing.
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: JS MVC framework decision time
June 09, 2014, 02:06:43 pm
I don't have any clear answers on BB/Angular compatibility/interaction, but do have some good news/bad news:

1. Bad news: Between Angular and Backbone, BB is slightly more flexible with how you embed in different contexts. If we were writing cross-domain widgets that would be embedded in other websites, BB would be more suitable. For example, BB has a noConflict() function for concurrently using multiple BB versions. There's some interest and rough-patches from the Angular community, but it doesn't seem to be a priority for Angular's core team, so ETA=>unknown.
2. Good news: It possible to do some customization of the Angular bootstrap. This should allow one to embed an Angular view inside a Backbone view.
3. Good news: The Javascript code for Angular and Backbone don't directly overlap or conflict -- they do use separate namespaces.
4. Bad news: We don't know where Drupal/WP will go with Backbone in the future -- what features/behaviors they'll produce with Backbone and how exactly they'll implement. There's no way to ensure smooth operation in the future when all parts are still evolving.
5. Bad news: Backbone and Angular both aim to support single-page applications where the URL looks like "http://example.com/#/dynamic-page", and the URL is a scarce resource: There's only one URL bar, and it only has one "#", and problems may arise if two different frameworks try to concurrently manage routes based on "#".
6. Mixed news: Managing the "#" isn't strictly necessary in either framework -- it may be possible to disable or re-engineer one or the other. Simplest case: we might have two SPA's on one domain ("http://example.com/#/dynamic-drupal-page" vs "http://example.com/civicrm/a/#/dynamic-civi-page").
7. Good news: There are some shops doing Angular as a frontend on top of Drupal's backend (and it seems likely that there are also people running Angular on WordPress). Even if Drupal/WP don't use Angular themselves, there's probably some pressure for them to not break it.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: JS MVC framework decision time
June 10, 2014, 02:38:43 am
I looked a little bit into grid editors. My take is that the leading grid for angular js is ng-grid. It seems to be one of several based on slickgrid which I did an extension for (that was never completed) & it has a lot of similarity to slickgrid. It has similar strengths & weaknesses (powerful but hard to get your head around) & like slickgrid you need to write your own editors above & beyond a few out of the box.

My take is that athough ng-grid doesn't have feature parity with slickgrid yet it's charging ahead while slickgrid it taking time-out - and it uses angular. I'm not sure quite how strong the similarities are.

Attached is a screen shot of adding grants using a grant-type extension & slickgrid + some tweaks. The highlighted field is actually a select but as I (foolishly) used core js & non api ajax lookups in an extension the contact lookup fields aren't working with 4.5. (NB if we add some more js utilities to core then we have the question as to whether they will be consistent enough cross-version for extension writers to leverage them & what testing exists). The second screenshot was the pop up I was using - tinkering with google address lookups

« Last Edit: June 10, 2014, 02:50:11 am by Eileen »
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
Re: JS MVC framework decision time
June 10, 2014, 12:06:53 pm
Agreed that https://github.com/angular-ui/ng-grid/commits/master is much more active than https://github.com/mleibman/SlickGrid/commits/master.
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

jcasharpe

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 5
    • Woodlands Church
  • CiviCRM version: 4.4.6
  • CMS version: Drupal 7
  • MySQL version: MariaDB 10.0.13
  • PHP version: 5.5
Re: JS MVC framework decision time
June 27, 2014, 11:20:26 am
To add some more to the mix I just came across polymer: http://www.polymer-project.org/. The whole elements idea looks like it would pair nicely with some of the civicrm components e.g. displays of profiles. Of course you'd often be paring this with angular or backbone to do some of the logic.

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: JS MVC framework decision time
July 02, 2014, 05:08:17 pm
The architecture of polymer-project -- with its focus on browser-level support for "web components" -- is really, really appealing. Their website has a nice video presentation posted a few days ago. On the downside: the architecture relies on "emerging web standards", and it seems like browser-compatibility is still a bit of an issue (http://www.polymer-project.org/resources/compatibility.html -- eg even with the "polyfill" compatibility layer, they've got issues in IE+Safari). Anecdotally, the designer app had visual problems for me in FF30. That might be acceptable -- if we have a lengthy timeline for 5.0 and if we don't need it for the frontend UI.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • 5.0 Saloon »
  • JS MVC framework decision time

This forum was archived on 2017-11-26.