C++ Cross Platform
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Alternative Title |
| |
Title of Series | ||
Number of Parts | 90 | |
Author | ||
License | CC Attribution 3.0 Unported: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor. | |
Identifiers | 10.5446/47614 (DOI) | |
Publisher | ||
Release Date | ||
Language |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
2
10
13
14
26
35
37
45
48
54
55
56
63
64
68
73
74
77
78
80
82
85
89
00:00
Computing platformMobile appJava appletScripting languagePersonal digital assistantPhysical systemLatent heatVirtual machineMultiplication signMobile appCodePhysical systemMessage passingFamilyResultantInsertion lossBitSocial classBit rateComputer configurationObject (grammar)TelecommunicationAxiom of choiceLatent heatPower (physics)Process (computing)CuboidVideo gameGradientPresentation of a groupTask (computing)NumberCompilation albumCASE <Informatik>Android (robot)Right angleComputing platformGame theoryCryptographySoftware developer1 (number)LogicMathematical optimizationCross-platformJava appletoutputWeb 2.0Operator (mathematics)Flow separationReal numberComputer animation
04:16
Computing platformMobile appCodeWeb browserGraphical user interfaceChainJava appletScripting languageFunction (mathematics)Machine codeFunctional (mathematics)Web browserCodeComputing platformInformation securityTheoryProcess (computing)MathematicsTouch typingRepresentation (politics)Mixed realityComputer animation
05:28
BefehlsprozessorRead-only memoryMobile appComputing platformVirtual machineFormal languageOperations researchVariable (mathematics)Local ringCompilerAddress spaceString (computer science)Constructor (object-oriented programming)Content (media)View (database)Closed setFundamental theorem of algebraMachine codePointer (computer programming)BefehlsprozessorObject (grammar)Semiconductor memoryCuboidCodeAddress spaceWritingMappingOrder (biology)Interpreter (computing)Social classLevel (video gaming)CountingOperator (mathematics)Inheritance (object-oriented programming)CompilerState of matterConstructor (object-oriented programming)Content (media)Goodness of fitPoint (geometry)SpeicheradresseComputer animation
07:46
Read-only memoryView (database)Content (media)Computing platformMobile appAddress spaceMachine codeCompilerCodeComputer configurationAddress spaceJava appletCodeOperator (mathematics)MereologySpeicheradresseContent (media)Object-oriented programmingString (computer science)Point (geometry)Data storage deviceComputer hardwareCompilerCompilation albumPointer (computer programming)Video gameSystem callLine (geometry)Process (computing)FreewarePerspective (visual)Sampling (statistics)Object (grammar)Level (video gaming)Semiconductor memoryComputer animation
09:46
Read-only memoryContent (media)Address spaceComputing platformMobile appPointer (computer programming)MathematicsCuboidObject (grammar)Product (business)Inheritance (object-oriented programming)PlastikkarteSuite (music)Streaming mediaComputer virusFunction (mathematics)Variable (mathematics)Template (C++)State diagramSTLThread (computing)Type theoryVector spaceElectronic mailing listHash functionJava appletJava native interfaceReflection (mathematics)Electronic signatureEmailFunctional (mathematics)Object (grammar)LoginPointer (computer programming)Address spaceThread (computing)Closed setType theoryPattern languageINTEGRALSpeicheradresseOrder (biology)Exception handlingComputer programmingReverse engineeringJava appletPoint (geometry)MultiplicationSystem callCountingQuantum stateMultiplication signCodeDifferent (Kate Ryan album)Standard deviationRight angleVariable (mathematics)Line (geometry)Library (computing)Computer fileCompilation albumWechselseitiger AusschlussTemplate (C++)Electronic signatureStack (abstract data type)Atomic numberAdditionBridging (networking)Process (computing)Message passingSpeicherbereinigungSign (mathematics)Insertion lossLevel (video gaming)Metropolitan area networkInterface (computing)PlastikkarteResource allocationGraph coloringCategory of beingComputer animation
17:09
Java native interfaceJava appletElectronic signatureEmailPointer (computer programming)Object (grammar)Reflection (mathematics)Computing platformMobile appJava Data ObjectsString (computer science)Operator (mathematics)OvalField (computer science)Exception handlingProcess (computing)CodeBridging (networking)Type theoryLibrary (computing)Interface (computing)ImplementationSource codeObject (grammar)Interface (computing)Quantum stateRight angleIntegrated development environmentAutomatic differentiationString (computer science)Reflection (mathematics)Social classWordQueue (abstract data type)Process (computing)Data conversionPoint (geometry)2 (number)Different (Kate Ryan album)Computer fileSystem callCategory of beingNormal (geometry)Ideal (ethics)SpeicherbereinigungCodeException handlingType theorySet (mathematics)Operator overloadingFlow separationRun time (program lifecycle phase)Operator (mathematics)Validity (statistics)Pointer (computer programming)Electronic signatureComputing platformOnline helpMachine codeConstructor (object-oriented programming)Library (computing)Overhead (computing)Information securityGoodness of fitFluid staticsFunctional (mathematics)Java appletClosed setReading (process)Interior (topology)Correspondence (mathematics)DataflowXMLComputer animation
24:31
Bridging (networking)Java appletType theorySource codeLibrary (computing)Interface (computing)ImplementationMobile appComputing platformAndroid (robot)CompilerArmEquivalence relationLevel (video gaming)LoginComputer networkConfiguration spaceComputer-generated imageryData compressionFunction (mathematics)String (computer science)Communications protocolBuffer solutionObject (grammar)Android (robot)SoftwareComputer fileObject (grammar)Mixed realityStandard deviationCompilerDifferent (Kate Ryan album)Reflection (mathematics)Configuration spaceCross-platformComputing platformCryptographyLevel (video gaming)Entire functionMessage passingRight angleBuffer solutionPoint (geometry)CountingOperating systemSelectivity (electronic)DemosceneCommunications protocolDatabaseMedical imagingDefault (computer science)Operator (mathematics)BuildingSemiconductor memoryInstallation artExterior algebraJava appletCodeBefehlsprozessorFlagXMLComputer animation
28:20
Android (robot)Computing platformMobile appFluid staticsString (computer science)Physical systemTemplate (C++)Java appletState diagramRevision controlShared memoryPhysical systemLibrary (computing)Android (robot)Integrated development environmentComputer fileLine (geometry)Source codeTemplate (C++)String (computer science)Revision controlJava appletSystem callStructural loadMaxima and minimaMachine codeObject (grammar)DemosceneProcess (computing)Right angleVideo gameSocial classComputer animation
30:27
Interface (computing)Computing platformMobile appCodeSoftware testingGoogolExecution unitRead-only memoryError messagePointer (computer programming)Software testingInterface (computing)WeightClosed setComputer configurationReading (process)WordMultiplication signObject (grammar)Point (geometry)Communications protocolAndroid (robot)File systemComputer virusSocial classStandard deviationSoftware developerType theoryLevel (video gaming)TheoryJava appletComputing platformDirectory serviceLibrary (computing)Data conversionVirtual machineoutputSoftware frameworkTemplate (C++)Projective planeComputer fileIntegrated development environmentUnit testingKey (cryptography)Bridging (networking)Direction (geometry)MereologyCodeFormal languageGoodness of fitExecution unitEmailHelmholtz decompositionRoutingCore dumpDifferent (Kate Ryan album)Address spaceProduct (business)Pointer (computer programming)Computer hardwareVariable (mathematics)Process (computing)Message passingSemiconductor memoryString (computer science)Cross-platformSimilarity (geometry)Roundness (object)System callView (database)Independence (probability theory)Bus (computing)MathematicsFree variables and bound variablesService (economics)Moving averageComputer animation
Transcript: English(auto-generated)
00:00
So, Marcus, I'm working with Objectbox for the last couple of years, and with Objectbox, my tasks shifted a little bit, so I've been a Java developer for 20 years, an Android developer for ten years, but with Objectbox, I use C++ a lot, and actually, I liked it.
00:22
So here's the story. I want to start with web technology. So web technology is all around, and it's really like, for example, if you start Slack, this is like a web technology, right? It might take a little until the messages are loaded, and also if you look at the processes,
00:43
it is eating a lot of resources. So if you compare that, so today, we're using like one gigabyte of RAM, and if you look like 50 years back, four kilobytes were enough to fly to the moon.
01:01
So it's just a little bit about resourcefulness. And if you look at cross-platform approaches, I know you saw like ten times in this conference already, so we have progressive app apps, we had PhoneGap, Electron, which powered Slack and others, React Native, Java, and Kotlin.
01:25
So Kotlin is really an interesting option, as we saw in several presentations already. Also might be Swift, so there might be some, I don't know, fighting between iOS world and Android world, but this could really make sense.
01:43
But where's another option, and this is like going to the real metal here, and this is like C and C++. So basically, C is like a sampler for a multiplatform. And it's been around forever, and this is nothing new.
02:01
So C developers are used to develop multiplatform. So when does it make sense to actually use C or C++? Usually it's about performance. So even with Kotlin Native, they will take years to get to the speed that you already
02:22
have with C++. It's so optimized, I'm so impressed what C++ compilers do, it's just amazing what complex code they take and how fast the result is. And especially on Android, because when you look at Android, it's running a virtual machine,
02:44
and it's not like a Java virtual machine running on desktop. It's several times slower than that. And of course there are some other reasons why you could use C or C++. It might be a little bit background of your company that you use C or C++ somewhere,
03:03
and you could just use that code. So where do you want to use it? If you use a game, that's just great. You could use Unity or Unreal, and with, for example, Unreal the game engine, you would
03:23
use C++. But for typical apps, it's not so good choice, because you still want the system-specific look and feel in your app as well. Also if you interact a lot with your operating system, there are better options, because
03:45
like all the Java APIs you have for Android, they are not available in C++. So what makes more sense is when you have a special use case, like for example you want to implement some specific cryptography, and you could also add some business logic
04:03
around it, because when you use, when you have a need for high performance anyway, you could just go ahead and extend this a little, because it will run on all platforms. So and there's also WebAssembly.
04:23
Who is heard of WebAssembly? I want to see some hands. Okay, not so many. So WebAssembly is about running native code in your web browser. And all major browsers support it already. So there's a toolchain that you can use for your C or C++ code.
04:47
And of course it's like a secure sandbox in theory. And there's a lot of interoperability of JavaScript, and also you have functionality to all your browser's functionality.
05:02
And it comes with, like it started with C, C++ support, and this is still the best support you can have for WebAssembly. So this is another platform you can focus with C++ actually. And I didn't even talk about IoT, small devices and so on.
05:24
So C and C++ are really multi-platform. Okay. Before I go on, I want to take a little step back and talk about some fundamentals about more close to the hardware things.
05:43
And yeah, so if you look what's going on, like a CPU only understands machine code. These are just like bytes in a specific order. And if you want to write code for it, you need a compiler or interpreter.
06:03
And also like if you look at a CPU, there are registers, and those registers are very important because they are very fast to access and also like most operations you can do in data is done within those registers. And if you look at memory, it's like a chunk of memory you have.
06:23
And every byte has its address. This is just a number. So let's see if you have a class like this. Very super simple class, name counter, versus constructor, whatever, and there's an increase
06:43
method. So if you would use that, you would have like an object. It has its state, like for example box is the name, and currently there are no box. So count is zero. And you call it, and it increases to one. So this is your object.
07:01
Now how does this look in like memory? So this is like a little simplified, but you can see like name box has some strange content, and here count maps to this one.
07:22
So maybe a couple of questions here. So why is that the one in the first byte? So it was like the little endian thing. So the byte ordering also comes into play sometimes when you work low level. And this is actually like a pointer.
07:40
So it doesn't contain box like the four letters, but it's more of, it's pointing somewhere. Where does it point to? To another memory address. And here you can see, like this looks like ASCII code, but where's the zero in it?
08:01
That's because you have UTF-16. So Java stores those, like each character into bytes. And this is how it resolves to a real string.
08:23
And if you look at some code that you execute, like in your object-oriented world, everything is the same, like data and methods and so on. From hardware perspective, it's pretty different. So you have your code and you have your data.
08:41
And with like the simple count++ just translates to a couple of like low-level calls, which is like, oops, sorry, wrong button. So this is like the address here. So what is happening, we are loading content of this address into register A. And then
09:06
we can add one to register A. And then we can store it. And at that point, and only at that point, like data gets updated. And this is also like part of the explanation why a++ is not atomic.
09:21
Because even here it's like free operations. And there's some very interesting website. It's like the compiler explorer. And you can paste in C or C++ code. And it will give you a sample code. So you can really look under the hood of what's going on in compilers.
09:48
So why did I tell you this? The point are pointers. A pointer is just a variable pointing to some memory, to some memory address.
10:03
And there's also a lot of pointer arithmetic done in C, C++. For example, you have a pointer to an object. And if you get some data from this object, like the property, it's just like a base address and adding some offset to it.
10:24
And it's also like the safest way to get into trouble. So if something goes wrong, it's usually a bad pointer that you have in your program. And this is like where it can get really nasty. So if you are troubled with null pointer exception, this is way worse than that.
10:46
And if you look at how you deal with actual C++ objects. For example, if you create a new person. And by the way, C++ has this great auto. So we don't even know the type right now.
11:01
So it's a pointer. So if you create a new object, it's a pointer. So where there's no garbage collection, no auto release pool or whatever. So once we have an object, how can we delete it? And this is also like a call that you have to do by yourself, right?
11:25
There's another problematic scenario. So for example, you call a method, maybe you didn't write it, and you get a pointer to a person back. So you don't know, should I delete this pointer, or is it like an internal pointer managed somewhere else?
11:41
And these are like the typical problems of C++. And it gets a little worse when you have like an object, and it's referenced by multiple other objects. So in the end, who's the owner of Joe, and who will delete Joe after everybody's finished?
12:08
And this is where modern C++ kicks in. So with C++ 11, where we have been so big steps ahead, for example, smart pointers.
12:21
What you can do here is you can, for example, you can return a unique pointer from your method. And in this way, you transfer the ownership to the caller of this method. And when you call this method again and assign another person to it, like a smart
12:40
pointer automatically deallocates, deletes the first person. And if like this unique pointer gets out of scope, also the second person is deleted. And this is just one of the things you can do. There's also like shared pointer.
13:01
And this is exactly like the situation where you had this Joe and multiple references to it. And this pretty much works like reference counting. And once like nobody references like a person anymore, it is getting deleted automatically. So this fixes most of the bad, bad problems we all think C++ is about.
13:31
Who knows what that is? Ray. OK, so it's a funny acronym.
13:41
And yeah, I better skip it and just explain it by an example. So for example, you have this logguard. So this is like an object on the stack. So once the method returns, this object gets deallocated.
14:01
And what happens here is you're getting like a log on a mutex and then also file. So both use this Ray principle. And once they are deleted, the resources are freed. So you don't have to call like file close or log unlock.
14:21
It's done automatically and in the right order. So that's the reverse order of creation. So even if here an exception might be thrown, everything is nicely deallocated. And there's no like if else, error, whatever things you have to do manually.
14:45
And this gets your code much cleaner. And C++11 also comes with lambdas. So we had function pointers before, but this is just much more nicer. You can capture variables and also it can be templated.
15:03
So you don't even lose performance. It's just like you wrote like a method 10 times for different types. So compilers are really smart about this. But it's also like the standard template library. And with C++11, it got a lot of useful additions.
15:25
So for example, threads. It's very simple to create a thread. And yeah, wait for a thread. We already saw the locking. And also it supports atomic values, atomic types. So you can do like the counter plus plus in an atomic way.
15:42
Very simple. And it also has, just like Java, Kotlin, whatever. It also has some nice containers. Like the methods are a little strange, like push back instead of add. But in the end, it's pretty much the same functionality.
16:01
And if you look, for example, you have a vector of users, how you iterate over your users. It looks pretty much like Java, right? Just one line before each. And you're done. Okay. Now let's look at how you can integrate C++ with Java, for example.
16:24
So where's Java Native Interface? And it allows you to call from Java into native C. And there's also an API that allows you to call into like the Java world from C.
16:40
So it's like a two-way bridge. So there's a funny signature that you have to adhere to implement your methods. And there's also some tools around it. But usually you can also just, once you know how the pattern is, you can just type
17:03
it or copy paste it on your own. So, like, one thing is how do I pass, for example, a C++ object to Java? That's pretty hard. But at some point, you need references, for example, like in your second JNI call,
17:23
you want to reference this C++ object, so you can still pass, like, along. And with, you can cast. And yeah. So we have those C-style methods.
17:41
And there's also, like, this JNI nth object. So you can do everything with that. Whatever you do, if you create a string, you want to read int property, you have to use JNI nth. And there's some conversion going on when you call into, like, your native method.
18:02
Then there's corresponding C type. For example, J int, J string, or J object in redslide. Valid for all classes you could possibly have. So let's look how this works. So with, for example, you have some string passed from Java.
18:28
So you can get, like, the C string using the nth. But let's make this a little more modern. And you could come up with some helper classes using Ray again.
18:46
And what you would do, okay, let's release. Yeah, so for, I forgot about that. So with environment JNI nth, you always have to release your resources.
19:00
So this is pretty much C-style. So to wrap this, you can come up with a Ray class. For example, JNI string. And in the constructor, you just get to see characters. And in the destructor, you clean up.
19:21
And there's one additional thing. There's operator overloading. So whenever you use this JNI string as, but you want to have, like, a char pointer, that's how you can very simply call this overloaded operator.
19:42
So maybe it becomes more clear if you look at an example. So where's this method called foo that you want to call? It has a C-style signature with const char pointer. And where's this JNI method you implement?
20:00
So you get, like, the environment in and, like, a J string. So all that you have to do is, you would allocate the JNI string, your helper class, and call foo using this. And there's no clean up, so this is a way, way cleaner way of doing this.
20:26
So JNI, yeah, it's old. It has its challenges. So first of all, there's no good interface to get the data of your Java objects.
20:41
It works pretty much like reflection. So using its name, you can get properties. And that's obviously not the most efficient way. But also when you call into JNI native, you have some overhead. There are some security checks and so on. So what also influences the way you design your JNI API.
21:07
And where's this fun topic of also, like, freeing your resources? In Java, you don't have any guarantees for your garbage collector. So when an object dies, it can be now,
21:22
it can be in five minutes, whatever. And this is like a little mismatch with the native code if, like, your Java object has, like, references to native resources. So you can, what would you probably do is if you have, like, a close method or something that you call manually.
21:42
And just to be sure, also have something like a finalizer or reference queue. And also, if you're using, like, more modern C++ code, you want to use exceptions. And there's just one catch with that.
22:01
Or isn't a catch with that. It will kill your Java process. So what you do is you catch the C++ exception and raise a Java exception. And where is the difference between throwing and raising an exception? If you raise an exception, it's just one of the few method calls
22:23
you make with JNIenv. And it returns regularly, so you have to take care that your flow also, like, returns from the JNI method. Like, maybe if there's a return type of J object, you just return null pointer or something.
22:44
Okay. There's some fun stuff you can also have with JNI. So for example, we have this static native method. And like in non-static method, calling the static one. And you just call from the object the Java method.
23:05
And what could possibly go wrong, right? Looks good, right? What could happen is where, like, native foo function has an illegal object. Like, the object it is called on with bar is already gone.
23:24
So this is just some things where you happen to run into. So solution is very simple. You just have to kick the static and you're good again. But, yeah. You still notice, you still have a reference
23:41
because that object is still here. Anyway. So JNI is not the greatest interface in the world. But it's like the only one if you want to talk to see. Fortunately, there are some more convenient alternatives around. Like with JNI.
24:02
It's pretty dynamic. It looks up your library at runtime. And it does all the, like, type conversions for you. Or, like, the most simple ones. And also JNI by Dropbox, which works a little differently. So what happens here is you define a text file, an IDL. And it generates some artifacts for several platforms.
24:24
So for C++, Java, and Objective-C. And this makes it all so much easier. So when we look at Android, it's quite easy to get started. What you have to install is, like, CMake, NDK.
24:44
And with the NDK, you get Java native interface, unfortunately. A pretty good compiler. So Clang. And GCC will be not supported anymore. It was like the default compiler
25:00
like a couple of years ago. But they switched to Clang internally. And with Clang, or also GCC, cross-compiles your C++ code for all the CPUs that are around. And, like, Clang 6 is pretty new.
25:20
So it also supports, like, newer standards like C++ 17. So from the NDK, you can also use specific Android APIs. It's not that you can use the entire Android operating system, but some APIs are available.
25:41
So if you're targeting, like, a lower API level, you're pretty much restricted where it's logging and some other stuff. And some cooler stuff comes with Android 8 and 8.1, like neural networks, shared memory. Alright, so.
26:01
There's also CMake. So, when you use Gradle for your, um, Android build, you would use CMake for your C++ build. It is, it is like, yeah, high, more high-level make for, for,
26:20
and cross-platform that internally uses Make or Ninja to make, to compile. And what you do, you specify, like, a text file. It has a specific syntax. You will see a short example shortly. So, how do you integrate CMake into your Android build? Well, it's pretty simple.
26:41
So, it's just, you basically just point it. Here's your CMake file. And that's it. You can also give in some configuration. So, for example, you want to have some flavors you can pass in also different configurations into your C++ build.
27:04
Another challenge is, like, if you have a lot of data and you want to share that in both worlds. So, what is very easy? For example, if it's, like, byte-based, so, for example, image data or you do some cryptography, so you usually have, like, big byte buffers and those go
27:21
just, just well back and forth. When you have, uh, like, objects, like, like, both ways are not so, so great because, yeah, like, a J object is very, like, this is, uh, reflection style access and so on. And the same way is just not so good.
27:42
So, how could you solve that? You could use, um, JSON for interop, but there's another, like, better alternative when you use, for example, something like protocol buffers, flag buffers. So, you are, uh, you still have those bytes,
28:00
uh, to, to call into your, uh, different platforms, kind of. And, but actually, those bytes are objects. So, this is a pretty good work around. Of course, you could use a database that works on both ends.
28:21
So, when you start with a new project and want to use the NDK, there's also a template given from Android Studio. So, all you have to do is a little checkbox, include C++ support, and here we go. It gives you an activity already, uh, calls like system load library
28:43
and also has, like, a first native, uh, step for, for, for your C, uh, style method. And also the first template for, uh, C++ where some includes, obviously.
29:00
And, and here's this, uh, funny naming. So, it goes like Java, then the package all with underscore, and then there's the class, and here, finally, is your method. So, this is just a convention to map with C method to your Java native method. And
29:24
there's some other stuff around it. So, so it's really getting exported. This, this method, uh, from your library and it's accessible, so you need to have some, write some yada yada about that also. And, yeah, here's another
29:42
example. This is how you can return like Java objects from your native code. So, again, it's going with the JNI environment and, yeah, for example, new string. So, if you look at
30:00
the CMake file that is generated, it's, it's very simple. So, you can ignore most of it, but those, those two lines are enough for a CMake file. So, for some reason you have to specify a minimum version for CMake, and then you just say there's the library and it has
30:21
the source file. And you're done. Okay, so, some more stuff. So, we, I talked about C++ 11 and, yeah, so, where's, meanwhile there's like C++ 14.
30:40
It was like more a small release, but 17 is a pretty important release again. And it has some cool features that you might know of, for example Kotlin with decomposition so, this is an example here. So, in the end you will have like three variables with different types
31:01
and so, you write a lot of, a lot less code again. And also, like the standard template library got important upgrades. So, pretty, pretty nice stuff with Optional Any and StringView and, surprisingly, it took very long to have a file system for C++
31:22
that works cross-platform now. So, before that like, even, like, reading all files within a directory that was platform-dependent code and with C++ 17 it's not. Okay. So, we talked about
31:40
Android and C++ in general. And if you look at the iOS side of things, it's actually much nicer here. So, there's no JNI but your objective C++ code can just use C code and that makes it very, very simple.
32:03
However, if you also want to support Swift there's no direct access way here. So, what you would do is Swift calling into some objective C and it can't be objective C++ at this point. So, anything that looks like C++ would
32:21
confuse this Swift part. So, what you usually do is you have some objective C protocol only for your objective C++ class. So, you're mostly Android developers
32:41
key takeaway is very simple on iOS. So, testing is very important with C++. And the nice thing is because C++ just runs on your desktop machine. You can also run tests
33:00
that run directly. So, you don't have to upload it to your device or anything. You can just run it. There are a couple of testing frameworks. So, unit testing. Yeah. So, I kind of catch to a lot. With Google test you have to install
33:20
an environment in the first place and catch to, for example, just a header file that you include. And the nice part here is we're so fast. So, you can have like hundreds of unit tests and they just run like in a second.
33:42
There's also one more thing you should consider. There's those sanitizers like address sanitizer or ASAN. And those check that you don't have bad pointers. Bad memory access. And this helps a lot before
34:01
it gets really ugly. So, when you have bad pointers somewhere in your code, you can be busy for days. So, these are really the tools you can use and combined with CI it really keeps your productivity level up.
34:22
So, you need a little safety net with C++, but once you have that in place, like personally, I feel as productive with C++ as I do in Java. And these are my closing words. Thank you.
34:45
Wow, we have time for questions. I'm not sure. Oh, wow, there's one. Oh, great. A couple. Of course, I thought it wasn't that easy, right? But please come and I'll give you the mic.
35:01
Thanks for the presentation. Very interesting. I was wondering how easy to have Android C++ and iOS and in theory other platforms in a single project. I know it should be possible to abstract the bridge between C and
35:22
Java or C and Objective-C or other things, but how much work is it on doing all those bridges? All those bridges. So, for JNI part, it is a little more work because there is some conversion going on.
35:42
And it really depends on your project. So, if you're doing a lot in C++, have just a few methods that's done in minutes. And on the iOS side, it's very simpler because you can access C++ directly. So, there's no strange
36:01
Java native interface here. So, with like the bridge part is, I don't know, it's like maybe like 10% of the work. And that's just because of JNI. Any other questions? Okay. You after that.
36:20
What are the key facts for you and would you recommend to use C++ for shared code or other technologies like languages like Kotlin or JavaScript or whatever? Good question. So, usually you have a reason to use C++ because you want some great performance or
36:40
you have some code that is close to some hardware you use or your company has some C++ code. Or you just or whatever. Maybe you have good C++ developers. So, these are our reasons. And, yeah, I think Kotlin native, for example, still
37:01
has to catch up a lot. In the long run, I think that's a very interesting route. But it's not as stable, not as proven, whatever as C++. Hello. I have a question. Maybe could you give me
37:20
practical advice? I have a problem. I should pass an interface to my C++ core and this interface will be implemented in Java and I should call it maybe 10 times per second and pass a lot of data. Maybe you could advise me how
37:40
maybe most efficient way from performance point of view, how could we implement it? Okay. So, great question. And answer might be a little more complex. Maybe you should talk. So, basically, you would supply the native side of things like, for example,
38:00
a method name and using this JNI end, you can call into Java. But let's discuss this in more detail, like, privately.