Why serverless was made for mobile development

Building mobile apps becomes infinitely simpler when we get the antiquated server stack out of the way

Why serverless was made for mobile development
Thinkstock

It has been a decade since the launch of the iPhone, but for developers, it can feel like we’re still trapped in 2007. If you’re doing anything interesting with a mobile app, you run into a pernicious and frustrating reality: Your mobile development experience was in large part determined by the web technologies that preceded mobile and still persist today.

So when we talk about building mobile apps, what we really mean is building mobile apps that interface with server technologies. And that means interacting with a stack that was designed for a world of desktop computers connected with ethernet cables. While the world has moved beyond big screens and wired connections, mobile developers are the ones who have had to accept endless compromises in order to ship the experiences they want.

To ship useful server-side code, you need a lot of novel, domain-specific skills. When a developer builds an app and connects it to the server, data doesn’t just magically start flowing into handy columns and rows. Before you make your first request, you have to deploy and manage those servers. The devops arts that make that possible are getting easier, but they certainly take up a lot of time.

Next, your server has to serialize the data from whatever format (probably JSON) it gets from the request, and then it has to store it in a database that usually understands SQL, and then it has to perform the business logic on that data. It’s going to do all of that in a server-side language, which of course will be different from the Swift or Android Java you use to write your mobile app.

A simple mobile app is suddenly in need of a sophisticated server-side team. And it’s mostly work spent just trying to get the two sides of your stack—mobile and server—to talk to one another. We have mobile apps and mobile teams, and they have to play nicely with a server-side stack and team that uses technology established in a pre-mobile world.

Simplify the server

There is a better way—an emerging pattern called serverless development—that we at Realm have been working hard to bring to mobile developers. A serverless architecture is meant to abstract away all of the infrastructure and frameworks that make server-side development possible, so that you simply focus on the hard part: writing code that does what you need it to, and which runs reactively as data changes. The server is still there—but all of the work to get productive with it has vanished.

This is the idea behind the Realm Mobile Platform. Because the Realm Object Server is an object synchronization and event handling server that works with Realm’s mobile database, it keeps data in sync across devices seamlessly and automatically, with minimal changes to data models or controllers. It uses live objects shared across the Realm Mobile Database and the Realm Object Server, which update automatically and immediately in response to changes at either source – and with comprehensive data encryption throughout.

Because the Realm Object Server takes care of syncing data between devices automatically, you can just go to your Realm dashboard, create a new Realm Function, and start writing JavaScript that will respond to changes in data generated by client apps.

How is that so different than normal server-side development? Well, as a mobile developer, you no longer have to become a server-side developer with all of that specialized knowledge in order to do effective work. You don’t have to think about how to get the server running, or how to get the data to the server. You don’t have to do devops. You don’t have to learn how to deal with Postgres and Redis and all of the other server-side technologies that a sophisticated app used to require.

And instead of having to learn a whole new language plus framework, like Django or Rails, you just write some JavaScript, and the platform takes care of all of the plumbing for which we used to use frameworks. Instead of dealing with middleware and URL routing, the platform gets the data where it needs to go, in the format you expect. Instead of building out RESTful endpoints and pointing requests at them, you just work directly with the incoming data.

When I used to write Django apps, POSTing data to a new view would require a couple dozen lines of code across four or five files. In contrast, the JavaScript code in a serverless Realm Function contains just the important bits, and starts running as soon as you press the play button.

Focus on the app

You end up writing a lot less mobile code too. Instead of writing networking and serialization code inside your mobile app, all you’re responsible for is the model and the data you create from it. Because the platform can take care of syncing, you get to focus on the app code that will actually make your app great—instead of the code that used to be necessary just to make your app work. You’re freed from all of the fragile code that you used to write to talk to the RESTful API that used to take up the rest of your time.

With a serverless architecture, you no longer need a dedicated devops and server team. You no longer need to know a server-side framework—just a little bit of JavaScript is enough. And you don’t even need to write all of the code that used to be necessary for communicating with a server, because the platform is designed to avoid that work in the first place.

The Realm Mobile Platform is a serverless platform that puts mobile use cases first. Data syncing is fundamental to great mobile apps (whether it’s to show your Uber driver’s location or the latest pictures from your family on Facebook). Server-side coding is also necessary, but instead of writing all of the boilerplate code that makes it possible to connect and share data between mobile apps, you can focus on the coding that matters—code that you can now write in the dashboard of your server, without learning anything more than JavaScript.

Mobile apps move as fast as we can. Features like live collaboration, two-way data sync, endpoint computing, and “offline first” used to be expensive and difficult to build. By adopting a serverless, mobile-first approach, developers can use Realm Functions to build next-generation capabilities at a fraction of the resources we used to spend just to set the stage for the apps we always wanted to build. Now we can just get to work, building the future.

New Tech Forum provides a venue to explore and discuss emerging enterprise technology in unprecedented depth and breadth. The selection is subjective, based on our pick of the technologies we believe to be important and of greatest interest to InfoWorld readers. InfoWorld does not accept marketing collateral for publication and reserves the right to edit all contributed content. Send all inquiries to newtechforum@infoworld.com.