Archive for November 16, 2015

Monday, November 16, 2015

A Look Into Realm’s Core DB Engine

JP Simard:

The whole point of Realm, or at least one of its very core ideas, is that it is objects all the way down. That was one of the driving principles that encouraged us to start fresh, rather than using an existing relational model. If you look at existing solutions that are currently out there, they tend to be ORMs. More often than not, there’s this conceptual object-oriented model that people are working with, which is really an abstraction of what’s going on underneath. Usually, these are records, tables with foreign keys, and primary keys. As soon as you start to have relationships, the abstraction starts to fall apart because you start needing expensive operations to be able to traverse these relationships.

[…]

As soon as you add this company object to the Realm, it becomes an accessor. Once you start reading properties from it, you’re no longer accessing your ivars, you’re accessing the raw database values, with the benefit of cutting out four or five steps and a bunch of memory copy along the way.

[…]

Even though we’re doing this composition by adding one filter after another, we’re not redoing all these queries, we’re essentially building a tree of what the result should look like. Even if you just access the first result out of this query, we’re not going to have to read all the properties for all the other objects, because we really try to keep it lazy.

[…]

There are a bunch of optimizations that we can make at the core level such as native links at the file format level.

[…]

An important part and design consideration for the core file format was to make sure that the format on disk was readable in memory without having to do any deserialization. You skip that whole step. All you do is calculate the offset of the data to read in your memory-mapped memory, read that value from the offset to its length, then return that raw value from the property access.

Update (2015-11-16): Jonathan Wight:

Using Realm on a new feature here at 3DR and so far very impressed. Minor issues but on the whole better experience than using CD

Improved App Store Search

Sarah Perez (comments):

A number of mobile app developers and industry observers recently noticed a significant change in the way the Apple App Store’s search algorithms are returning results. Developers say that, following a series of shifts that took place beginning on November 3, app search results now appear to be more intelligent and far more relevant – especially among the top results – than in previous months.

[…]

This new change is focused more on how apps are returned when users type in keywords to find an app – something that’s becoming a more common way to find apps in a crowded app store featuring over a million mobile applications.

David Sparks:

I’ve often thought App Store search was pretty embarrassing for Apple. My own particular canary-in-a-coal-mine on this issue is Tweetbot. When I needed to rebuild my new iPhone a few months ago. I searched “Tweetbot” in the App Store and the results came up empty. This is one of the most popular Twitter clients in the App Store and yet searching its explicit name did not find it. Searching “Twitter”, gave me a long list of Twitter-related applications but despite scrolling for a long time, Tweetbot did not show up.

He says this is fixed now.

Interstellar Functional Reactive Framework

Interstellar (via Jonathan Wight):

The simplest Signal<T> implementation for Functional Reactive Programming you will ever find.

Nimble Matcher Framework

Nimble:

Use Nimble to express the expected outcomes of Swift or Objective-C expressions. Inspired by Cedar.

// Swift

expect(1 + 1).to(equal(2))
expect(1.2).to(beCloseTo(1.1, within: 0.1))
expect(3) > 2
expect("seahorse").to(contain("sea"))
expect(["Atlantic", "Pacific"]).toNot(contain("Mississippi"))
expect(ocean.isClean).toEventually(beTruthy())

BDD has never felt right to me, but I do like using a layer on top of XCTest’s macros because they are both verbose and incomplete.

Ads Use Inaudible Sound to Link Your Devices

Dan Goodin:

The ultrasonic pitches are embedded into TV commercials or are played when a user encounters an ad displayed in a computer browser. While the sound can't be heard by the human ear, nearby tablets and smartphones can detect it. When they do, browser cookies can now pair a single user to multiple devices and keep track of what TV commercials the person sees, how long the person watches the ads, and whether the person acts on the ads by doing a Web search or buying a product.