Engineers Detail Extensive Efforts to Rewrite Facebook iOS App

MacRumors

macrumors bot
Original poster
Apr 12, 2001
46,727
8,945





Facebook employee Jonathan Dann has written a blog post detailing how the company's iOS engineering team designed earlier Facebook for iPhone apps and the extensive coding that was required to rewrite the new Facebook 5.0 app.

The post is a bit technical in parts, but is worth a read for developers and others interested in how one of the most popular iPhone apps gets made.

An excerpt:
One of the biggest advantages we've gained from building on native iOS has been the ability to make the app fast. Now, when you scroll through your news feed on the new Facebook for iOS, you'll notice that it feels much faster than before. One way we have achieved this is by re-balancing where we perform certain tasks. For example, in iOS, the main thread drives the UI and handles touch events, so the more work we do on the main thread, the slower the app feels. Instead, we take care to perform computationally expensive tasks in the background. This means all our networking activity, JSON parsing, NSManagedObject creation, and saving to disk never touches the main thread.

To give another example, we use Core Text to lay out many of our strings, but layout calculations can quickly become a bottleneck. With our new iOS app, when we download new content, we asynchronously calculate the sizes for all these strings, cache our CTFramesetters (which can be expensive to create), and then use all these calculations later when we present the story into our UITableView.

Finally, when you start Facebook for iOS, you want to see your news feed, not a loading spinner. To provide the best experience possible, we now show previously-cached content immediately. But this introduces a new problem: If you have a lot of stories in your news feed, UITableView throws a small spanner in the works by calling the delegate method -tableView:heightForRowAtIndexPath: for each story in your news feed in order to work out how tall to make its scrollbar. This would result in the app loading all the story data from disk and calculating the entire story layout solely to return the height of the story, meaning startup would get progressively slower as you accumulate more stories.

The solution to this particular problem has two main parts. Firstly, when we do our initial asynchronous layout calculations, we also store the height of the story in Core Data. In doing so, we completely avoid layout calculation in -tableView:heightForRowAtIndexPath:. Secondly, we've split up our "story" model object. We only fetch the story heights (and a few other things) from disk on startup. Later, we fetch the rest of the story data, and any more layout calculations we have to do are all performed asynchronously.
Article Link: Engineers Detail Extensive Efforts to Rewrite Facebook iOS App
 

Tinmania

macrumors 68040
Aug 8, 2011
3,456
905
Aridzona
Hate to see if they had to work on a game or some other app that really required good coding skills.

I guess making an app to download cat pics and "I'm going to bed now!" messages was tough work.



Michael
 

room237

macrumors 6502
Oct 20, 2008
322
1
Queens, NYC
It's marginally better. Completely rewritten, huh? So instead of making actual improvements on the UI in the process, they kept the same limited capabilities and just made the app start up a little faster.

Still no way to share posts.
 

zagm

macrumors newbie
Jun 22, 2010
1
0
he could have just said he was "wired in" and made that quote a lot shorter
 

Pakaku

macrumors 68020
Aug 29, 2009
2,193
2,191
It's marginally better. Completely rewritten, huh? So instead of making actual improvements on the UI in the process, they kept the same limited capabilities and just made the app start up a little faster.

Still no way to share posts.
I don't use the facebook app, but I'm pretty sure I'd like a decent, usable app that's missing a few features, rather than a terrible, laggy app.
 

JangoFett124

macrumors regular
Jul 16, 2002
176
15
Hate to see if they had to work on a game or some other app that really required good coding skills.

I guess making an app to download cat pics and "I'm going to bed now!" messages was tough work.



Michael
Do you have programming experience?
 

NT1440

macrumors G5
May 18, 2008
12,176
14,210
It's marginally better. Completely rewritten, huh? So instead of making actual improvements on the UI in the process, they kept the same limited capabilities and just made the app start up a little faster.

Still no way to share posts.
There are actually quite a few improvements on UI, but FB specifically stated this update was for performance only. Rumors put a major overhaul in the near future, perhaps even further integration than the built in FB features of iOS 6?
 

TylerL

macrumors regular
Jan 2, 2002
167
181
It's always great to see real-world hard-won experience doled out like this.

To those mad there aren't more changes, rebuilding is hard. New features are hard too. Don't do both at once. Rebuilding makes future changes easier.
Patience. Mobile users barely make Facebook money anyway.
 

bushido

Suspended
Mar 26, 2008
8,070
2,746
Germany
i can no longer delete comments i made on someone elses post! this could be rly embarrassing after a drunk night out!
 

slrandall

macrumors 6502
Jun 15, 2011
412
0
Hate to see if they had to work on a game or some other app that really required good coding skills.

I guess making an app to download cat pics and "I'm going to bed now!" messages was tough work.



Michael
Never coded before, have you? Games are difficult but nowhere near the most challenging.
 

JangoFett124

macrumors regular
Jul 16, 2002
176
15
Nah.... just how I have earned my living for the last 11 years. That's all lol.
Sorry, it's just that your comment makes it seem like you have never coded anything of quality. Just because it can display cat pictures doesn't make it trivial. I would expect anyone with experience to respect the work that went into this app, especially after reading the linked article.
 

Laird Knox

macrumors 68000
Jun 18, 2010
1,767
938
Hate to see if they had to work on a game or some other app that really required good coding skills.

I guess making an app to download cat pics and "I'm going to bed now!" messages was tough work.



Michael
That's what I got out of his remarks too. :) Facebook isn't rocket surgery. Sounds like they have a bunch of green programers trying to reinvent the wheel.

