Facebook Has a New Private Mobile Photo-Sharing App, and They Built It In C++
jfruh writes: Facebook [on Monday] announced Moments, a new mobile app that uses Facebook's facial recognition technology to let you sync up photos only with friends who are in those photos with you. Somewhat unusually for a new app, the bulk of it is built in the venerable C++ language, which turned out to be easier for building a cross-platform mobile app than other more "modern" languages.
>>>Facebook announced Moments, a new mobile app that uses Facebook's facial recognition technology to let you sync up photos only with friends who are in those photos with you, advertisers who are unlikely in these photos, law enforcement agents who are probably not in these photos, APT hackers that are no in these photos, and that dude who specializes in recovering data from used electronics that always presents at the conference.
Fixed that for you.
one in the toolshed."
So, what, it's written in Lisp with some Fortran libraries?
With modern certification mills cranking out millions of Java and .Net and Framework and Node.js and Shiny chimps, they've essentially guaranteed that it's unauditable by anyone not on a short list. +1 to you, Facebook.
Only to people who don't know what the fuck they're talking about ;-)
C++ is all over the place. Yes, it's a complex language. But it gives a hell of a lot more control over all the tradeoffs in software implementation than all the other "popular" languages, with pretty high-level abstractions at the same time.
a station wagon full of #ifdefs hurtling down the information superhighway.
"Fuck That."
... Oddly enough. At least, that's what the Play Store says. Maybe some other restriction in place.
If C++ is "the best tool" for cross-platform mobile app development, then the state of mobile app development is in a sorry state indeed.
Seriously if C++ is the best we can do for *anything*, then we need to just throw in the towel and go back to pencil and paper right now.
Taking such a strident and dogmatically absolutist stance on the usefulness of any language indicates a lack of experience in the field and a narrowness of understanding of the field. It sounds like someone told you it was really, really bad, and, knowing nothing else, you simply repeat what they said.
C++ is, syntactically, not my favorite language. It's not even my second favorite language. But for its breadth of application, the ubiquity of compilers on any platform, and the sheer volume of useable libraries, it is up there on my list.
Shouldn't it be written in assembly then, or maybe on punch cards? :)
Just cruising through this digital world at 33 1/3 rpm...
Somewhat unusually for a new app, the bulk of it is built in the venerable C++ language, because the main guys on the team were big C++ fans who found a way to justify their preference.
Not saying it was the wrong choice, particularly for the team in question, but I'm betting if you hand the project to another team you come up with a different language.
Also interesting is it sounds like they're using an automatic code generator to translate some of the stuff from C++ to Java to run on android, maybe it will work seamlessly but that extra layer always makes me nervous.
I stole this Sig
We could call it 'getting facefucked' and the cameras could now squirt semen in people's face to complete the experience.
My ism, it's full of beliefs.
C++ is so flexible that you can write all your nasty "legwork" code (performance-sensitive stuff, like the actual facial recognition, image data manipulation, etc.) *once* and call it from whatever UI layer you write.
Granted, it's probably somewhere between hard and impossible to write a mobile platform-agnostic UI layer that actually looks good on both Android and iOS, since iOS and Android are so different in that regard; but even if they didn't bother doing that and just wrote two entirely separate view layers, they still can separate out all the heavy lifting and "write once, compile in two places". Both Android and iOS have decent to good C++ support, so if you make it platform-independent, you can have an optimized core library that works on the two major mobile platforms with no modifications.
Not sure I would go with C++ for something that was less performance-sensitive, but in this case, they can probably peg the CPU of a modern smartphone for at least a good fraction of a second with some of their heavier code.
Unless of course they are simply taking the image and uploading it to "the cloud" to do the facial recognition, in which case it's kind of a head-scratcher, since you don't need C++ to make HTTP requests.
On what planet is C++ an unusual choice?
I'm completely ignoring the "Facebook" part of this announcement. What's news to me is that (most of) an app on any mobile platform can actually be written in C++ instead of Java or Swift. I quite seriously had no idea this could be done. The few times I've dabbled in Android development, for example, absolutely everything centered around Java. I've never played with iOS development because I don't have a suitable device, but I assumed you had to go with Objective C or Swift.
Where do I get started building Android apps in C++? Inquiring minds suddenly want to know.
He kind of has a point though. While C++ happens to be useful for cross platform mobile development, that's not because of C++ itself is better at cross platform development. It's because the higher level languages for mobile development are tied to each platform and generally can't be run on the others. But all of the platforms support C++ for computationally intense code. An ideal solution solution would be to have a cross platform higher level language, and to just use C++ for it's intended use on these platforms which is primarily just computation or providing access to an existing library, not driving the actual logic of the overall app.
They don't claim best tool, you did. They made something based on the skillset they possess and the requirements in front of them. The fact that C++, a powerful, flexible language, has the tools available isn't a bad thing. I'm not sure why you would think it was
An ideal solution solution would be to have a cross platform higher level language, and to just use C++ for it's intended use on these platforms which is primarily just computation or providing access to an existing library, not driving the actual logic of the overall app.
In software development, you never get to use the "ideal solution" because it invariably, as exemplified by this case, doesn't exist. The "best tool for the job" is always a local optimum.
Anything that has to be shipped outside your own organisation really has to be written in C++.
Look at the alternatives for commercial development of retail applications:
- Java - no good gui toolkits, resource hungry and bad latency. It is _possible_ to use, but never seems to be as performant as a native choice. Requires JVM. Contaminated and effectively dead as a platform as a result of Oracle's extremely, extremely, extremely extreme view on API copyrights, so not an option in my company any more sadly. Oracle really scared our lawyers, however crazy us technical people consider Oracle management to be, and however unlikely they are to prevail. SWT was the best toolkit I used for java GUIs. Definitely shippable.
- C#/.NET - no portable choices for GUI toolkits. Shipping a binary mono that works everywhere is tricky on Linux due to dependencies on GTK. No acceptable portable UI toolkit. Winforms kind of works, but it actually rather clunky and nasty. My impression is that it performs better than java, I guess because we ahead of time compiled everything we built with it mostly.
- C++ - Qt, GTK, wxWidgets all work as commercially supportable toolkits. I have shipped Qt apps. The best GUI toolkit I have used on any platform, when used properly. Dependencies in C++ are simple and easy to manage. C++14 also offers a never nice improvement over C++98 - almost like a whole new language. The traditional reasons for avoiding C++ are gone. Sure, it may be a mental burden to less competent developers to learn properly, but do you want to employ incompetents anyway?
Of course, developing internal software, that doesn't need to be packaged and shipped on all customer's Linux and Windows is a completely different world.
In this world, I would probably go with a mixture of C++ and C#, depending on project requirements.
If you didn't restrict the toolshed to high-level languages, it would have been written by flipping switches and rearranging patch cables.
Where do I get started building Android apps in C++? Inquiring minds suddenly want to know.
The latest versions of Qt5 support building Qt/C++ apps for Android and iOS. I've never tried it for more than running a few examples, but it seems pretty nice and easy, and I've really enjoyed Qt development for years now.
These guys clearly have no sense of fashion. On the other hand this could have been done with any turing-complete language.
Only Luddite software uses C++. Modern app appers use App languages, like AppScript and App App!
Apps!
C++ is "Venerable"? Based on its first standard version, it is 17 years old. Seriously, we set the bar of language decrepitude at only 17 years?
I might might let it slide if you used that adjective for C or something even older. But C++ has only just now gone through enough revisions to start getting halfway decent. You wanna just chuck it in the retirement home right when they are starting to get some of the kinks worked out? One or two more revisions and they were going to get it up to the capabilities of Ada. :-)
Brutal.
Ok... I get that. I even basically said that in my comment. The whole point of it was to point out that this cross platform mobile development doesn't have the ideal solution right now (and unless Apple and Google can start getting along, it probably won't ever).
Please note the following quotes from the article:
With C++, “a lot of our more complicated logic can be written once and run on both iOS and Android,”
Due to the complexity and the performance required, HTML / Cordova were not viable options ( see http://magenic.com/Blog/Post/4... Test 4: Prime Number Calculation, where cordova takes 12 - 23 times longer to run than native / xamarin). This performance is not an issue for most applications, but for something like face detection you bet this has an impact.
In regards to Xamarin, it could have been a viable solution. The main issue here though is that doing work on images is a lot harder to do performant without pointers in c# (ignoring unsafe code), and in a portable class library so it can be shared (limited support for images).
The best performance wise (ignoring memory, Xamarin seems to manage memory better in most instances) would be to go native. But doing this means that you would have to write the complex calculations twice, once in swift/objc and java.
So this leaves doing it in c++. This is indeed possible, but you would only do this when you have very complex and performance dependant code that you do not want to write twice (for example, image manipulation). If you pick c++ for any other reason, you are most likely picking the wrong technology as it is more difficult to write mobile applications in c++ than the other languages (yes, the other languages have abstractions, that is because most applications have no need to care about low level operations).
So Facebook, look at their business problem and solves it using the best tool available. This does not mean that c++ is the correct technology for all cases.
Cosmonaut?
The smart ones only know java , the rest think HTML +CSS are programming languages and javascript is the domain of almost omnipotent god like beings whose radiance they can only begin to emulate.
Facebook has some actually competent coders that do not need to be coddled and do not start to cry if the language they use requires some actual understanding?
Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
"Somewhat unusually for a new app, the bulk of it is built in the venerable C++ language, which turned out to be easier for building a cross-platform mobile app than other more "modern" languages."
I'm the co-owner of a software company with $15 million USD in annual revenues from software sales and software consulting. At least 90% of revenue is directly based on products and services that use C++. I'm sitting at my desk writing C++ right now. The code I am working on now will be in the cars that come out this year and in all likelihood for the next 10 years or more.
Nobody at my company or at the auto manufacturers we work with are surprised by that or think that it is unusual in any way. We all agree that C++ is a low risk, highly capable technical solution that meets project requirements and is likely to for years to come. If my customers didn't think that, they wouldn't be using C++.
Seriously, if you want to write something that works in any platform, write it in C, C++ is a second but still valid choice.
When people design a platform, one of the first thing they do make it run code written in C. It is also the language of choice for everything UNIX : Linux, BSD, GNU, etc... It is well standardized too : sure, it is easy to shoot yourself in the foot but if you code properly, it should work on any platform. And as an added bonus, good C code is also valid C++ and ObjC.
As probably many others, I've been looking into this exact problem for a while, comparing a lot of available options. Ultimately, I want something to run on Android, iOS, Windows (+ Phone), Linux, and OS X. The very complex core logic should be a write-once affair, while not having a single shared UI is not such a major issue, nor is writing some platform-specific utility classes. I have also come to the conclusion that C++11 for that core is the most viable option.
Some interesting tidbits not mentioned in the summary is that they used DropBox's djinni to generate C++, ObjC and Java bindings; and they used the Flux unidirectional data flow architecture. Both of these things are worth reading about, more so than any thing that is actually mentioned in the summary.
If you want fast applications, write them in C or one of the C family (C++, Objective C). If you want fast to write code, don't then,
There's yet to be a single language that can compete with that language group for speed, capability and power of the resulting code (providing it's relatively bug-free) It's a higher cost of production for a better quality result.
While occasionally a really well-tuned script language can match it for capability (perl succeeded there) - usually they cannot.
And anyone who calls these "Venerable" has to realize they're being arrogant in a way they can't back up, because they're linguistically implying obsolescence.
While C++ happens to be useful for cross platform mobile development, that's not because of C++ itself is better at cross platform development.
Yes it is. Well-written C++ code will run on any platform, whereas even the best java code only runs on the java platform. This makes C++ much more suitable for cross platform development than java.
Is this sophistry? I don't think so. Java is not a cross-platform system, java *is* a platform. And I think that no matter what the initial intentions may have been, time has shown that languages that compile to any platform, while less convenient than languages that bring their own platform, are actually the more flexible and practical for cross platform development of the two designs.
The lesson here is that a sufficiently large corporation is indistinguishable from government. --ultranova
I make apps, using Qt, for Desktop (Win, Mac & Linux), Android and iOS. Having the same source code (which happens to be c++) across all platforms allows me to master one tool kit and spend time make more apps instead of learning a new language every time Apply or Google feels like it.
So what you're saying is we need to create a new language, one that could be "write once, run everywhere" capable...
Browsing at +1 - no ACs, I ignore their posts. So refreshing!
"There are only two kinds of languages: the ones people complain about and the ones nobody uses"
Bjarne Stroustrup
Yes it is. Well-written C++ code will run on any platform, whereas even the best java code only runs on the java platform. This makes C++ much more suitable for cross platform development than java.
I have another way of looking at the same point........C is the most portable language, because if you write a library in C, it can be used from any language. Java, Python, TCL, Perl, Pascal, Fortran, C#, R, Javascript, D, Go, Ocaml, PHP, etc can all call into a C library (and a lot of the interfaces can be built automatically). If you write in Java, you're stuck building on top of it in Java.
"First they came for the slanderers and i said nothing."
I criticise Snowden for not knowing what the American people want in practice. In my book, corporations stealing my private info is worse than the NSA stealing my private info. People willingly use Facebook, whom sells private info to corporations. Therefore, NSA stealing that info is acceptable.
I have seen people online argue the opposite. Namely, that the US govt has lots of military power, and corporations do not. It would be nice if the public could come to an answer on this.
The code I am working on now will be in the cars that come out this year and in all likelihood for the next 10 years or more.
You almost had me, right up until you said that.
If you're writing code NOW, it will most assuredly NOT be in any cars that come out this year. Or next year, probably.
Initially developed in the late 1970s, C++ is a powerful general-purpose programming language, and is still widely used for writing mission critical and performance-sensitive applications.
Hardly. Stroustrup first introduced C with classes at Bell Labs in 1979. It wouldn't be known as C++ until at least 1983.
'The tyrant will always find pretext for his tyranny.' - Aesop's Fables
Now such thing as an ideal solution.
As you point out c/c++ is often the best for the job.
People forget about things like IDEs, compilers, debuggers, and libraries.
See my blog http://ilovecookes.blogspot.com/ for light hearted technical information.
I learned Objective-C so that I could deploy on iOS and otherwise wouldn't have given the language a second look. Then I discovered Cocos-2d which makes C++ on iOS, Android, etc very easy so boom I happily made the leap back to C++ and haven't looked back. There is pretty much zero chance that I will write more than a few dozen lines of Objective-C again in my life. There is also pretty much zero posibility that I will write any swift and I certainly have dodged the Java bullet for Android.
About the only problems that I have encountered are some artificial ones where some API features are cut off from me without a tiny bit of Objective-C or Java. But those tiny bits get wrapped in a C++ class and forgotten.
Seriously if C++ is the best we can do for *anything*, then we need to just throw in the towel and go back to pencil and paper right now.
Sometime, "pencil and paper" *are* the best tool for the job, because they work everywhere.
Same for C++:
It's maybe not Dart (for Google Chrome), nor Rust (for Firefox), nor Swift (latest gen iOS), nor whatever is the latest cool thing (scala ?) to run on a Java machine (for Android), nor Ruby (is that the lastest hipster thingy on servers ?)
But it works everywhere. Thus there *are* legitimate solution were using the older or simpler tool is better than all the modern hyped bells and whistles.
"Sufficiently advanced satire is indistinguishable from reality." - [Tips: 1DrYakQDKCQ6y52z6QbnkxHXAocMZJE61o ]
For me it was the co-owner with the large(ish) revenue. If you are the co-owner you are probably not going to be a code monkey. This is not always true but it is likely more true with increased revenue. I have been the sole proprietor of a very profitable company and, alas, once we reached the level of reasonable prosperity I was too busy to code or even help build hardware. To be honest, I much preferred having my hands in the pot over managing. It was far more effective and efficient to have dedicated staff due to distractions, important business, and lapsed skills. There could be, and likely are, exceptions but this one seems a bit sketchy though their revenue is not all that high but high enough to the point where they should likely be doing more productive things.
"So long and thanks for all the fish."
I just got through doing an app this way. It's a sensible way to do certain types of apps. Definitely not everything, but in this case it was talking to a BLE device, and it was easier to code the "core" (the part that dealt with packets, etc.) in C++ and leave the UI specifics to the Android and iOS SDKs. The biggest inconvenience is the layer between the C++ and "native" parts, but it's not rocket science.
He didn't say C++ was worthless. He said it would be a pretty bad thing if it was "the best tool" or "the best we can do", and going by the rest of your comment I'm not sure if you'd completely disagree.
Take away its heritage advantages (libraries and compilers-- "it's popular for being popular"), and you are left with what exactly?
Let's see, you have almost-foolproof C compatibility... except most other languages can link to C code. Annnnnd... hmm. I can't really think of anything else. High performance OO maybe, but other languages can do that in more powerful ways (including Objective C).
Why is that modded funny? It's not a half-bad idea!
(Of course, these days when you want half-Lisp, half-Fortran, you use a different syntax and call it Matlab (or GNU Octave). It's better than using C++, at any rate!)
"[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz
I work in C++ every day and have been a professional programmer for nearly 15 years, but I agree with the original sentiment.
Even if we just took C++ and turned it into a proper grammar we could remove half the code in C++ compilers.
Even if we just took C++ and added some simple rules about where source files should live relative to each other, C++ could have real projects not defined by the IDE or make system you're using.
Even if we just took C++ and had a 'no macros' version so that each header file could just be read once, C++ could take a tenth of the time it does to compile.
Even if we just took C++ and gave it a cross platform system library less convoluted than boost, programming C++ could feel almost modern. ... Should I go on?
It's a godawful series of hacks and mistakes which nobody in their right mind could arrive at from scratch. I understand WHY it's still the way it is but to defend it for WHAT it is is futile.
What's news to me is that (most of) an app on any mobile platform can actually be written in C++
What do you think games for Nintendo DS, PlayStation Portable, Nintendo 3DS, and PlayStation Vita are written in?