Why Discourse is not using Ember Data?


#1

What are the advantages and disadvantages of not using Ember data ? Which data persistence layer is being used then ?


#2

One advantage would be that you could just use $.ajax calls as is which is more familiar than having to learn a whole new mechanism.

Since these are also promises you can keep using the good old .then(success, failure) functionality as usual.

Disadvantages is that a given $.ajax call will always be made even if the data hasn’t changed.


#3

Discourse was created at a time when Ember Data was not particularly stable and as such they put considerable effort into building their own data layer that was suitable for their specific needs. Changing now for the sake of change does not make much sense for the project.

Their code is very readable, for a simple example of how they use AJAX directly, check out their Group model. They also have tighter integration with their rails app and push all the necessary JSON to render a page alongside the requested HTML then populate the store as the app is booting with preload_store.js. Definitely read through some of their code if you have time, it’s a great learning resource.

It would be interesting to hear from the Discourse devs about the choices they would make if they were to reboot the project with the current state of Ember Data.

From my view Ember Data puts a lot of emphasis on building a long-running relationship graph which is great for complex apps that need to keep a lot of data around, whereas Discourse by it’s nature does not need a complex relationship graph and is probably not interested in keeping (potentially large) in-memory copies of topics and posts.

Bustle also skipped Ember Data, instead creating their own Ember Restless data library, a cut-down lightweight version of Ember Data. Again, their code is a great resource for learning, you can see how Ember Restless/Ember Data/others essentially boil down to wrappers around basic AJAX requests with convenience methods for managing the retrieved and stored data.