Archives de catégorie : Anki

No porting Anki to Firefox OS

I thought about porting Anki/Ankidroid to Firefox OS, but I realized that I would be a daunting task (and not just a simple conversion from Python/Java to JavaScript). Why?

First reason: In Firefox OS, there is no native support for Sqlite, the library (and file format) used by Anki. There is a port of Sqlite done using emscripten (a C/C++ to Javascript converter), but it only operates on in-memory databases. So if you want to modify an existing Anki file, you need to load it completely in memory (mine is larger than 70Mo!), work on it, then save it completely in the end. So your modifications will not be saved after a transaction/card review, and working in memory may not fit with cheap phones.

Second reason: In Sqlite, there is an abstraction layer for I/O operations for each OS/family of OS. But it does not seem possible to create a implementation for Firefox OS… because the I/O in Firefox OS are asynchronous (when your read/write is done, it will call a callback function). And refactoring Sqlite in order to convert all the synchronous I/O calls to asynchronous calls seems an Herculean work.

What about IndexedDB? The data model of Anki is quite simple, but IndexedDB does not support joins, so it would have to be emulated with JavaScript code. Also, it will not help importing/exporting an existing Anki file…

Conclusion: From what I saw, I feel quite disappointed by the model adopted by Firefox OS, which only proposes a limited set of system API and seems quite limited for the port of existing libraries. Especially the asynchronous I/O aspect. It seems like this model is great for applications developed with Firefox OS in mind, but if you need to port an existing application… May it will get better (I hope there will be an official SQLite support)…