SlideShare a Scribd company logo
Joan Puig Sanz
 Apps for all the platforms 
 Possible solutions 
 Why C++? 
 C++11 
 Libraries 
 Tips and tricks 
 Conclusion 
1
Because making good apps is easy… 
…or not 
2
 Android 
 iOS 
 MacOS 
 WP 
 Windows 8 
 BB10 
 Ubuntu Touch 
 … 
3
 Phonegap 
 Titanium 
 Adobe Air 
 Xamarin 
 … 
4
 Not native UI 
 Slow performance 
 For complex apps you need 
to make custom 
components. 
 You depend on a company 
 Poor user experience 
5
UX 
Smooth UI 
6
7
 Cross platform language. 
 Better Performance. 
 Very mature language. 
 Lots of libraries. 
 Easy communication with native language: 
 Objective-C 
 Java 
 C# 
8
UI/UX • Full native UI and UX 
• Bindings to communicate with C++ 
• e.g. Objective-C++ and JNI 
C++ 
bindings 
C++ Core • Common functionalities 
9
10
 The compiler deduce the actual type of a variable that 
is being declared from its initializer. 
auto i = 42; // i is an int 
auto l = 42LL; // l is an long long 
auto p = new Foo(); // p is a foo* 
std::map<std::string, std::vector<int>> map; 
for(auto it = begin(map); it != end(map); ++it) 
{ 
} 
11
 Support the "foreach" paradigm of iterating over 
collections. 
std::map<std::string, std::vector<int>> map; 
std::vector<int> v; 
v.push_back(1); 
v.push_back(2); 
v.push_back(3); 
map["one"] = v; 
for(const auto& kvp : map) 
{ 
std::cout << kvp.first << std::endl; 
for(auto v : kvp.second) 
std::cout << v << std::endl; 
} 
12
 Before: 
 Implicitly converted to integral types 
 Export their enumerators in the surrounding scope, 
which can lead to name collisions 
 No user-specified underlying type 
enum class Options {None, One, All}; 
Options o = Options::All; 
13
 unique_ptr: Ownership of a memory resource it is not 
shared, but it can be transferred to another unique_ptr 
 shared_ptr: Ownership of a memory resource should be 
shared 
 weak_ptr: Holds a reference to an object managed by a 
shared_ptr, but does not contribute to the reference count; 
it is used to break dependency cycles. 
14
 Powerful feature borrowed from functional 
programming. 
 You can use lambdas wherever a function object or a 
functor or a std::function is expected 
std::function<int(int)> lfib = [&lfib](int n) { 
return n < 2 ? 1 : lfib(n-1) + lfib(n-2); 
}; 
15
 static_assert performs an assertion check at compile-time 
template <typename T1, typename T2> 
auto add(T1 t1, T2 t2) -> decltype(t1 + t2) 
{ 
return t1 + t2; 
} 
std::cout << add(1, 3.14) << std::endl; 
std::cout << add("one", 2) << std::endl; 
template <typename T1, typename T2> 
auto add(T1 t1, T2 t2) -> decltype(t1 + t2) 
{ 
static_assert(std::is_integral<T1>::value, "Type T1 must be integral"); 
static_assert(std::is_integral<T2>::value, "Type T2 must be integral"); 
return t1 + t2; 
} 
16
 Final and overview 
 non-member begin() and end() 
 Initializer lists 
 Object construction improvement 
 Unrestricted unions 
 User-defined literals 
 … 
17
Not reinventing the wheel 
18
 C++ 11 is missing utilities 
 A standard way to make requests 
 Dealing with XML or JSON 
 Big numbers 
 Security 
 Math 
 … 
 Solution: Use it with other libraries 
19
 Boost 
 Juce 
 Qt 
 … 
20
 Supports: 
 License: 
 "AS IS” 
 Big community 
 Lots of modules 
21
 Supports: 
 No WP (for now) 
 License: 
 Core: "AS IS” 
 Other modules: GPL and commercial license 
 Very well written code 
 Easy to use 
22
 Supports: 
 License: 
 GPL v3, LGPL v2 and a commercial license 
 Big community 
 Lots of modules 
23
To make easier our life 
24
 Declare the native method on java 
