Introducing

Realm Mobile Platform
Build Better Apps Faster!
.
Christian Melchior
@chrmelchior
About Realm
• Headquartered in San Francisco, with engineering office
in Copenhagen
• ~50 employees
• Series B startup, $29M raised
Realm Mobile Database
• On-device cross-platform object database
• Launched July 2014
• Developed in the open, fully open source
• 16K+ GitHub stars, 100K+ active developers
Developers Love Realm for Power, Simplicity, Ease of Use
Apps of Every Type, 1.000.000.000+ installs
Realm Mobile Platform
Users Expect More of Apps Today
• Offline first: They need apps that work well offline and when network
connections are intermittent
• Reactive: They expect apps that are highly responsive, with all changes
immediately reflected in the UI
• Real-time: They expect every user and device to stay in sync with each
other in real-time
• Collaborative: They want highly collaborative features and experiences
within their apps
• Seamless: They expect to be able to move seamlessly from device to device
The Apps You Want To Make
The AppYou Can Make
Price
Synchronisation is HARD
Deadlines
Crossplatform concerns
Backend team to busy
The Realm Mobile Platform
Realm Mobile DatabaseRealm Object Server
Real-time data sync
DemoRealmTasks - https://github.com/realm/RealmTasks
Realm
Mobile
Database
Real-time Sync
Realm
Object
Server
SDK
SDKSDK
Sync

Engine
Dashboard
Auth
System
Encryption Layer
What is it?
Access
Control Full DB access
Data connectors
Object Store
SD
SDK
SDK
Enterprise
Feature
Event
Framework
Developer priorities
• Time-to-market: Your team need to be able to deliver quality apps
quickly and on time
• Ability: With high user expectations, the team need the ability to easily
add advanced features like data sync, messaging and collaboration.
• Cross-platform: To reach the full audience, you need to be able to
deliver apps for both iOS and Android
• Standardize: To manage all the apps and reduce complexity, you want
to standardize on a single platform
REST is working great
for the web! 

Why change?
jp@realm.io
The Reality With REST
REST is brittle and cumbersome in a mobile world
• What happens when there is no connectivity?
• Queueing?
• Persistence?
• What about connectivity being lost during requests?
• Tokens? Do they have to be persisted in app?
• State-full services?
• Resource intensive
• Need for multiple REST calls. High latency cost
• Often incurs duplication of data
• JSON parsing is expensive
Delivers Key Mobile Solutions
• Eliminates network challenges
• Simplifies data architecture
• Unlocks existing infrastructure
SDK
1
2
• Offline-first
• Full database on the device
• Queries run locally
• Writes apply immediately
• Reactive architecture keeps UI up-to-date
• Automatic sync happens in the background
• Resilient to any network conditions
Eliminate Network Challenges
Objects as API’s
MobileServer
Realtime data sync
BuyObject
ShoppingCart: →
Status: nil
OrderInfo: nil
Objects as API’s
MobileServer
Realtime data sync
BuyObject
ShoppingCart: →
Status: nil
OrderInfo: nil
BuyObject
ShoppingCart: →
Status: nil
OrderInfo: nil
Objects as API’s
MobileServer
Realtime data sync
BuyObject
ShoppingCart: →
Status: nil
OrderInfo: nil
BuyObject
ShoppingCart: →
Status: nil
OrderInfo: nil
Objects as API’s
MobileServer
Realtime data sync
BuyObject
ShoppingCart: →
Status: nil
OrderInfo: nil
BuyObject
ShoppingCart: →
Status: nil
OrderInfo: nil
Objects as API’s
MobileServer
Realtime data sync
BuyObject
ShoppingCart: →
Status: “processing”
OrderInfo: nil
BuyObject
ShoppingCart: →
Status: “processing”
OrderInfo: nil
Objects as API’s
MobileServer
BuyObject
ShoppingCart: →
Status: “done”
OrderInfo: →
Realtime data sync
Objects as API’s
MobileServer
Realtime data sync
BuyObject
ShoppingCart: →
Status: “done”
OrderInfo: →
BuyObject
ShoppingCart: →
Status: “done”
OrderInfo: →
Delivers Key Mobile Solutions
• Eliminates network challenges
• Simplifies data architecture
• Unlocks existing infrastructure
Typical Application Data Flow
Native object
JSON
Native object
SQL
Native object
JSON
Native object
SQLite SQLite
• It’s just objects

on the device and on the server
• Objects are live,

they update—automatically and
immediately—in response to changes
• Not an ORM,

the database is the data model
• Easier for developers 

to build, change, maintain
• Reduce code complexity

