cannyboy cannyboy - 1 year ago 81
Linux Question

Will I be able to use Realm on Linux, with Perfect?

Perfect - - is a new web server which lets you use the same language on the server-side as you do on your the device. It will be compatible with the Linux version of Swift when it is released before the end of this year - presumably because it just uses Swift's standard library,

It has connectors for MongoDB, MySQL, PostgreSQL.

Currently, I'm developing an app using the Realm database in Swift. Will I be able to use Realm on the server-side too? Does it just use the Swift standard library?

Answer Source

Realm offers so far two bindings for Cocoa-related development: Realm Objective-C and Realm Swift. The latter is based on the former and a shallow wrapper around the Objective-C APIs adopting types and protocols from the Swift standard library and exposing more convenient APIs. The reason for that architecture instead of a pure Swift binding is that Swift doesn't allow to interface C++ code, but Realm's underlying storage engine is based on that. This means that even with Realm Swift, you have Foundation as transitive dependency as we rely on it for e.g. RLMObject with Key-Value Coding, inter-operate with KVO, use Foundation's value types (NSNumber, NSArray, …).

So assuming that there won't be a Linux-compatible Foundation distribution shipping with the Linux version of Swift, using Realm on Linux would require a "pure" Swift binding of Realm, which isn't possible yet, an alternative Objective-C binding, which avoids Foundation, or a mature alternative implementation of Foundation, where GNUstep might be a candidate, but this is entirely untested from our side.

Update #1

Swift was open-sourced together with a Swift implementation stub of Foundation's APIs as a shim over OS APIs, so that it can be portably used on Linux and other platforms where Apple's Foundation is not available. This stub was filled since then with actual implementations by contributors to the project and is part of the Swift 3 release, so it can be used for pure Swift projects.

However this doesn't solve the general issue here that Realm Swift is not pure Swift and is based on Realm Objective-C. So it relies on the availability of the Objective-C runtime and Foundation.

Update #2

We recently announced the Realm Mobile Platform, which you can run on-premises or on the public cloud. So this makes it indeed possible to use Realm on Linux. But server-side access is so far exclusively supported on the Enterprise Edition with the Node.js binding.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download