SlideShare una empresa de Scribd logo
1 de 35
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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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 a 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 a 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++
 

Último

Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 

Último (20)

Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 

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