BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Realm Reaches 1B Users, 100k Active Developers, and Launches Version 1.0

Realm Reaches 1B Users, 100k Active Developers, and Launches Version 1.0

Realm has released version 1.0 of its object-oriented database for iOS and Android.

Launched two years ago, Realm is intended to provide a simpler, more performant alternative to using on-device technologies such as SQLite or Core Data.

Realm's technical team told InfoQ that among the noted changes in the latest release are an improved query language, with support for partial string matches, relationship traversal, multi-field sorting, and distinct matches. This joins other improvements, including a reduced library footprint by 70% on Android, that allows for smaller-sized apps to be shipped to consumers, and the introduction of Realm Configuration classes, to serve the increasing amount of apps that have multiple Realms.

Following on from its recent launch of Realm Xamarin, a reactive database for .NET developers, Realm 1.0's changelog includes mentions of support for:

  • Apple’s Swift language, via Realm Swift
  • Carthage, Swift's dependency manager
  • Apple’s watchOS and tvOS
  • RxJava on Android
  • Kotlin, the emerging language for Android app development

In the blog post 13,949 Commits and 6,148 Closed Issues Later: Thank You for Helping Realm Reach 1.0 the Realm team show the following Java inline code to demonstrate:

// Define you model class by extending RealmObject
public class Dog extends RealmObject {
    private String name;
    private int age;

    // ... Generated getters and setters ...
}

public class Person extends RealmObject {
    @PrimaryKey
    private long id;
    private String name;
    private RealmList<Dog> dogs; // Declare one-to-many relationships

    public Person(long id, String name) {
        this.id = id;
        this.name = name;
    }

    // ... Generated getters and setters ...
}

// Use them like regular java objects
Dog dog = new Dog();
dog.setName("Rex");
dog.setAge(1);

// Create a RealmConfiguration that saves the Realm file in the app's "files" directory.
RealmConfiguration realmConfig = new RealmConfiguration.Builder(context).build();
Realm.setDefaultConfiguration(realmConfig);

// Get a Realm instance for this thread
Realm realm = Realm.getDefaultInstance();

// Query Realm for all dogs younger than 2 years old
final RealmResults<Dog> puppies = realm.where(Dog.class).lessThan("age", 2).findAll();
puppies.size(); // => 0 because no dogs have been added to the Realm yet

// Persist your data in a transaction
realm.beginTransaction();
final Dog managedDog = realm.copyToRealm(dog); // Persist unmanaged objects
Person person = realm.createObject(Person.class); // Create managed objects directly
person.getDogs().add(managedDog);
realm.commitTransaction();

// Listeners will be notified when data changes
puppies.addChangeListener(new RealmChangeListener<RealmResults<Dog>>() {
    @Override
    public void onChange(RealmResults<Dog> results) {
        // Query results are updated in real time
        puppies.size(); // => 1
    }
});

// Asynchronously update objects on a background thread
realm.executeTransactionAsync(new Realm.Transaction() {
    @Override
    public void execute(Realm bgRealm) {
        Dog dog = bgRealm.where(Dog.class).equals("age", 1).findFirst();
        dog.setAge(3);
    }
}, new Realm.Transaction.OnSuccess() {
    @Override
    public void onSuccess() {
      // Original queries and Realm objects are automatically updated.
      puppies.size(); // => 0 because there are no more puppies younger than 2 years old
      managedDog.getAge();   // => 3 the dogs age is updated
    }
});

In the discussion Realm 1.0 on Hacker News, the mood around the major release was positive, with many users offering compliments and congratulations. In discussion around Realm's closed source "core" user mahyarm referred commenters to the Realm FAQ

I see references to a “core” in the code, what is that?

The core is referring to our internal C++ storage engine. It is not currently open-source but we do plan on open-sourcing it also under the Apache 2.0 license once we’ve had a chance to clean it up, rename it, and finalize major features inside of it. In the meantime, its binary releases are made available under the Realm Core (TightDB) Binary License

Realm also reports with the 1.0 release a milestone of over 1 billion end-users on the iOS & Android apps that it powers.

Commenting on the news, Realm's CEO Alexander Stigsen said, “It is thrilling to see how quickly we’ve grown and the caliber of companies that are using Realm to underpin their mobile infrastructure. To have reached a billion end users — a milestone so few companies reach — is a testament to the demand for our innovative approach to mobile data storage.”

Rate this Article

Adoption
Style

BT