Slide 1

Slide 1 text

Realm

Slide 2

Slide 2 text

What is Realm? • Fast, zero-copy, embedded database • Tens of thousands of devs, 100M+ devices • Object & model-oriented • Full ACID transactions • Well defined threading model • Cross-platform C++ core with language bindings (currently Objective-C, Swift & Android)

Slide 3

Slide 3 text

Open Source* github.com/realm/realm-cocoa * Bindings 100% open source, C++ core launching as Apache 2

Slide 4

Slide 4 text

Why?

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Current State of iOS Persistence

Slide 7

Slide 7 text

Core Data • Full-featured & mature • 10+ years old ORM for SQLite • Slow • Complex and difficult to learn/debug •  only

Slide 8

Slide 8 text

SQLite • Faster than Core Data • Optimized for iOS • Cross Platform • 14+ years old • Bad user experience • Manual mapping and queries • Lack of thread safety

Slide 9

Slide 9 text

Other Options • FMDB • YapDatabase • CouchbaseLite • LevelDB

Slide 10

Slide 10 text

Lots has changed in last decade • Smartphone Revolution • Low Connectivity • NoSQL • Need for Sync

Slide 11

Slide 11 text

Benchmarks

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Realm Models @interface Employee : RLMObject @property NSString *name; @property NSDate *startDate; @property float salary; @property BOOL fullTime; @end RLM_ARRAY_TYPE(Employee) @interface Company : RLMObject @property NSString *name; @property Employee *ceo; @property RLMArray *employees; @end

Slide 16

Slide 16 text

Realm Models (Swift) class Employee: Object { dynamic var name = "" // you can specify defaults dynamic var startDate = NSDate() dynamic var salary = 0.0 dynamic var fullTime = true } class Company: Object { dynamic var name = "" dynamic var ceo: Employee? // optional. who needs CEO's?! let employees = List() }

Slide 17

Slide 17 text

Using Realm let company = Company() // Using Realm Objects company.name = "Realm" // etc... let realm = Realm() realm.write { // Transactions realm.add(company) } // Queries let companies = realm.objects(Company) companies[0].name // => Realm (generics) // "Jack"s who work full time (lazily loaded & chainable) let ftJacks = realm.objects(Employee).filter("name = 'Jack'") .filter("fullTime = true")

Slide 18

Slide 18 text

Background Operations dispatch_async(queue) { let realm = Realm() realm.beginWriteTransaction() Person.createInDefaultRealmWithObject( ["name": "randomstring", "birthdate": NSDate()] ) // make this data available to other threads realm.commitWriteTransaction() }

Slide 19

Slide 19 text

Notifications let token = realm.addNotificationBlock { note, realm in viewController.updateUI() } // Later... realm.removeNotification(token) Fine-grain Notifications Coming Soon!

Slide 20

Slide 20 text

Current Limitations • NSDate is truncated to the second (use NSTimeInterval instead) • KVO is not supported (we'll add support along with fine-grain notifications) • Realm Object Setters & Getters cannot be overriden (use ignored properties as proxies instead)

Slide 21

Slide 21 text

Work In Progress • Multiprocess • Fine-grain notifications • Async queries • Cascading deletes • Nullable types • Sync • Open source Core

Slide 22

Slide 22 text

Where is Realm used?

Slide 23

Slide 23 text

Thermodo

Slide 24

Slide 24 text

Groupon

Slide 25

Slide 25 text

Coinbase

Slide 26

Slide 26 text

Buzzfeed

Slide 27

Slide 27 text

Dubsmash

Slide 28

Slide 28 text

Quickbooks

Slide 29

Slide 29 text

ZipRecruiter

Slide 30

Slide 30 text

Macaroni

Slide 31

Slide 31 text

Aplos

Slide 32

Slide 32 text

What Can You Build With Realm?

Slide 33

Slide 33 text

Where to find us • Facebook: j.mp/realmjp • Twitter: twitter.com/realm • GitHub: github.com/realm • StackOverflow: stackoverflow.com/questions/tagged/realm • Email: [email protected]

Slide 34

Slide 34 text

j.mp/realmjp Questions? @simjp, [email protected]