via unified data format; cross-platform
• Encrypted at rest & transitObjects all the way down
Simplify Data Architecture
Delivers Key Mobile Solutions
• Eliminates network challenges
• Simplifies data architecture
• Unlocks existing infrastructure
Legacy Systems Hold Back Mobile
XML JSON
RESTSOAP
/facilities /departments
{"facility": "west-1A",
"departments": [
{"type": "manufacturing"},
{"type": "operations"}]
}
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<department>manufacturing</department>
<facilities>west-1A</facilities>
</root>
Unlock Existing Infrastructure
DC9WP
Coupon:
Coupon:
DC9WP
coupon.code = DC9WP
coupon.isValid = true
1
2
3
• Bridge legacy APIs
• Shift complexity to backend
• Node.js SDK
• Identical object interface
• Full database capabilities
• Apply changes to push data
• Event framework
• Listen and respond to changes from clients
• Pass along data to other systems or databases
• Supports custom authentication
The code centric view
Realm is an object database
Create native objects that map
directly to the database.
// Define you model class by extending RealmObject
public class Dog extends RealmObject {
public String name; // fields can also be private of course
public int age = 1; // default values
}
public class Person extends RealmObject {
@PrimaryKey
public long id;
public String name; // support for custom logic in accessors
public RealmList<Dog> dogs; // declare one-to-many relationships
}
Perform complex queries across
your object graph
RealmResults<User> result2 = realm.where(User.class)
.equalTo("name", "John")
.or()
.equalTo("name", "Peter")
.findAll();
RealmResults<User> result = realm.where(User.class).findAll();
result = result.sort("age"); // Sort ascending
result = result.sort("age", Sort.DESCENDING);
All changes occur in transactions
offering ACID compliance
// Obtain a Realm instance
Realm realm = Realm.getDefaultInstance();
realm.beginTransaction();
Book cheeseBook = realm.createObject(Book.class);
cheeseBook.title = "Gouda Recipes";
cheeseBook.id = 1;
realm.commitTransaction();
But Realm objects have a
special capability…
Realm objects live-update in
response to changes
RealmResults<Dog> puppies = realm.where(Dog.class).lessThan("age", 2);
puppies.length(); // => 0
realm.beginTransaction();
Dog myDog = realm.createObject(Dog.class);
myDog.name = "Rex";
myDog.age = 1;
realm.commitTransaction();
puppies.length(); // => 1
Realm is a live object database
Realm is an object database
Listen for live object changes
to simplify your architecture
RealmResults<Person> persons = realm.where(Person.class).findAll();
persons.addChangeListener(new RealmChangeListener() {
@Override
public void onChange(RealmResults<Person> change) {
// ... do something with the updates (UI, etc.) ...
}
});
Now imagine if these live-updates
came from remote changes?
Realm Object Server synchronizes
object changes in real-time.
Server-side Realms
Device-side Realms
Realm Object Server
Real-time Sync
Push object changes server-side
instantly via Node.js interface
Authenticating a user
SyncCredentials me = SyncCredentials.usernamePassword(username, password, true);
String authURL = "http://my.realm-auth-server.com:9080/auth";
SyncUser user = SyncUser.login(me, authURL);
Open a Realm instance
and get ready for
synchronization
RealmConfiguration conf = new RealmConfiguration.Builder().build();
String serverURL = "realm://my.realm-server.com/~/default";
SyncConfiguration conf = new SyncConfiguration.Builder(user, serverURL).build();
Realm realm = Realm.getInstance(conf);
// Any changes made to this Realm will be synced across all devices!
Conflicts will occur!
How do you handle them?
Conflict Resolution
• Operational Transform
• Well-known documented solution.
• Guarantee convergence.
• At field level
• Delete always wins
• Last write wins
• Inserts in Lists are ordered by time
• https://realm.io/docs/realm-object-server/#conflict-resolution
Trigger server-side functions based
on data changes across Realms
Benefits for developers
• Networking abstracted away. No need to worry about
connectivity, JSON parsing, object mapping…
• Unified Data Model. Same data format and reactivity on
Client and Backend.
• Straight line from Server to UI. Data can be bound
directly to UI on Client.
vs.
Questions?
@chrmelchior
cm@realm.io
Build Better Apps Faster!
Ressources
• RealmTasks https://github.com/realm/
RealmTasks
• Realm Mobile Platform https://realm.io/
products/realm-mobile-platform/
• Realm Java https://realm.io/docs/java/latest/
• More demos https://github.com/realm-demos

