Realm vs Sqlite for mobile development [closed]

[亡魂溺海] 提交于 2019-12-20 10:24:33

问题


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?


回答1:


Realm and Sqlite are quite different in many aspects.

Here are two articles you could go through to grasp the main differences:

System Properties Comparison Realm vs. SQLite
5 Reasons Why You Should Choose Realm Over CoreData/SQLite

As suggested by Slavia in the comments, take also a look to this article for a comparison of several ORMs, including Realm.




回答2:


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.



来源:https://stackoverflow.com/questions/37151580/realm-vs-sqlite-for-mobile-development

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!