8 ms·
Under the hood: Rebuilding Facebook for iOS
- nutjob123 14y agoGood stuff. Can't wait for the android version. One more thing, I just spent 15 minutes figuring out how to change a co-worker's profile pic in the new app. I fear that simple use cases are becoming complicated.
- kennywinker 14y agoCool to hear about some implementation details. Curious if they will open source any of this stuff. My gut says no, but hope springs eternal...
- deleted 14y ago[deleted]
- newhouseb 14y agoIf you go into IOS Settings and then click Facebook > About you can see all of the open source components that they use (An enormous amount). It has everything from AQGridView to Boost to Chromium (what?) to PHP (again, huh?).
- sandyarmstrong 14y agoSince Facebook is a big PHP shop, it could be that they have some standard libraries where they prefer to use PHP's version as the canonical implementation. Then they port these to various languages. In some licensing interpretations, this would bind them to the license of the original code.
- kennywinker 14y agoInteresting. Could they be using code written in PHP, but converted to C++ using HipHop?
- sandyarmstrong 14y agoIt's certainly possible to use C++ in native iOS apps. I'd forgotten about HipHop, so that makes a lot of sense.
- ceejayoz 14y ago> to PHP (again, huh?) Were you not aware that Facebook is a PHP shop? Or are you just questioning its inclusion in the app's credits?
- newhouseb 14y agoDefinitely aware, just normally accustomed to license credits meaning "we used this in source code/binary form in our distributable app." I missed the fact that it was referring to the Base64 encoder/decoder which makes more sense.
- kennywinker 14y agoFor people who don't want to scroll through an endless stream of legal disclaimers and licences: https://gist.github.com/3441055 https://gist.github.com/3441055 Appirater AQGridView AutoHyperlinks Boost Chromium CocoaLumberjack CoreTextHyperlinkView EGODatabase EGOTableViewPullRefresh HPGrowingTextView jQuery JSONKit libphonenumber mosquitto OpenUDID PLCrashReporter protobuf QSUtilities Google Toolbox for the Mac Base64 library from PHP re2 SDWebImage UIImage+Alpha UIImage+Resize UIImage+RoundedCorner
- RandallBrown 14y agoFacebook is a pretty huge contributor to open source. The Three20 framework that they made which powered their original iPhone app was open source and used by tons of developers. They have a ton of repos on their github https://github.com/facebook https://github.com/facebook
- jamesaguilar 14y agoI wonder if they are done or are they going to still work on making it faster. Responsiveness when viewing your own profile is still atrocious on an iPhone 4.
- sidcool 14y agoI don't have access to the article. Can someone post it here or mirror it?
- christiangenco 14y agohttp://pastebin.com/fqDShqiK http://pastebin.com/fqDShqiK
- sidcool 14y agoThanks!!
- SlipperySlope 14y agoThis is very strong evidence that when performance matters to your iOS app, you are better off going native and not HTML 5. Who here thinks that Facebook should have stayed with HTML 5?
- mrwilliamchang 14y agoI think that staying HTML 5 is a mistake. As the needs of your app expand, there will be a greater and greater need to use native API's. The longer you develop in HTML 5 the more code you will have to port when you finally do decide to transition to native. You're better off minimizing your pain and transition to native early when there is less code to port.
- jlongster 14y agoI don't know enough about their app to give a detailed response, but it seems like the optimizations they performed could have just as well been applied to their HTML5 version. WebWorkers, for example, are available on iOS. It could be that they could never get true native speed without writing it natively. However, in my experience their HTML version was so awful that I suspect a lot of it was from bad decisions on how to use HTML5. That may be the problem though: that it takes deep knowledge to know how to leverage it correctly and speedily.
- wsc981 14y agoIf a company has the resources to support native development, I think there's no reason to stick with an hybrid HTML5 app. It's well-known that (because of security reasons) JavaScript is slow in a UIWebView compared to a real website, see: http://blog.mobtest.com/2012/05/heres-why-the-facebook-ios-app-is-so-bad-uiwebviews-and-no-nitro/ http://blog.mobtest.com/2012/05/heres-why-the-facebook-ios-a...
- MatthewPhillips 14y agoIt's because of a design mistake early in the iOS development.
- EthanEtienne 14y ago
- pdenya 14y agoWhat a strange article. I'm not sure who this is written for. There's no real details about anything technically interesting that they did other than including the whole messages app codebase in the new app. But explaining how their objects share protocols? Listing some data that they precalculated and the methods it saves them time in? This stuff is obvious to any current ios dev and useless to anyone who isn't an ios dev.
- biznickman 14y agoThis was exactly my thoughts ... I'm still trying to figure out why they would use multi-threading though.
- frankus 14y agoWha? The UI needs to keep processing events to remain responsive. If you have a long-running (relatively speaking, say 10 milliseconds) process like uncompressing an image, you don't want your UI to lag for that long. You could have the image decompressor look up every millisecond or so to see if there are any UI events to process, but that leads to the sort of spaghetti code that multithreading/multitasking was built to address.
- jonathannorris 14y agomulti-threading is a must for every iOS app. If you are building a fully single threaded iOS you are going to have a bad time.
- pdenya 14y agonot sure if you're an obj-c dev but for me the surprise was that it even needed to be mentioned since it's extremely easy and common place to do processing outside of the main thread in current apps.
- duaneb 14y agoBlocking the UI with requests is a UI no-no.
- riledhel 14y ago"We truly believe mobile is the best platform for Facebook" that's a strong statement.
- mrwilliamchang 14y agoI'm impressed with how quickly FB, able to transition from emphasizing their web experience, to emphasizing their mobile experience. Most established web companies are moving much slower on this (ie Microsoft, Google, Yahoo!, Amazon, eBay, Flickr, Yelp, Craigslist, Tumblr, etc...).
- rieter 14y agoSeriously? FB is one of the worst slow moving companies in mobile. Google mobile apps were always better.
- cicloid 14y agoUntil the last iterations, true. Still waiting for the Sparrow rebranded Gmail app for iOS
- abraham 14y agoDon't hold your breath. > While we’ll be working on new things at Google, we will continue to make Sparrow available and provide support for our users. http://sprw.me/ http://sprw.me/
- cicloid 14y agoGlad to hear that. Maybe I was to brief on my reply, but... What I mean, was more of the know-how generated on Sparrow making its way in to Gmail app.
- rieter 14y agoMeanwhile FB Android app is still unusably slow and bug-ridden. It's just not acceptable for someone who wants be perceived as a strong technology company.
- macrael 14y agoI believe that the Google apps on Android are good, but my experience with Google apps on iOS have been mostly bad. Have there been good ones?
- Baba_Chaghaloo 14y agoWho voted this advertisement up, I wonder? Fuck you Facebook. I'm never signing back up, your site is harmful to people, everyone who works there can go to hell.
- geuis 14y agoI'm going to share this link with you, since it appears you haven't read it before. http://ycombinator.com/newsguidelines.html http://ycombinator.com/newsguidelines.html It's also that link in the footer called "Guidelines". Read them.
- Baba_Chaghaloo 14y agoI'm fully willing to say that to their face though. If I made a dumb website that accidentally caused even one divorce I'd shutter it, Facebook must cause hundreds every year. It created, intentionally or not, a culture of bragging and narcissism. They're stockpiling facial recognition data. It's a terrible company. If you work there, Fuck You. You're a bad person. I don't know how else to say it.
- mh- 14y ago>I don't know how else to say it. Consider not.
- biznickman 14y agoCan anybody explain why they would use background threads? Seems like over-engineering. Don't iOS blocks natively perform tasks asynchronously?
- xuki 14y agoNo unless you specify so. Block can be ran on both background and main thread.
- sandyarmstrong 14y agoRunning a block async on the main thread can still hurt UI performance. Having worked on an app that deals with a lot of image downloading and processing, we needed to use a different runloop for downloading, and background operations to do image resizing and caching. Between blocks and NSOperationQueue this all feels pretty natural in iOS development. You're not explicitly managing thread creation, etc.
- masklinn 14y ago> Don't iOS blocks natively perform tasks asynchronously? The blocks themselves don't, no, they're just anonymous functions. I'd hope NSOperationQueue[0] and maybe GCD composes most of what they mean by "use background threads". And as sandyarmstrong notes, using things like operation queues will still impact your performances more than separate threads, as the main thread's runloop will still have to go through them, stuff like that. [0] Which can take a block if an NSOperation is too much overhead for the work, see addOperationWithBlock:
- jonathannorris 14y agopretty much every iOS app uses multi-threading (if they don't they should). GDC makes it pretty easy to implement, its defiantly not over-engineering. I highly recommend any new iOS programer to learn GDC when building their first app.
- hobonumber1 14y agoI assume you mean GCD - Grand Central Dispatch?
- state 14y agoI know we're all interested in the content, but that is a seriously bad reading experience. Just because the content is technical doesn't mean the font size has to be tiny and the line height squashed. It's way too dense.
- pieter 14y agoHmm, too bad you need a Facebook account to read this. Anyone have a version cached somewhere?
- ciferkey 14y agoHmm thats odd. I don't have an account and I have no trouble reading it.
- masklinn 14y ago> Hmm, too bad you need a Facebook account to read this. That doesn't seem to be the case, I have no facebook account and I got in just fine.
- mh- 14y agohttps://www.facebook.com/notes/facebook-engineering/under-the-hood-rebuilding-facebook-for-ios/10151036091753920 https://www.facebook.com/notes/facebook-engineering/under-th...
- pieter 14y agoThat link also requires me to log in
- xentronium 14y agohttp://pastebin.com/Ld7FbEp8 http://pastebin.com/Ld7FbEp8