Introduction to Realm Mobile Platform

  • 1.
    Introducing
 Realm Mobile Platform BuildBetter Apps Faster! . Christian Melchior @chrmelchior
  • 2.
    About Realm • Headquarteredin San Francisco, with engineering office in Copenhagen • ~50 employees • Series B startup, $29M raised
  • 3.
    Realm Mobile Database •On-device cross-platform object database • Launched July 2014 • Developed in the open, fully open source • 16K+ GitHub stars, 100K+ active developers
  • 4.
    Developers Love Realmfor Power, Simplicity, Ease of Use
  • 5.
    Apps of EveryType, 1.000.000.000+ installs
  • 6.
  • 7.
    Users Expect Moreof Apps Today • Offline first: They need apps that work well offline and when network connections are intermittent • Reactive: They expect apps that are highly responsive, with all changes immediately reflected in the UI • Real-time: They expect every user and device to stay in sync with each other in real-time • Collaborative: They want highly collaborative features and experiences within their apps • Seamless: They expect to be able to move seamlessly from device to device
  • 8.
    The Apps YouWant To Make
  • 9.
    The AppYou CanMake Price Synchronisation is HARD Deadlines Crossplatform concerns Backend team to busy
  • 10.
    The Realm MobilePlatform Realm Mobile DatabaseRealm Object Server Real-time data sync
  • 11.
  • 12.
    Realm Mobile Database Real-time Sync Realm Object Server SDK SDKSDK Sync
 Engine Dashboard Auth System Encryption Layer Whatis it? Access Control Full DB access Data connectors Object Store SD SDK SDK Enterprise Feature Event Framework
  • 13.
    Developer priorities • Time-to-market:Your team need to be able to deliver quality apps quickly and on time • Ability: With high user expectations, the team need the ability to easily add advanced features like data sync, messaging and collaboration. • Cross-platform: To reach the full audience, you need to be able to deliver apps for both iOS and Android • Standardize: To manage all the apps and reduce complexity, you want to standardize on a single platform
  • 14.
    REST is workinggreat for the web! 
 Why change? jp@realm.io
  • 15.
  • 16.
    REST is brittleand cumbersome in a mobile world • What happens when there is no connectivity? • Queueing? • Persistence? • What about connectivity being lost during requests? • Tokens? Do they have to be persisted in app? • State-full services? • Resource intensive • Need for multiple REST calls. High latency cost • Often incurs duplication of data • JSON parsing is expensive
  • 17.
    Delivers Key MobileSolutions • Eliminates network challenges • Simplifies data architecture • Unlocks existing infrastructure
  • 18.
    SDK 1 2 • Offline-first • Fulldatabase on the device • Queries run locally • Writes apply immediately • Reactive architecture keeps UI up-to-date • Automatic sync happens in the background • Resilient to any network conditions Eliminate Network Challenges
  • 19.
    Objects as API’s MobileServer Realtimedata sync BuyObject ShoppingCart: → Status: nil OrderInfo: nil
  • 20.
    Objects as API’s MobileServer Realtimedata sync BuyObject ShoppingCart: → Status: nil OrderInfo: nil BuyObject ShoppingCart: → Status: nil OrderInfo: nil
  • 21.
    Objects as API’s MobileServer Realtimedata sync BuyObject ShoppingCart: → Status: nil OrderInfo: nil BuyObject ShoppingCart: → Status: nil OrderInfo: nil
  • 22.
    Objects as API’s MobileServer Realtimedata sync BuyObject ShoppingCart: → Status: nil OrderInfo: nil BuyObject ShoppingCart: → Status: nil OrderInfo: nil
  • 23.
    Objects as API’s MobileServer Realtimedata sync BuyObject ShoppingCart: → Status: “processing” OrderInfo: nil BuyObject ShoppingCart: → Status: “processing” OrderInfo: nil
  • 24.
    Objects as API’s MobileServer BuyObject ShoppingCart:→ Status: “done” OrderInfo: → Realtime data sync
  • 25.
    Objects as API’s MobileServer Realtimedata sync BuyObject ShoppingCart: → Status: “done” OrderInfo: → BuyObject ShoppingCart: → Status: “done” OrderInfo: →
  • 26.
    Delivers Key MobileSolutions • Eliminates network challenges • Simplifies data architecture • Unlocks existing infrastructure
  • 27.
    Typical Application DataFlow Native object JSON Native object SQL Native object JSON Native object SQLite SQLite
  • 28.
    • It’s justobjects
 on the device and on the server • Objects are live,
 they update—automatically and immediately—in response to changes • Not an ORM,
 the database is the data model • Easier for developers 
 to build, change, maintain • Reduce code complexity
 via unified data format; cross-platform • Encrypted at rest & transitObjects all the way down Simplify Data Architecture
  • 29.
    Delivers Key MobileSolutions • Eliminates network challenges • Simplifies data architecture • Unlocks existing infrastructure
  • 30.
    Legacy Systems HoldBack Mobile XML JSON RESTSOAP /facilities /departments {"facility": "west-1A", "departments": [ {"type": "manufacturing"}, {"type": "operations"}] } <?xml version="1.0" encoding="UTF-8" ?> <root> <department>manufacturing</department> <facilities>west-1A</facilities> </root>
  • 31.
    Unlock Existing Infrastructure DC9WP Coupon: Coupon: DC9WP coupon.code= DC9WP coupon.isValid = true 1 2 3 • Bridge legacy APIs • Shift complexity to backend • Node.js SDK • Identical object interface • Full database capabilities • Apply changes to push data • Event framework • Listen and respond to changes from clients • Pass along data to other systems or databases • Supports custom authentication
  • 32.
  • 33.
    Realm is anobject database
  • 34.
    Create native objectsthat map directly to the database. // Define you model class by extending RealmObject public class Dog extends RealmObject { public String name; // fields can also be private of course public int age = 1; // default values } public class Person extends RealmObject { @PrimaryKey public long id; public String name; // support for custom logic in accessors public RealmList<Dog> dogs; // declare one-to-many relationships }
  • 35.
    Perform complex queriesacross your object graph RealmResults<User> result2 = realm.where(User.class) .equalTo("name", "John") .or() .equalTo("name", "Peter") .findAll(); RealmResults<User> result = realm.where(User.class).findAll(); result = result.sort("age"); // Sort ascending result = result.sort("age", Sort.DESCENDING);
  • 36.
    All changes occurin transactions offering ACID compliance // Obtain a Realm instance Realm realm = Realm.getDefaultInstance(); realm.beginTransaction(); Book cheeseBook = realm.createObject(Book.class); cheeseBook.title = "Gouda Recipes"; cheeseBook.id = 1; realm.commitTransaction();
  • 37.
    But Realm objectshave a special capability…
  • 38.
    Realm objects live-updatein response to changes RealmResults<Dog> puppies = realm.where(Dog.class).lessThan("age", 2); puppies.length(); // => 0 realm.beginTransaction(); Dog myDog = realm.createObject(Dog.class); myDog.name = "Rex"; myDog.age = 1; realm.commitTransaction(); puppies.length(); // => 1
  • 39.
    Realm is alive object database Realm is an object database
  • 40.
    Listen for liveobject changes to simplify your architecture RealmResults<Person> persons = realm.where(Person.class).findAll(); persons.addChangeListener(new RealmChangeListener() { @Override public void onChange(RealmResults<Person> change) { // ... do something with the updates (UI, etc.) ... } });
  • 41.
    Now imagine ifthese live-updates came from remote changes?
  • 42.
    Realm Object Serversynchronizes object changes in real-time. Server-side Realms Device-side Realms Realm Object Server Real-time Sync
  • 43.
    Push object changesserver-side instantly via Node.js interface
  • 44.
    Authenticating a user SyncCredentialsme = SyncCredentials.usernamePassword(username, password, true); String authURL = "http://my.realm-auth-server.com:9080/auth"; SyncUser user = SyncUser.login(me, authURL);
  • 45.
    Open a Realminstance and get ready for synchronization RealmConfiguration conf = new RealmConfiguration.Builder().build(); String serverURL = "realm://my.realm-server.com/~/default"; SyncConfiguration conf = new SyncConfiguration.Builder(user, serverURL).build(); Realm realm = Realm.getInstance(conf); // Any changes made to this Realm will be synced across all devices!
  • 46.
    Conflicts will occur! Howdo you handle them?
  • 47.
    Conflict Resolution • OperationalTransform • Well-known documented solution. • Guarantee convergence. • At field level • Delete always wins • Last write wins • Inserts in Lists are ordered by time • https://realm.io/docs/realm-object-server/#conflict-resolution
  • 48.
    Trigger server-side functionsbased on data changes across Realms
  • 49.
    Benefits for developers •Networking abstracted away. No need to worry about connectivity, JSON parsing, object mapping… • Unified Data Model. Same data format and reactivity on Client and Backend. • Straight line from Server to UI. Data can be bound directly to UI on Client.
  • 50.
  • 51.
  • 52.
    Ressources • RealmTasks https://github.com/realm/ RealmTasks •Realm Mobile Platform https://realm.io/ products/realm-mobile-platform/ • Realm Java https://realm.io/docs/java/latest/ • More demos https://github.com/realm-demos