Kudos to their infrastructure and backend for handling the insane amounts of traffic but not so much for the front end design.
 

jaymzuk

macrumors regular
Jun 1, 2012
216
44
This seems like quite a big victory for Apple.

My view was that well-written HTML5 apps were probably the greatest threat to iOS, as they could potentially circumvent the whole App Store and walled garden approach. But with Facebook going down this route, many other developers may be discouraged from using HTML5 as the bedrock of their apps
 

borisiii

macrumors 6502
Jul 4, 2010
358
0
For any other company a good mobile app is assumed. Facebook are trying to do an Adobe and and convince everyone what a huge effort it was and how grateful we should be...
 

OldSchoolMacGuy

Suspended
Jul 10, 2008
4,197
8,906
"Extensive effort" compared to the total lack of effort they'd previously put into it I guess. Still not an app that would take long to produce much less the years it took them.

----------

There are actually quite a few improvements on UI, but FB specifically stated this update was for performance only. Rumors put a major overhaul in the near future, perhaps even further integration than the built in FB features of iOS 6?
It's going to be quite a while before we see any kind of redesign of the mobile app. Facebook has to figure out how to make money on mobile before they'll bother putting any effort into the app. With over 60% of their users accessing FB through mobile, it's a huge hit to them that they still haven't figured out how to monetize mobile.

In a single week they just lost their Design Manager, Director of Platform Partnerships, Platform Marketing Director, and Mobile Platform Marketing. It's going to be a while before they figure out anything with mobile and look to redesign their mobile app.

Although we have seen that the new FB app update did add spammy suggestions of games and crap that you should install.
 

nick_elt

macrumors 68000
Oct 28, 2011
1,578
0
With the new app I cant access my profile. Yes its faster but theres a few bugs. Wish I could "downgrade" i you could call it that.
 

aristotle

macrumors 68000
Mar 13, 2007
1,768
5
Canada
Nah.... just how I have earned my living for the last 11 years. That's all lol.
HTML and Javascript do not count as software development.

Have you written anything for the consumption of end users in any of the following languages:
C/C++, C#, Java, Perl, Python?

I have been working as a software developer for almost 15 years and I have written mission critical software using each of those languages in my career.

I also dabbled in web development which included both client side and server side code but if someone only dealt with client side scripting and layout then they really could not rightly call themselves a "developer".
 

Tinmania

macrumors 68040
Aug 8, 2011
3,456
905
Aridzona
Never coded before, have you? Games are difficult but nowhere near the most challenging.
I didn't say "the most challenging." I compared to a Facebook app, which is trivial compared to a high-level game of today.

I am a front-end business application designer and database programmer. I would rather be assigned to work on anything even remotely like facebook versus working on a modern game. And by game I am not talking about Words with Friends or its ilk.

But if you want to believe the Facebook app is some kind of impossible to code "app" go right ahead.

As for me, optimizing simple processes that shouldn't have been intensive in the first place is not something I am impressed about. :cool:




Michael

----------

HTML and Javascript do not count as software development.
:rolleyes:
So why did you bring them up, cupcake? No one else did. :p



Michael:confused:
 

Bluefusion

macrumors 6502
Apr 25, 2003
257
0
New York, NY
I think it's pretty obvious that the Facebook app has always been atrociously bad. Not just "slow", or "missing features" or "not amazing", but horrendous. Thus, the fact that it now "sorta works" is hardly cause for celebration. No company of Facebook's size should have ever produced something this bad. Once it stopped being able to load any content whatsoever for me (even after deleting and redownloading), I gave up. That was over 8 months ago.

I get that programming is hard. The thing is, if it is your job, wouldn't you be embarassed to have produced this garbage?

Spewing technobabble is hardly a worthwhile "argument" in favor of how long this took.

Hope the new one is good. I'm not going to bother downloading it, though, since I just use the website...
 

KnightWRX

macrumors Pentium
Jan 28, 2009
15,046
4
Quebec, Canada
But if you want to believe the Facebook app is some kind of impossible to code "app" go right ahead.
There is no impossible to code "app". But to say the Facebook app is trivial is quite insulting to the people who worked on it, be it the HTML5 cross-platform version or the current iOS native port.

Database programming ? I guess now we know why you think Facebook is trivial, you don't know the half of it beyond the SQL join used to extract the data from the database, "cupcake". :p
 

OldSchoolMacGuy

Suspended
Jul 10, 2008
4,197
8,906
HTML and Javascript do not count as software development.

Have you written anything for the consumption of end users in any of the following languages:
C/C++, C#, Java, Perl, Python?

I have been working as a software developer for almost 15 years and I have written mission critical software using each of those languages in my career.

I also dabbled in web development which included both client side and server side code but if someone only dealt with client side scripting and layout then they really could not rightly call themselves a "developer".
Oh god. You sound like everyone at WWDC comparing their developer e-penises. That's one of the reasons my company stopped going years ago. My boss has been writing software since he was 8 and worked for EA writing video game control systems at age 12 amongst other jobs. He still doesn't want to sit around with a bunch of programmers trying to figure out who is the most elite amongst them.
 

Codestud

macrumors member
Nov 1, 2011
79
13
Software has sadly been going down the road of bloatware and inefficiency for some years now due to PC users being spoilt by large amounts of RAM and processing power - it's been leading to a new breed of programmers who just don't know how to write tight and efficient code, unlike those of us who grew up in the 70s and 80s.

Doing asynchronous programming to keep the UI thread clear should be standard programming practice, and it's what should have been done in the first place for such a mission critical app for Facebook.

With any luck, this rewrite exercise has taught a few developers some valuable lessons.