
Why the Facebook iOS Application is so large - jafitc
http://quellish.tumblr.com/post/126712999812/how-on-earth-the-facebook-ios-application-is-so
======
dshankar
If you're having difficulty loading this webpage, it's because the author
decrypted Facebook's iOS binary and listed all 18,000 header files.

Yes, this webpage is merely a list of 18,000 headers.

~~~
jafitc
1\. The article gives the insight that the binary is sooo big, not just assets
as one would think.

2\. It shows how the classes are extracted

3\. It presents the classes for you to browse.

The word "merely" is downplaying the information being shared by the author.

~~~
mynameisvlad
Barely does 1 and 2 since 3 causes browsers to actually slow down to a crawl.
The second that 18k list started to load, my browser turned ridiculously slow.

~~~
jafitc
I agree that the inline HTML code block is not optimized for such a use-case.
You can read the content here:
[https://news.ycombinator.com/item?id=10066530](https://news.ycombinator.com/item?id=10066530)

Still my point was about the content being simply a list, which it is not (for
better or worse in this case, I know :-)

------
64mb
TL;DR Facebook app has 18k classes, if you want to know what they are look
here:
[https://gist.github.com/quellish/473f513fbd1310233a8e](https://gist.github.com/quellish/473f513fbd1310233a8e)

FB App is 114MB in size, but loading this page in Chrome will use a good
450MB, idk how they managed that.

~~~
nolok
> FB App is 114MB in size, but loading this page in Chrome will use a good
> 450MB, idk how they managed that.

Comparing the size of the binary with the size of the memory used by the live
program is apples to oranges. The two metrics don't have any correlation
whatsoever.

~~~
coldtea
He doesn't compare the size of the binary with the size "of the memory used by
the live program".

He compared the size of the binary with the size (in Chrome's memory) of the
idiot's webpage complaining about it.

Which he obviously knows is Apples to Oranges, but it's still fun to know and
illuminating (the guy blames FB for being too careless with their app size but
is too stupid to watch for his web post's size).

~~~
jafitc
I love how easily some ppl on HN call someone an idiot. Way to encourage
people to share.

I found it interesting even if my browser ate 260 whatever MB of memory.
Doesn't make him an idiot, just a little bit lazy about optimizing his blog
(which is not used by millions like the Facebook app)

It seems none of the cool kids with lean blogs managed to post this stuff or
get it on HN. I'd love to read their articles about it, but hey, they don't
seem to exist.

~~~
coldtea
> _I love how easily some ppl on HN call someone an idiot. Way to encourage
> people to share._

We live in the "social sharing age". People even share what they had for
lunch. If anything, people should be encouraged to share LESS or more
meaninful stuff only.

> _It seems none of the cool kids with lean blogs managed to post this stuff
> or get it on HN. I 'd love to read their articles about it, but hey, they
> don't seem to exist._

Serving something you want to read doesn't mean there should be no criticism
for serving it in a bad way.

If you had only one chinese restaurant in your city, one that served bad food,
would it make sense not to complain for their good quality because "other
restaurants don't serve noodles at all"?

~~~
jafitc
> Serving something you want to read doesn't mean there should be no criticism
> for serving it in a bad way.

There's criticism of serving something in a bad way, and then there is calling
someone an "idiot".

Should we instantly call every single person an idiot for making a mistake?

I wouldn't say that the food was bad here, it was just a bit cold.

> We live in the "social sharing age". People even share what they had for
> lunch. If anything, people should be encouraged to share LESS or more
> meaninful stuff only.

This is off topic, but I don't think people should share less. If you are
bothered by it, you should read less. Maybe we should have better tools for
filtering. But information is everything, something as banal as "I had a bad
day" has value. Tracking social sentiment for example.

~~~
coldtea
> _There 's criticism of serving something in a bad way, and then there is
> calling someone an "idiot"._

True.

> _Should we instantly call every single person an idiot for making a
> mistake?_

No, but what if they do that first by pointing fingers at the stupid FB devs?

> _This is off topic, but I don 't think people should share less. If you are
> bothered by it, you should read less._

This still leaves the problem of an overproduction of pointless stuff, which
aside from the ecological issues and time wasted by those producing it, also
makes deciding "what to read" among the avalance of BS more difficult.

------
aaronbrethorst
I was expecting a bit more nuance and insight than '18,000 classes, lol, FB is
dumb.' At the very least, it'd be interesting to note what the size of the app
might be after app thinning goes live next month.

~~~
pests
Details on app thinning?

~~~
crgt
In brief, a new feature of iOS 9 that allows app resources to be delivered on
a device specific basis..meaning that, for example, a user with an iPhone 5
will no longer need to download assets meant to support the 6+ or iPad. More
here: [http://arstechnica.com/apple/2015/06/app-thinning-will-
be-a-...](http://arstechnica.com/apple/2015/06/app-thinning-will-be-a-major-
boon-for-8gb-and-16gb-iphones-and-ipads/)

~~~
NoCulturalFit
Not just assets, but also the compiled binary will be for that architecture
alone. ARM6, ARM7 etc. Really cool stuff.

------
sovande
This so called "investigation" of the Facebook app can be done much simpler.
Locate the app in iTunes, rename the .ipa file to .zip, unzip and run otool
and nm on the binary. The author list 18,000 header files which is not much of
an investigation nor much interesting. Though the staggering number of classes
does admittingly somewhat explain the enormous size of the FB app. I do not
use the FB app, but generally it can be equally illuminating to look in the
Resources/ folder of an app if you wonder where the size came from.

~~~
0x0
No. You have to jailbreak and "crack" the app to get at the code segment,
which makes this more of an effort than you make it out to be. Unless you know
something I don't?

~~~
conradev
The symbols themselves are not encrypted, so you can still list those without
cracking the app.

------
revelation
Their binary alone is 118MiB? Even with all the auto-generated crap in there
(I hope no human chose those names), how do they manage that?

I wonder how long it takes for an iPhone to even load that thing into memory
before it starts executing any code..

~~~
geon
> I wonder how long it takes for an iPhone to even load that thing into memory
> before it starts executing any code..

I takes my iPhone 4s about 5-10 seconds to start it.

------
wruza
Seems to me that huge part of this was auto-generated (and auto-structured),
and each .m/.h contains very few lines of code. I don't know what FB app does,
but with 18000+ fully functional non-excessive handwritten modules you can
just win the internets. Oh wait~

------
natch
They are obviously very lost and reinventing wheels, rather than learning and
applying the right design patterns for Apple platforms. I talked to a Facebook
iOS person on here recently who was under the impression that GCD offered no
help with concurrency problems.

------
delinka
Chrome asks to kill the page after a bit. Does this content exist in a cleaner
state?

~~~
dynomight
I opened it in the opera version of chrome and it loads no problem. The
browser isn't the best at everything but sometimes it works when everything
else fails.

~~~
manojlds
There is no Opera version of Chrome. Opera uses Blink, that's it.

~~~
dynomight
Apparently Chrome uses blink too. But now I can see how one is not the other
even though both use the same.

------
klapinat0r
I _hope_ it's a mechanism to make it possible for new employees to actually
work on this app.

Perhabs someone with experience on large complex applications can share some
insights?

Otherwise, I pity the FB employees who gets assigned to this project. " _Here
you go, fix that button, here 's 18k files to digest_".

Surely they must've decoupled it into oblivion in order to have a class that
manages "just that", so

1\. new employee can work in an "isolated" context (although he really isn't)

2\. can locate where to write and debug in this complex codebase.

------
Namrog84
But then they can say. In 2.0 we improved performance 50%!! And repeat this
process of headline news several times!

------
kenOfYugen
unneeded complexity

~~~
codeshaman
Lots of money, lots of employed engineers, everyone needs to do something.

That's the case with a lot of tech today - it's done for the sake of letting
people do something. Which, I guess, is not that bad, in the end things are
brought to perfection, even though they're not strictly 'needed' in the
product. The fast CPUs and enough RAM take care of the added complexity and
everyone's happy.

~~~
mehrzad
I hope that's not the case, considering there are much more interesting things
Facebook employees could be working on (not necessarily even for the
betterment of society).

~~~
ethanbond
It seems to definitely be the case for designers (300+?), I wouldn't be
surprised if it's the same for engineers.

10,000+ people to keep the service running?

------
jafitc
I've never seen an iOS application quite like this. I wonder how they even
manage it. Tons of subprojects perhaps?

~~~
ioddly
I wonder how much of it is automatically generated.

~~~
Animats
That's a good question. Is much of this the output from some GUI design tool?
There seems to be a class for every GUI element.

------
vbezhenar
That's what I call a fat client :)

------
mahouse
Makes me remember of that time they had to cheat on Dalvik because they hit
the 65k methods limit 8-)
[https://news.ycombinator.com/item?id=8162342](https://news.ycombinator.com/item?id=8162342)
(blog link is dead)

Anyway, I find this to be pointless, when the majority of that size is
probably taken by assets.

