Lyft Goes Swift: How (And Why) It Rewrote Its App From Scratch In Apple’s New Language

Lyft’s old code used to be positive. however its new model is tighter, more straightforward to take care of—and prepared for the longer term.

September 10, 2015

When Apple ended its WWDC keynote in June 2014 by way of saying Swift, an all-new language for developing iOS apps, it used to be an strange second for a couple of causes. For one factor, it was once a significantly technical bit of stories right through a keynote that traditionally addresses consumers as much because it does engineers. For another, Apple had efficiently kept Swift secret, making its debut a genuine shocker.

the possibility of a up to date programming platform designed with iOS in thoughts obtained a lot of builders excited. nevertheless it additionally raised questions. How simple would it be to recreate apps written in purpose-C, the existing same old for iOS construction? Would the advantages of working in a more up-to-date surroundings counterbalance the hassle of starting from scratch? If Swift used to be the long run, would it not make more experience to dive right in or wait except it used to be a refined, confirmed platform?

among the app developers that wrestled with such considerations was once Lyft, the San Francisco-based totally driver-on-demand car service. It concept the subject over, then put one developer on Swift to research the situation, and then, in due time, determined to redo its complete application in Swift. slightly over a 12 months after Apple’s announcement, it was once prepared with an all-Swift version of Lyft. the company believes that it is the greatest app to make the transfer, both relating to strains of code and selection of customers.

“Early on, we recognised this as quite of an test, and really risky,” says Chris Lambert, the company’s CTO. however by pursuing the challenge at the proper percent, it ended up with a model of the app that made its builders far more productive and satisfied—and which carried out identical to the outdated one, proper out of the gate.

Out With The previous

In a method, it’s exceptional that Apple waited except 2014 to unveil one thing like Swift. purpose-C originated in the early Eighties, lengthy earlier than it took place to any individual that instrument engineers would in the future write applications for telephones. It came to Apple by way of next, Steve Jobs’s 2nd startup, which Apple acquired in 1996. When the company drew on next know-how to supply the technical underpinnings of the iPhone and iPad, goal-C was a part of the package.

The language doesn’t have a popularity for being a cakewalk to learn or a pleasure to work in. however Lyft did not see it as a specific drawback, either. “i’d say objective-C wouldn’t have considered nearly the adoption it noticed with out iOS, obviously,” says Lambert. “but no person evaded writing purpose-C, nobody dreaded writing objective-C.”

still, no language with roots courting to the primary Reagan administration goes to really feel reducing-edge. “you have to see some great benefits of Swift, simply in compactness and the extra modern programming paradigm that came into play,” says Pete Morelli, Lyft’s VP of engineering. moreover, the Lyft app itself was exhibiting its age. the corporate had whipped up the unique version in 2012, when it used to be referred to as Zimride and decided to pivot from being a standard ride-sharing service into one thing more right away competitive with Uber. because it added options, it slathered them on top of that original foundation.

“many of the code has been rewritten during the last three years, but some core parts of it have been nonetheless maintaining strong,” explains Lambert. “but we might have constructed a distinct app if we’d started over.”

“We were an extraordinarily completely different company in 2012 after we started this,” adds Sebastian Brannstrom, Lyft’s very first developer. “We basically hacked collectively Lyft in the course of two weeks, Eduardo [Perez Rico] and me. a number of the sins of these days are nonetheless with us. however that’s the way you get began.”

Lyft engineers Sebastian Brannstrom and Martin Conte Mac Donellpicture: Harry McCracken

starting Small

If nothing else, shifting to Swift would supply the company the chance to fix every little tense thing about its code that had built up through the years. but the company still did not recognize sufficient about Swift to be positive that it used to be prepared for an app as ambitious as Lyft.

So fairly than rolling the dice, Lyft did one thing that wasn’t unsafe at all. last September, it assigned a single developer—recent recruit Martin Conte Mac Donell—to start dabbling in Swift. He commenced putting together a prototype. After a month of working by himself, he had a rough draft working. principally, it can help you request a automobile.

