Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Realm and 
Lessons Learned building it 
{MBLT}DEV ‘14 
Brian Munkholm, 
VP Engineering @realm 
bm@realm.io 
@brianMunkholm
Menu: 
What is Realm? 
How popular? 
Why use Realm? Feedback 
Design goals & fulfilment - API examples 
Lessons Learned 
T...
What is Realm? 
• Modern mobile database - replace SQLite+ORMs 
• Easy: Object-oriented, but not an ORM 
• Safe: full ACID...
Realm for iOS 
Used by >20,000 developers 
worldwide in < 8 weeks! 
Including ~1,000 in or very close to 
production 
>220...
Realm for Android 
- launched 1 month ago 
Used by >5,000 developers 
worldwide the 1’st week! 
First apps in production 
...
Why use Realm? 
- ask the devs!
Cloth 
a beautifully designed 
personal outfit diary 
>350k users 
Uses Realm for all data 
handling 
took over a 2 year-o...
Beanflow 
Full POS & inventory app (w/ 
offline mode) 
Uses Realm as network cache 
for all data 
“I don't have any plans ...
Common benefits 
• Save time - save $$$ 
• Make faster & better apps 
• Uses less memory and disk 
• Free (de)serialisatio...
Design Goals 
1. Simple 
2. Fast 
3. Modern 
to learn 
to maintain 
to use across threads
1. Simple
Models 
public class Dog extends RealmObject { 
// Fields 
private String name; 
private int age; 
// + Getters and Setter...
Writes 
// Obtain a Realm instance in each thread 
Realm realm = Realm.getInstance(this); 
// ACID transactions give you e...
RealmResults<User> teens = realm.where(User.class) 
.between("age", 13, 20) 
.findAll(); 
Queries 
// Queries can be chain...
Relationships 
public class Person extends RealmObject { 
private String name; 
private Dog bestDog; // One-One relations ...
Thread-safety: All access is the same 
new AsyncTask<Void, Void, String>() { 
@Override 
protected String doInBackground(V...
Thread-safety: 
• Writes cannot conflict - they block 
• No need to merge data sources, ever. 
• Reads are consistent as s...
2. Fast 
BIG disclaimer! 
Use benchmarks as rough indicator 
Measure your own senarios
Lessons Learned
Lesson one 
Aim high! 
• Worlds best product 
• Solid funding from the best 
• 100% dedicated team
Lesson two 
Listen to the users / community 
• Ask users actively 
• Listen, understand their needs 
and react quickly 
• ...
Lesson three 
Performance is great - but 
usability is king! 
• and eats performance… 
• Android/Java reflection is SLOW 
...
Add a new object first time 
• Runtime code generation 
• Use lower level APIs 
• Compile-time code 
generation 
• Cache a...
The future: 
• Encryption 
• Handover results between threads 
• Dynamic API / Migration 
• Advanced Query 
• Synchronisat...
Thanks for your support!!! 
Watch or Influence? 
Feedback : 
realm.io bm@realm.io 
#Realm #BrianMunkholm
#MBLTdev: Уроки, которые мы выучили, создавая Realm
#MBLTdev: Уроки, которые мы выучили, создавая Realm
#MBLTdev: Уроки, которые мы выучили, создавая Realm
#MBLTdev: Уроки, которые мы выучили, создавая Realm
Upcoming SlideShare
Loading in …5
×

#MBLTdev: Уроки, которые мы выучили, создавая Realm

2,269 views

Published on

#MBLTdev: Конференция мобильных разработчиков
Спикер: Brian Munkholm
VP Engineering, Realm
http://mbltdev.ru/

Published in: Mobile

#MBLTdev: Уроки, которые мы выучили, создавая Realm

  1. 1. Realm and Lessons Learned building it {MBLT}DEV ‘14 Brian Munkholm, VP Engineering @realm bm@realm.io @brianMunkholm
  2. 2. Menu: What is Realm? How popular? Why use Realm? Feedback Design goals & fulfilment - API examples Lessons Learned The future
  3. 3. What is Realm? • Modern mobile database - replace SQLite+ORMs • Easy: Object-oriented, but not an ORM • Safe: full ACID properties • Cross-platform: C++ core (3 years dev) • Small: compact data, object == DB (no copy!) • Fast • Free: open source!
  4. 4. Realm for iOS Used by >20,000 developers worldwide in < 8 weeks! Including ~1,000 in or very close to production >2200 GitHub Stars! (Parse: 10k in 8 mon)
  5. 5. Realm for Android - launched 1 month ago Used by >5,000 developers worldwide the 1’st week! First apps in production >700 GitHub Stars in 2 weeks (GreenDao has 1592, ORMlite 307 after years!)
  6. 6. Why use Realm? - ask the devs!
  7. 7. Cloth a beautifully designed personal outfit diary >350k users Uses Realm for all data handling took over a 2 year-old codebase and ported it to Realm in 1 day. clothapp.com reallyseth.com
  8. 8. Beanflow Full POS & inventory app (w/ offline mode) Uses Realm as network cache for all data “I don't have any plans to go back to Core Data anytime soon. I really like Realm.” sebastiandobrincu.com www.beanflow.com
  9. 9. Common benefits • Save time - save $$$ • Make faster & better apps • Uses less memory and disk • Free (de)serialisation • cross platform (iOS, Android, ++) • cross language
  10. 10. Design Goals 1. Simple 2. Fast 3. Modern to learn to maintain to use across threads
  11. 11. 1. Simple
  12. 12. Models public class Dog extends RealmObject { // Fields private String name; private int age; // + Getters and Setters… }
  13. 13. Writes // Obtain a Realm instance in each thread Realm realm = Realm.getInstance(this); // ACID transactions give you easy thread-safety realm.beginTransaction(); Dog dog = realm.createObject(Dog.class); dog.setName("Rex"); dog.setAge(3); // Full commit to disk (or memory) realm.commitTransaction();
  14. 14. RealmResults<User> teens = realm.where(User.class) .between("age", 13, 20) .findAll(); Queries // Queries can be chained efficiently RealmResults<User> johns = teens.where() .equalTo("name", “John") .or() .contains("name", “Jo") .findAll();
  15. 15. Relationships public class Person extends RealmObject { private String name; private Dog bestDog; // One-One relations private RealmList<Dog> dogs; // One-Many relations … } realm.beginTransaction(); Person person = realm.createObject(Person.class); person.setName("Tim"); person.getDogs().add(dog); realm.commitTransaction();
  16. 16. Thread-safety: All access is the same new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(Void… voids) { Realm realm = Realm.getInstance(this); realm.beginTransaction(); Person person = realm.createObject(Person.class); person.setName("Tim"); realm.commitTransaction(); return null; } }.execute();
  17. 17. Thread-safety: • Writes cannot conflict - they block • No need to merge data sources, ever. • Reads are consistent as soon as the write completes
  18. 18. 2. Fast BIG disclaimer! Use benchmarks as rough indicator Measure your own senarios
  19. 19. Lessons Learned
  20. 20. Lesson one Aim high! • Worlds best product • Solid funding from the best • 100% dedicated team
  21. 21. Lesson two Listen to the users / community • Ask users actively • Listen, understand their needs and react quickly • It takes time!
  22. 22. Lesson three Performance is great - but usability is king! • and eats performance… • Android/Java reflection is SLOW • but dont’ give up
  23. 23. Add a new object first time • Runtime code generation • Use lower level APIs • Compile-time code generation • Cache all the introspection calls 100 75 50 25 0 4 sec!!! Runtime Runtime+ Compile Time Cache
  24. 24. The future: • Encryption • Handover results between threads • Dynamic API / Migration • Advanced Query • Synchronisation • What do you want for xmas?
  25. 25. Thanks for your support!!! Watch or Influence? Feedback : realm.io bm@realm.io #Realm #BrianMunkholm

×