Djinni ( https://github.com/dropbox/djinni ) jest młodym projektem zapoczątkowanym w Dropbox. Djinni umożliwia współdzielenie warstwy biznesowej/domenowej (napisanej w C++) przez aplikacje zaimplementowane w Javie i Objective-C/Swift redukując tym samym redundancję kodu. W trakcie prelekcji zaprezentuję w jaki sposób utworzyć prostą aplikację na Android/iOS opartą o Javę, Swift, C++ oraz Djinni, zwracając uwagę na wszelkie problemy na jakie natrafiłem w ciągu swojej półrocznej pracy z tym stosem technologicznym.
3. Me
• over 10 years in IT
• over 4 years as C++ software engineer
• some Java experience
• no Objective-C experience
• last half of year of free time (boring guy) spent on
Android/iOS mobile app development, Swift learning, etc.
• want to share idea of broad usage of C++ in mobile app
development world
4. Multiplatform app
• multiplatform app is…
mobile / web / “traditional”,
Android / iOS / MacOS / Linux / Windows, etc.
• native look & feel
• performance
5. Potential issues
• Each of app platform version in native language
(Java, Objective-C, C# etc.)
• Duplicated code
• More code - harder maintenance
• Slow development
7. C++11 (modern C++)
“C++ feels like a new language. That is, I can
express my ideas more clearly, more simply, and
more directly in C++11 than I could in C++98.
Furthermore, the resulting programs are better
checked by the compiler and run faster.”
Bjarne Stroustrup,
The C++ programming language
8. C++11 (modern C++)
• auto
• foreach
• lambdas
• smart pointers
• move semantics
• constexpr
• many libraries
• a lot more…
9. Cross-language bridge
• Java Native Interface (JNI): C++ <-> Java
• Objective-C++: C++ <-> Objective-C
• Consistent interface across languages
• Data types that are the same in all languages
• Object’s lifetime
• Error handling
11. Djinni
• Dropbox’s Carousel and Mailbox
• Bridge between C++ and Java/Objective-C
• Bridge between C++ and Python (experimental)
• Open source
• Facebook’s Moments
17. C++11: smart pointers
auto d = new Dynamic;
try {
do_sth(d); // may throw
}
catch (...) {
delete d;
throw; // rethrow
}
delete d;
vintage C++
18. C++11: smart pointers
auto d = new Dynamic;
try {
do_sth(d); // may throw
}
catch (...) {
delete d;
throw; // rethrow
}
delete d;
auto d = std::make_shared<Dynamic>();
do_sth(d); // may throw
modern C++
vintage C++
21. Pros
• Less code
• Easier maintenance
• More consistency between app platform versions
• Faster development
• Better performance
• Easy switch from single- to multi-platform
22. Cons
• Reasonable use of bridges
• Djinni’s limitations (lack of interface inheritance)
• Compilers issues (AndroidNDK vs CrystaxNDK)
• Size of Android app increases (architectures)
• No single IDE