
iOS at Facebook [pdf] - GarethX
https://static1.squarespace.com/static/5463eca4e4b09c644a61f99a/t/55fa801ae4b008853e3de038/1442480154751/SimonWhitaker.pdf
======
xenadu02
It's all a bunch of bored engineers looking for ways to be clever but without
anyone to take ownership of the codebase.

There is absolutely no reason for the Facebook app to be so large and have so
many classes. The app itself doesn't _do_ that much.

~~~
gorena
Yeah, the difference between Facebook and Instagram or Twitter is
_incremental_. They basically do the same stuff, Facebook does a little bit
more (although, they entirely removed direct messages). Why is the Facebook
app so huge?

~~~
Narretz
I wouldn't be surprised if all the messages code is still in the app.

~~~
edgyswingset
I've got an alpha of the Facebook for Android app and it's got all of my
conversations loaded, including text from the last message. It'll even light
up with a red indicator when I get a new message. All the actions start an
Intent which launches my Messenger app, though.

So yeah, it's probably all dead code that's still there.

------
randomsearch
It's interesting to note that this presentation strongly contradicts the
advice of "The Pragmatic Programmer" and "Clean Code", which are highly
respected by many. Does this mean that those books are wrong, or does it mean
that Facebook will eventually come to regret their philosophy? Or maybe
writing this kind of code is somehow fundamentally different, so the usual
wisdom and rules of thumb don't apply.

I really don't know the answer, but find it fascinating and can't wait to see
what Facebook is doing in 10 years time.

~~~
alexpersian
I think what it means is that as it stands now, there is no definite good/bad
way to make successful software. There are just opinions.

~~~
buffoon
There are definite bad ways. I've watched a few companies go down the shitter
using known bad ways.

~~~
Shish2k
I've watched a few companies go down the shitter using known good ways; and
seen companies with mind-blowingly horrific software succeed based on
marketing and contracts. There are a lot of anecdotes, but I have yet to see
any data suggesting a correlation.

------
micampe
This didn't really tell me why Facebook needs 400 people to work on the iOS
app and 75 commits per hour.

~~~
joeblau
What's crazy is that WhatApp has 4 Android engineers and 1 billion downloads.

~~~
avinassh
> What's crazy is that WhatApp has 4 Android engineers

Interesting. Any source for this claim? And also what's the full size of
Whatsapp team?

~~~
joeblau
Jan Koum on Twitter when their app crossed 1 billion users on the Google Play
Store[0]. Not sure what their current team size is, but it seems like it's
around 40-50. Last year at Startup School, Jan said the backend team 7-8
people on the backend[1].

[0] -
[https://twitter.com/jankoum/status/575740639444336640](https://twitter.com/jankoum/status/575740639444336640)

[1] -
[https://youtu.be/8-pJa11YvCs?t=1272](https://youtu.be/8-pJa11YvCs?t=1272)

------
bjano
So the main purpose of most of the 18000 classes is to make it possible for
the app to scale up to 18000 classes? :)

~~~
zacblazic
Partly! The tools they mentioned (IDE, Mercurial) don't impact the app itself
though. Which makes them irrelevant and doesn't factor into why their codebase
is massive.

~~~
0x4a42
They are relevant if you take them for what they are: examples that explains,
in a general way, why FB has large codebase. Because when something doesn't
fits their needs they will write their own version.

So I guess with iOS they wrote/rewrote some part of the system
functionnalities to better fit their needs.

------
shyber
FYI when Sun owned the FB HQ building the address was 1 Network Drive :)

------
emanuelev
Can't even imagine the amount of crap in their code-base. I bet that amount of
commits is necessary to continuously correct the shitload of mistakes coming
from their "Hacking" culture.