private native void doSomethingNative(String str); 
 Implement the C method 
JNIEXPORT void Java_com_example_MyClass_doSomethingNative (JNIEnv *env, jobject obj, 
jstring s) 
{ 
const char* const utf8 = env->GetStringUTFChars (s, nullptr); 
CharPointer_UTF8 utf8CP (utf8); 
String cppString (utf8CP); 
env->ReleaseStringUTFChars (s, utf8); 
doSomethingWithCppString (cppString); 
} 
 Do not forget to release the java objects! 
 env->Release: The maxim number of java references is 512 
 Some libraries offers you utilities to parse common java 
objects to Cpp objects 
25
 Declare the native method on java 
JNIEnv* env = getEnv(); 
jclass myJavaClass = env->GetObjectClass (myJavaObject); 
jmethodID myJavaMethod = env->GetMethodID(myJavaClass , ”methodName", "([I;Z)Ljava/lang/String"); 
jstring jresult = (jstring) env->CallObjectMethod (myJavaObject, myJavaMethod , myIntArray, myBoolean); 
// Do something 
env->DeleteLocalRef (jresult); 
env->DeleteLocalRef (myJavaClass); 
 Do not forget to delete the local java references 
 env->DeleteLocalRef: The maxim number of java 
references is 512 
26
 Java 
public class Foo { 
private static native void destroyCppInstanceNative(long ref); 
private native long newCppInstanceNative(); 
private native String getStringNative(long ref); 
private long _ref = 0; 
public Foo() { 
_ref = newCppInstanceNative(); 
} 
public String getString() { 
return getStringNative(_ref); 
} 
public void destroy() { 
destroyCppInstanceNative(_ref); 
} 
} 
27
 C 
JNIEXPORT long Java_com_example_Foo_newCppInstanceNative(JNIEnv *env, jobject obj) { 
Foo* newFoo = new Foo(); 
int64 ref = reinterpret_cast<int64>(newFoo); 
return ref; 
} 
JNIEXPORT jstring Java_com_example_Foo_getStringNative(JNIEnv *env, jobject obj, long ref) { 
Foo* foo = reinterpret_cast<Foo*>(ref); 
jstring jStringResult = env->NewStringUTF(foo->getString().toUTF8()); 
return jStringResult; 
} 
JNIEXPORT void Java_com_example_Foo_destroyCppInstanceNative(JNIEnv *env, jobject obj, int64 ref) { 
Foo* foo = reinterpret_cast<Foo*>(ref); 
delete foo; 
} 
28
 On Objective-C++ is very easy to use C++ 
 The extension of the Objective-C++ file is .mm 
 Try to do not add imports of C++ code on the Objective-C headers 
 If you add a C++ import in your Objective-C header you will force 
other classes to be Objective-C++ (.mm) instead of Objective-C 
(.m) 
@implementation JSPFoo 
Foo fooObject; 
-(id) init { 
self = [super init]; 
if (self) { 
} 
return self; 
} 
- (NSString*) stringFromCpp 
{ 
NSString* result = [NSString stringWithUTF8String:fooObject.getString().toRawUTF8()]; 
return result; 
} 
@end 29
 Establish some code conventions with your coworkers 
 Review each others code 
 If you do not find the C++ code that you need just create 
some interfaces and implement them in the native 
platform (java, Objective-c, C# … ) 
 Code as if you where creating a library, if you have more 
apps to develop this code will help you 
 C++ is not a read-only code, so do not put the blame on it 
30
 Remember to initialize all the values in the constructor, 
even numbers… 
 To speed up the compilation time use unity builds 
 Check out djinni: tool for generating cross-language type 
declarations and interface bindings. 
dropbox/djinni 
31
What do we get at the end? 
32
 Pros 
 Different apps sharing the same core and with native 
UI/UX 
 Better performance 
 Faster development 
 Easier maintenance 
 Cons 
 Need to learn a new language 
 Android apps will be bigger (code compiled for different 
architectures) 
 Can be fixed distributing specific apk per each architecture 
33
@joanpuigsanz

More Related Content

What's hot

Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)Luigi De Russis
 
Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)Luigi De Russis
 
Async await in C++
Async await in C++Async await in C++
Async await in C++cppfrug
 
AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8Phil Eaton
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about goDvir Volk
 
Introduction to D programming language at Weka.IO
Introduction to D programming language at Weka.IOIntroduction to D programming language at Weka.IO
Introduction to D programming language at Weka.IOLiran Zvibel
 
The Present and The Future of Functional Programming in C++
The Present and The Future of Functional Programming in C++The Present and The Future of Functional Programming in C++
The Present and The Future of Functional Programming in C++Alexander Granin
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)Ishin Vin
 
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...Yandex
 