The expertise impressed him. Swift was powerful and simple to examine. “I was in reality able to be really, in point of fact productive in a short amount of time,” he says.

Lyft’s Swift app

Conte Mac Donell’s confidence made Lyft extra confident. “Come January, we indubitably had enough to make us confident that this was something we needed to speculate vital resources into,” says Brannstorm. In March, the company started out to place extra builders on the Swift undertaking. It obtained much more conversant in the brand new environs via implementing certain features within the principally purpose-C model of the app on the same time it was once working on the all-Swift revamp. by means of June, just about every iOS developer used to be working in Swift; on average, it took two or three weeks for any given engineer to be up, working, and at ease.

As Lyft’s engineers dived into Swift, their expertise mirrored Conte Mac Donell’s early favorable impressions. “by the time we have been working on this Swift venture, we were also working in parallel on revamping your entire onboarding float of the app,” he says. “On the old [version], that used to be a project that took more than a month, with a couple of engineers. And with Swift, that used to be a venture that took per week for one engineer.”

Swift code was once also far extra compact than goal-C, which made it easier to understand and manage. through the years, the unique model of Lyft had ballooned to seventy five,000 traces of code. by the point the corporate was once done recreating it in Swift, they had something that performed the identical tasks in less than a 3rd of that.

Flipping The change

Swift was once so new that Lyft’s engineers were essentially debugging the language itself in addition to their app. “as a result of we had been one of the crucial greatest tasks using simplest Swift, we had the entire biggest challenges,” says Conte Mac Donell. “We worked aspect through facet with Swift developers in reporting these issues.”

“They have been extremely attentive to all the issues we found early on,” provides Morelli. “Having that strong relationship and having that back-and-forth, which may also be extraordinary now and again with Apple, was once in point of fact useful.”

When the corporate had a Swift app that kind of worked, it started out checking out it from each a passenger and driver standpoint—the latter of which used to be that you can imagine partly because numerous Lyft staff are also Lyft drivers on the side. “Even with simply an employee beta take a look at, we have been in a position to catch driver-facet bugs, passenger bugs, the whole ride go with the flow,” says Lambert. “It used to be a lovely thorough process.”

For the entire beta testing Lyft did, it couldn’t be positive how hassle-free its Swift app was except it released it on the app retailer. And if there have been problems, they may affect vast numbers of passengers and drivers suddenly, imparting a threat to a trade that relies on so many things working appropriately in real time.

“some of the challenges of doing something like this is, you don’t actually have a conceivable gradual rollout technique for iOS,” says Lambert. “Android has a little bit bit of a leg up there, the place you are able to do a 1%, a 5%, a 10% rollout. With iOS, mainly, it’s reside or it can be not, which puts quite a lot of the burden on the engineering group. everybody who has auto-update turned on on their telephone will have it inside an hour.”

On July 16, Lyft deployed the Swift version to the App retailer. And . . . it labored. Making the day momentous for the company, but completely uneventful for its passengers and drivers.

looking back, one of the hanging things about the project used to be that it didn’t decelerate the advance course of. usually, the corporate pushes out a new version to the App retailer on a weekly basis. With the move from goal-C to Swift, it skipped a weekly cycle—but just one. Which presentations that the transition, formidable though it was once, wasn’t a time sink. as a substitute, Swift’s efficiency compensated for the labor curious about studying a new language and recreating an uncommonly advanced app. And it did so straight away.

“We noticed that as we have been porting to this new infrastructure, people had been able to do things so much quicker,” says Morelli. “at the same time as new options were delivered, the Swift people were ready to catch up.”

As easily as the effort went, most of the merit is but to come back. “using modern instruments opens the doorways for the whole thing Apple is already planning—new structures, new gadgets,” says Conte Mac Donell. “the whole lot’s going to revolve round Swift.” because it does, Lyft will not must scramble to get with the program. because of its early decision to go all-in with Swift, it is ready presently.

[Photos: courtesy of Lyft]

quick company , learn Full Story

(100)