Streamtable.js vs. Datatables
Streamtable.js vs. Datatables
I've been a fan of datatables and used it for numerous projects. Recently, I stumbled upon this StreamTable.js (http://blog.joshsoftware.com/2013/04/23/streamtable-js-the-next-generation-search-filter/), and it looks fairly interesting. Has anyone have any thoughts about it? Thanks.
This discussion has been closed.
Replies
For me, real streaming of data could be done through WebSockets - again with the server sending new data, and using the DataTables API to update the table. That could include updates to rows as well as new rows.
Allan
StreamTable was born because of 2 primary needs:
+ We found the configuration for DataTable quite complex.
+ We also needed a seamless streaming approach. While fnAddData is supposed to be client-side stuff, to make it work with server-side poll, the user has to prod around bit for it.
The good, constructive twitter tussle is here: https://twitter.com/gautamrege/status/326950675579822080
Apart from this, we have simplified a few things:
+ StreamTable is currently ~400 lines as compared to ~12000 lines of DataTable.
+ We use callbacks for managing / massaging the data instead of configuration like aoColumns
+ We have steered clear of fnRender for rendering each column and instead rely on view callback which can be used with simple clean templates like mustache. So, there is more control.
+ StreamTable allows us to work with even non-tabular formats - i.e. it need not just be a table, the data representation can change and can be controlled for custom views.
Back to the streaming bit:
Adding websocket support is definitely a good idea but it may be an overkill if we have a result sub-set (that may require a pub/sub kinda model). Its also a heavy price to pay because it would need some server-side component to work with -- are you planning this for DT?
If only the two could merge we would have a dataStreamTable :)
I should first say that while I'm proud of DataTables, I know its limits and it is never going to be a single solution that works for everyone. No library possibly can be, and there will always be areas which can be improved. Case in point is my work on DataTables 1.10 at the moment which completely revamps the API and drops the hungarian notation (backwards compatible changes!), making initialisation cleaner and the data easier to work with.
A library which can handle streaming data for tables is fantastic. I think ultimately, any table / grid component which can handle adding, deleting and editing rows can deal with truly streamed data (the WebSocket that I was hinting at). Equally any component which can add data using an API can handle the addition of data retrieved by polling (a small example of doing this with DataTables' fnAddData method: http://live.datatables.net/atoyil/edit ).
Doing fully streamed data (WebSocket) is something that I think should exist outside of the table library, whereby it can do the data retrieval, and tell the table to add, edit or delete rows (realtime stock information is a good example and I've seen DataTables used for this kind of thing). Its also very highly server dependent (or at least communications channel dependent) so its not something that I'm planning on including as part of DataTables core. DataTables is going to stay focused on the data in the table only.
I like the use of callbacks as they've been used in StreamTable. Personally I find mData very easy to use in DataTables when working with json objects as the data source), but I see the attraction of manipulating the data wholesale. This actually can be done with DataTables at the moment, but with an event ( `xhr` ) rather than a callback, since it is passed the data which can then be manipulated before being drawn.
I also really like the use of mustache - while I'm not going to add any dependencies to DataTables (other than jQuery), a template plug-in is something I've been thinking of (it would automatically built the column definitions for you), and that's a really attractive option. Its great to see templates being used so powerfully here.
Finally size - DataTables is ~70k minified, ~22K gzipped, (a very large amount of the 12'000 lines are doc comments). I'm working really hard to ensure that DataTables doesn't go far beyond that point with the new features going in for 1.10. Difficult with the number of features included, but it should be possible. The goal ( http://datatables.net/development/roadmap ) is to make DataTables fully modular with v1.12, when you'll be able to pick and choose the components you want. It will never be 400 lines, but it should be able to go quite small depending on the modules selected.
Great work with StreamTable - I look forward to seeing it develop :-). And thanks also for your feedback on how you found DataTables and why it wasn't a good fit for your use case.
Regards,
Allan
This is the best thing I've heard all day!! :D