С++ without new and delete
С++ without new and deleteС++ without new and delete
С++ without new and deletePlatonov Sergey
 
C++ vs python the best ever comparison
C++ vs python the best ever comparison C++ vs python the best ever comparison
C++ vs python the best ever comparison calltutors
 
Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Daker Fernandes
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17LogeekNightUkraine
 
DLL Design with Building Blocks
DLL Design with Building BlocksDLL Design with Building Blocks
DLL Design with Building BlocksMax Kleiner
 
C Under Linux
C Under LinuxC Under Linux
C Under Linuxmohan43u
 
C++17 introduction - Meetup @EtixLabs
C++17 introduction - Meetup @EtixLabsC++17 introduction - Meetup @EtixLabs
C++17 introduction - Meetup @EtixLabsStephane Gleizes
 
Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016maiktoepfer
 

What's hot (20)

Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)
 
Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)
 
Async await in C++
Async await in C++Async await in C++
Async await in C++
 
Summary of C++17 features
Summary of C++17 featuresSummary of C++17 features
Summary of C++17 features
 
AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
 
Introduction to D programming language at Weka.IO
Introduction to D programming language at Weka.IOIntroduction to D programming language at Weka.IO
Introduction to D programming language at Weka.IO
 
The Present and The Future of Functional Programming in C++
The Present and The Future of Functional Programming in C++The Present and The Future of Functional Programming in C++
The Present and The Future of Functional Programming in C++
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
 
History of c++
History of c++ History of c++
History of c++
 
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
 
С++ without new and delete
С++ without new and deleteС++ without new and delete
С++ without new and delete
 
C++ vs python the best ever comparison
C++ vs python the best ever comparison C++ vs python the best ever comparison
C++ vs python the best ever comparison
 
Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
 
DLL Design with Building Blocks
DLL Design with Building BlocksDLL Design with Building Blocks
DLL Design with Building Blocks
 
C Under Linux
C Under LinuxC Under Linux
C Under Linux
 
GCC, GNU compiler collection
GCC, GNU compiler collectionGCC, GNU compiler collection
GCC, GNU compiler collection
 
C++17 introduction - Meetup @EtixLabs
C++17 introduction - Meetup @EtixLabsC++17 introduction - Meetup @EtixLabs
C++17 introduction - Meetup @EtixLabs
 
Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016
 

Similar to Cross Platform App Development with C++

Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Xavier Hallade
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)DroidConTLV
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Paris Android User Group
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...Sang Don Kim
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DMithun Hunsur
 
14.jun.2012
14.jun.201214.jun.2012
14.jun.2012Tech_MX
 
L Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsL Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsJan Aerts
 
JNA - Let's C what it's worth
JNA - Let's C what it's worthJNA - Let's C what it's worth
JNA - Let's C what it's worthIdan Sheinberg
 
NDK Primer (AnDevCon Boston 2014)
NDK Primer (AnDevCon Boston 2014)NDK Primer (AnDevCon Boston 2014)
NDK Primer (AnDevCon Boston 2014)Ron Munitz
 
NDK Primer (Wearable DevCon 2014)
NDK Primer (Wearable DevCon 2014)NDK Primer (Wearable DevCon 2014)
NDK Primer (Wearable DevCon 2014)Ron Munitz
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application DevelopmentRamesh Prasad
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software DevelopmentZeeshan MIrza
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?Andrey Karpov
 
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)PROIDEA
 
Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Kenneth Geisshirt
 

Similar to Cross Platform App Development with C++ (20)

Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Android ndk
Android ndkAndroid ndk
Android ndk
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in D
 
14.jun.2012
14.jun.201214.jun.2012
14.jun.2012
 
L Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsL Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformatics
 