~~~
onewaystreet
They deal with this with automated code review tools like their Infer static
analysis tool ([http://fbinfer.com](http://fbinfer.com)) as well as
abstracting away the Objective-C with React Native.

~~~
emanuelev
Yeah that might work for programming mistakes, but not sure it can help with
bad design choices.

------
brodd
Am I reading this right, there are interns and engineers running PHP in a
debugger on production data? How else would he be able to memorialize his own
account and trigger the email?

~~~
randomsearch
That is a good point, how did no-one else pick up on that???! It reminds me of
engineers where I used to work, who would run through a £0.01 transaction on
their credit card to check the changes to the charging system were still
working...

------
spydum
So, FB app is bloated because they choose to be sloppy is what I read. Wonder
how sustainable this is over the long term?

~~~
phn
Sloppy?! Those guys have needs the majority of us will never need to deal
with. Did you read the presentation?

If anything they're the opposite of sloppy.

~~~
Touche
The parent is not referring to those needs (which are legitimate). The
presentation talks a lot about the hacking culture; how there is a lot of
duplicate code, a lot of dead code, a lot of "temporary" code.

We call these things technical debt. But it sounds like they just never fix
them. Refactors never happen.

~~~
phn
They don't call it debt. It is simply their way of keeping their agility with
a huge number of developers. If the flip side is junk that mostly impacts
install space, I don't see it as a bad trade-off.

What alternative way would you suggest to keep your mega team productive and
shipping features?

~~~
Touche
You can't avoid fixing tech debt. Eventually it impedes your ability to be
productive. It happens, to some degree, to every software project. Someone
else joked about "we wrote the app from the ground up" but that really does
happen. You're not "shipping features" if you're rewriting the app.

------
chuckcode
Would be interested to see some comparison with the Android app which seems to
have most of the same functionality at 1/4 the size with 25MB [1] compared to
the 100MB of iOS. Seems like either iOS team at FB has significant cruft
laying around or iOS doesn't scale as well as Android and FB is hacking around
that. Possibly a bit of both but think it would be an interesting comparison
in addition to the war stories about hacking their entire tool chain.

[1] [https://gigaom.com/2015/01/26/facebooks-new-android-app-
goes...](https://gigaom.com/2015/01/26/facebooks-new-android-app-goes-light-
on-the-data/)

~~~
dmishe
iOS apps are shipped as fat binaries, so for one, part of that 100mb app is
duplicated slices of binaries for armv7, arm64 and possibly, but not likely,
armv7s.

Android apps enjoy bytecode that is getting JIT-ed on install.

~~~
dgallagher
Apple has introduced App Thinning in iOS 9 apps which should cut down on their
size:

[https://developer.apple.com/library/watchos/documentation/ID...](https://developer.apple.com/library/watchos/documentation/IDEs/Conceptual/AppDistributionGuide/AppThinning/AppThinning.html)

~~~
azsromej
The feature was recently delayed, but it should help once it's ready

------
cableshaft
This was pretty interesting. It would have never occurred to me that XCode,
Git, etc. couldn't handle as much as you throw at it, but it kind of makes
sense how they explain it here. Still, I don't think I would like to actually
work in that environment where the codebase changed so much so often and had
so much dead and redundant code, so I guess I'm glad my interview with them
didn't go terribly well (got asked questions by non tech-type person who was
looking for keywords to obscure concepts as answers and didn't understand my
conceptual but keyword-less responses).

~~~
jonknee
Apple uses XCode to make iOS (and OS X and even XCode!), so it obviously can
handle more than Facebook.app, but it doesn't fit their culture. Same with Git
frankly.

~~~
gorena
Or they could just modularize into frameworks and use Carthage?

But, whatever, rewrite Xcode I guess.

------
rabino
The unnecessary bashing of PHP, the lame justification for a sloppy
architecture, the immense ego... I don't think hack culture should be used to
justify asshole-ery.

------
randomsearch
This is truly a superb read. Don't just read the comments!

------
bsaul
So i guess maybe Apple didn't code their ios and ios apps using xcode, xcode-
git, autolayout and coredata after all. Because their scale seems pretty big
too.

------
rckrd
Some sidenotes: I'm surprised to see so many custom libraries for Paper, an
app which I had forgotten about. And another reminder that a lot of companies
at scale are choosing mercurial over git.

------
gorkemyurt
(Another post about React Native)

Facebook engineers keep telling everyone that React Native is not used in the
main Facebook app. I always wondered what is stopping them from start using
it. Perhaps app size is a massive concern? Maybe all this tooling around their
app is not really compatible with React Native?

Its interesting that they have a ton of legacy Obj-c code (considering that
companies started to build apps not very long time ago, and they already re-
wrote their app several times) I wonder if any other company is a situation
like this well other than Apple.

~~~
zghst
It would probably be a huge pain to migrate all 18,000 classes, tests, tools,
etc., over to a React Native app. Also JS has less fine grained tooling for
performance profiling (try stepping through JS bytecode for performance
analysis, it's a PITA). One day it might get there, but not today. If it
works, why change it?

~~~
gorkemyurt
I am not talking about migrating the whole app but how about for new features?
I noticed that they redesigned their friends request page, why not build that
with react native?

~~~
plorkyeran
The engineers who did that redesign didn't want to use react native or felt it
wasn't a good choice. Just because one person at Facebook built a tool doesn't
mean that everyone else at Facebook is suddenly required to use that tool
where ever possible.

------
m4tthumphrey
This was an awesome read. Thanks Simon!

------
vinceyuan
This post is very interesting. News reported Facebook would create a
simplified Android app for low end phone owners in Africa. I think They should
do it for iOS too.

~~~
untog
They already have, it's called Facebook Lite. You can't get it from the Play
Store in the US, but I download an APK. It's nice.

I only really downloaded it so that I could get notifications, and now
m.facebook.com can send them from Chrome, so I'm very happy to totally app-
less.

------
colinbartlett
I loved the anecdote starting on page 41 where he accidentally "memorializes"
his Facebook profile thus triggering an email to his wife about his death.

------
JamesBaxter
Very interesting, even as a fan of native apps I can see the thought process
behind doing it web based when you have to build so many tools for each
platform.

~~~
miguelrochefort
Except it's mostly not web based.

~~~
Synaesthesia
Yes interestly enough there was a period when the front-end for mobile was
html5 based but they since ditched that for greater (native) performance, in
fact as this article reveals, a number of implementations!

------
bsdpython
tl;dr Software engineering at extreme edge cases of performance and
scalability can look very different than your typical use cases. Don't do this
at home (until you have to). Interesting none-the-less.

~~~
mnem
> extreme edge cases of performance and scalability

That gave me a chortle :)

------
sabujp
what is fb doing for iOS builds and compiles?

~~~
aaronbrethorst
[https://github.com/facebook/xctool](https://github.com/facebook/xctool)

~~~
rimantas
which is just a wrapper around Apple's xcodebuild.

~~~
aaronbrethorst
What's your point?

------
buffoon
"Done is better than perfect"

"Move fast and break things"

I'm glad they're not holding any critical data like our personal information,
what we do, what we think and where we are then!

If this set of slides embodies 'hacker culture' which it claims to, I am not a
hacker, neither are my colleagues and I'm proud of that.

The whole thing stinks of arrogance hiding incompetence. I'm not putting
anything near facebook, ever.

~~~
asdfqwe1
To be fair, most of these specific signs have been removed now/changed (I was
an intern there fall 2013). They actually talked about how that used to be a
slogan, but breaking stuff isn't really acceptable anymore because facebook is
so big. They still wanted us to move really fast though...

~~~
zeeshanm
From what I have heard they are now expecting their employees to still move
fast, break stuff, but be ready to be penalized for it if you do. So, really,
they are encouraging their employees to move at a steady pace with occasional
hack nights when there is an upcoming release in the near-term. Facebook is
growing old.

~~~
gorena
Does Facebook pay overtime for "hack nights"?

~~~
edgyswingset
No, but they make up for it by consistently throwing piles of money at
peoples' feet which dwarf the compensation of all but a handful of other jobs.

------
joeblau
It seems like with such a strong engineering team, Facebook should have really
built their own phone. It's impressive that they re-wrote a lot of the major
components the iOS development process and optimized them for their scale. I
think a Facebook style development platform on it's own hardware would be an
interesting contrast to Google's and Apple's solutions. One challenge with
learning this type of development stack is that you're almost not even
learning traditional iOS development so your skills aren't truly
transferrable.

~~~
artmageddon
> It seems like with such a strong engineering team, Facebook should have
> really built their own phone.

They actually tried not too long ago... [0]

[0] [http://www.cnet.com/news/heres-why-the-facebook-phone-
floppe...](http://www.cnet.com/news/heres-why-the-facebook-phone-flopped/)

