25

Am an Xamarin Developer , I used to use Sqlite as mobile database ,
recently Realm comes to the picture.
Any idea about Differences between them in Performance & ease of use..etc?

What is the best practice of using either one?

Mohammed Ali
  • 696
  • 3
  • 9
  • 22
Medo Medo
  • 952
  • 2
  • 12
  • 21
  • http://geeks.ms/jsuarez/2016/06/28/xamarin-comparativa-de-sqlite-y-realm/ Latest (Spanish) comparison I have seen independently tested and published, quite readable with Google translating, has benchmarks. – Andy Dent Jun 29 '16 at 11:38
  • 1
    One example (ease of use): Realm still does not support on delete cascade – Murat Ozgul Aug 24 '16 at 21:34

1 Answers1

24

I'm a developer on the Xamarin team at Realm so I can tell you a bit more about how the Xamarin product works.

Realm has a C++ core which is common across all products. That is why we release for each platform rather than just a language - we need to include the native core. Whilst we support PCL builds of your code, we don't have a PCL library as such - at build time your PCL code will link to the matching IOS or Android library.

All the Realm products are individually developed to provide an idiomatic interface for a given programming language, with as slim a layer as possible between your code and the data.

That means, for example, the C# product provides LINQ for querying and uses C# objects as the means of defining the data model. At build time, the Fody code generator is run to add property setters and getters so your C# objects will directly interact with the core C++ data. Unlike typical ORM products, there's no copying of data from the database into buffers and then again into your objects.

Realm data is memory-mapped so it's going directly from your code to storage. We generate accessor methods that replace the auto-property getters and setters.

We use the term zero-copy to describe this. In contrast, most other systems will have C# objects which have fields backing their properties. Those objects are often populated by copying from a SQLite buffer which has been read from the disk storage. That's two levels of copying.

Andy Dent
  • 17,578
  • 6
  • 88
  • 115
  • 2
    `Unlike typical ORM products, there's no copying of data from the database into buffers and then again into your objects` Can you help me and explain more on this statement? – Amrut Bidri Jan 20 '17 at 06:45
  • Also I have read something like zero-copy database in case of realm on some blog. Do it relate here? – Amrut Bidri Jan 20 '17 at 06:53
  • Yes, the term "zero-copy" is used to describe what I'm talking about there. – Andy Dent Jan 20 '17 at 09:13
  • 1
    looking to the number of bugs open https://github.com/realm/realm-dotnet/issues?page=2&q=is%3Aissue+is%3Aopen aprox 30 bugs or so currently I wouldn't say Realm is ready for production – Don Box Mar 08 '17 at 20:38
  • I believe Apache Kafka uses zero-copy as well to deliver on wicked fast performance promises. – Klaus May 23 '17 at 23:39
  • @AndyDent would like to see your feedback on this one: https://mobilefirstcloudfirst.net/2016/05/xamarin-apps-sqlite-vs-realm-whats-the-best-mobile-db-solution/ . Although the post is dated 1 yr ago, the author is a Xamarin University Certified Trainer – BiLaL Jun 05 '17 at 18:57
  • @BiLaL the comment about "constructor has to be Realm.CreateObject" is out of date and CreateObject deprecated for months. Similarly, the "RealmList" issue was resolved and Async methods added. His point about depending on Fody is still valid - it has been a source of some problems but is also a massive enabler. Note as of April 2017 I no longer work at Realm so am writing this as a former contractor but still huge fan, now using Realm in two startup projects. – Andy Dent Jun 07 '17 at 02:23
  • @AndyDent Thanks for the comprehensive quick response. If you are using it for your own projects means you prefer it over SQLite. Till April, when you were there, any plan regarding Fody was on the table? – BiLaL Jun 07 '17 at 15:39
  • @BiLaL re Fody, I cannot disclose anything that is not public. There is a mention of using Roslyn instead on the issue thread https://github.com/realm/realm-dotnet/issues/529 – Andy Dent Jun 08 '17 at 07:51
  • @AndyDent it was not intended to push you that far either. Thanks for the link, the last comment from contributors dates back to July 1, 2016. Lets see when the issue gets some heat. – BiLaL Jun 18 '17 at 11:19