JNA - Let's C what it's worth
JNA - Let's C what it's worthJNA - Let's C what it's worth
JNA - Let's C what it's worth
 
NDK Primer (AnDevCon Boston 2014)
NDK Primer (AnDevCon Boston 2014)NDK Primer (AnDevCon Boston 2014)
NDK Primer (AnDevCon Boston 2014)
 
NDK Primer (Wearable DevCon 2014)
NDK Primer (Wearable DevCon 2014)NDK Primer (Wearable DevCon 2014)
NDK Primer (Wearable DevCon 2014)
 
Csharp dot net
Csharp dot netCsharp dot net
Csharp dot net
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application Development
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software Development
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?
 
1- java
1- java1- java
1- java
 
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
 
Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++
 

Recently uploaded

iGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockiGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockSkilrock Technologies
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessWSO2
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfmbmh111980
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion Clinic
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAlluxio, Inc.
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Krakówbim.edu.pl
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...rajkumar669520
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfMeon Technology
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?XfilesPro
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandIES VE
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareinfo611746
 

Recently uploaded (20)

iGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockiGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by Skilrock
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 

Cross Platform App Development with C++

  • 2.  Apps for all the platforms  Possible solutions  Why C++?  C++11  Libraries  Tips and tricks  Conclusion 1
  • 3. Because making good apps is easy… …or not 2
  • 4.  Android  iOS  MacOS  WP  Windows 8  BB10  Ubuntu Touch  … 3
  • 5.  Phonegap  Titanium  Adobe Air  Xamarin  … 4
  • 6.  Not native UI  Slow performance  For complex apps you need to make custom components.  You depend on a company  Poor user experience 5
  • 8. 7
  • 9.  Cross platform language.  Better Performance.  Very mature language.  Lots of libraries.  Easy communication with native language:  Objective-C  Java  C# 8
  • 10. UI/UX • Full native UI and UX • Bindings to communicate with C++ • e.g. Objective-C++ and JNI C++ bindings C++ Core • Common functionalities 9
  • 11. 10
  • 12.  The compiler deduce the actual type of a variable that is being declared from its initializer. auto i = 42; // i is an int auto l = 42LL; // l is an long long auto p = new Foo(); // p is a foo* std::map<std::string, std::vector<int>> map; for(auto it = begin(map); it != end(map); ++it) { } 11
  • 13.  Support the "foreach" paradigm of iterating over collections. std::map<std::string, std::vector<int>> map; std::vector<int> v; v.push_back(1); v.push_back(2); v.push_back(3); map["one"] = v; for(const auto& kvp : map) { std::cout << kvp.first << std::endl; for(auto v : kvp.second) std::cout << v << std::endl; } 12
  • 14.  Before:  Implicitly converted to integral types  Export their enumerators in the surrounding scope, which can lead to name collisions  No user-specified underlying type enum class Options {None, One, All}; Options o = Options::All; 13
  • 15.  unique_ptr: Ownership of a memory resource it is not shared, but it can be transferred to another unique_ptr  shared_ptr: Ownership of a memory resource should be shared  weak_ptr: Holds a reference to an object managed by a shared_ptr, but does not contribute to the reference count; it is used to break dependency cycles. 14
  • 16.  Powerful feature borrowed from functional programming.  You can use lambdas wherever a function object or a functor or a std::function is expected std::function<int(int)> lfib = [&lfib](int n) { return n < 2 ? 1 : lfib(n-1) + lfib(n-2); }; 15
  • 17.  static_assert performs an assertion check at compile-time template <typename T1, typename T2> auto add(T1 t1, T2 t2) -> decltype(t1 + t2) { return t1 + t2; } std::cout << add(1, 3.14) << std::endl; std::cout << add("one", 2) << std::endl; template <typename T1, typename T2> auto add(T1 t1, T2 t2) -> decltype(t1 + t2) { static_assert(std::is_integral<T1>::value, "Type T1 must be integral"); static_assert(std::is_integral<T2>::value, "Type T2 must be integral"); return t1 + t2; } 16
  • 18.  Final and overview  non-member begin() and end()  Initializer lists  Object construction improvement  Unrestricted unions  User-defined literals  … 17
  • 20.  C++ 11 is missing utilities  A standard way to make requests  Dealing with XML or JSON  Big numbers  Security  Math  …  Solution: Use it with other libraries 19
  • 21.  Boost  Juce  Qt  … 20
  • 22.  Supports:  License:  "AS IS”  Big community  Lots of modules 21
  • 23.  Supports:  No WP (for now)  License:  Core: "AS IS”  Other modules: GPL and commercial license  Very well written code  Easy to use 22
  • 24.  Supports:  License:  GPL v3, LGPL v2 and a commercial license  Big community  Lots of modules 23
  • 25. To make easier our life 24
  • 26.  Declare the native method on java private native void doSomethingNative(String str);  Implement the C method JNIEXPORT void Java_com_example_MyClass_doSomethingNative (JNIEnv *env, jobject obj, jstring s) { const char* const utf8 = env->GetStringUTFChars (s, nullptr); CharPointer_UTF8 utf8CP (utf8); String cppString (utf8CP); env->ReleaseStringUTFChars (s, utf8); doSomethingWithCppString (cppString); }  Do not forget to release the java objects!  env->Release: The maxim number of java references is 512  Some libraries offers you utilities to parse common java objects to Cpp objects 25
  • 27.  Declare the native method on java JNIEnv* env = getEnv(); jclass myJavaClass = env->GetObjectClass (myJavaObject); jmethodID myJavaMethod = env->GetMethodID(myJavaClass , ”methodName", "([I;Z)Ljava/lang/String"); jstring jresult = (jstring) env->CallObjectMethod (myJavaObject, myJavaMethod , myIntArray, myBoolean); // Do something env->DeleteLocalRef (jresult); env->DeleteLocalRef (myJavaClass);  Do not forget to delete the local java references  env->DeleteLocalRef: The maxim number of java references is 512 26
  • 28.  Java public class Foo { private static native void destroyCppInstanceNative(long ref); private native long newCppInstanceNative(); private native String getStringNative(long ref); private long _ref = 0; public Foo() { _ref = newCppInstanceNative(); } public String getString() { return getStringNative(_ref); } public void destroy() { destroyCppInstanceNative(_ref); } } 27
  • 29.  C JNIEXPORT long Java_com_example_Foo_newCppInstanceNative(JNIEnv *env, jobject obj) { Foo* newFoo = new Foo(); int64 ref = reinterpret_cast<int64>(newFoo); return ref; } JNIEXPORT jstring Java_com_example_Foo_getStringNative(JNIEnv *env, jobject obj, long ref) { Foo* foo = reinterpret_cast<Foo*>(ref); jstring jStringResult = env->NewStringUTF(foo->getString().toUTF8()); return jStringResult; } JNIEXPORT void Java_com_example_Foo_destroyCppInstanceNative(JNIEnv *env, jobject obj, int64 ref) { Foo* foo = reinterpret_cast<Foo*>(ref); delete foo; } 28
  • 30.  On Objective-C++ is very easy to use C++  The extension of the Objective-C++ file is .mm  Try to do not add imports of C++ code on the Objective-C headers  If you add a C++ import in your Objective-C header you will force other classes to be Objective-C++ (.mm) instead of Objective-C (.m) @implementation JSPFoo Foo fooObject; -(id) init { self = [super init]; if (self) { } return self; } - (NSString*) stringFromCpp { NSString* result = [NSString stringWithUTF8String:fooObject.getString().toRawUTF8()]; return result; } @end 29
  • 31.  Establish some code conventions with your coworkers  Review each others code  If you do not find the C++ code that you need just create some interfaces and implement them in the native platform (java, Objective-c, C# … )  Code as if you where creating a library, if you have more apps to develop this code will help you  C++ is not a read-only code, so do not put the blame on it 30
  • 32.  Remember to initialize all the values in the constructor, even numbers…  To speed up the compilation time use unity builds  Check out djinni: tool for generating cross-language type declarations and interface bindings. dropbox/djinni 31
  • 33. What do we get at the end? 32
  • 34.  Pros  Different apps sharing the same core and with native UI/UX  Better performance  Faster development  Easier maintenance  Cons  Need to learn a new language  Android apps will be bigger (code compiled for different architectures)  Can be fixed distributing specific apk per each architecture 33