- Tram Ho
Bitcode is not a new concept, but there are probably a lot of you vague about this concept. So what is it? Why does the app build (iOS) ask if bitcode is enabled?
Bitcode – Basically this is something that allows the App Store to optimize applications for each device type before they are downloaded by users. In addition, it also helps applications to automatically take advantage of new capabilities added by Apple in the future while developers do not need to re-upload the app to the store.
Before learning about bitcode, you need to know a little bit about Low Level Virtual Machine (LLVM). This is a programming library used to compile high-level source code into machine code so that the device can understand execution. LLVM has been used to build many compiler of many popular high-level programming languages, such as C, C ++, Python, Java, Ruby, of course Objective-C and Swift (originally two languages used to write apps for OS X and iOS)
There are 3 parts in LLVM. Part of it is called “front-end”, which is what is used to read these programming languages. The second part is called “back-end”, it knows how to produce machine code lines that can be run by ARM CPU, x86_64, SPARC, PowerPC and many other architectures.
But how can the back-end understand the source code of the front-end to perform this conversion function? That is the task of an intermediate layer between “back-end” and “front-end”. This middle class is known as “LLVM Optimizer”, it uses a low-level programming language called intermediate representation (IR). IR in LLVM can exist in three different forms depending on the programmer, and one of the three forms has “bitcode” (the other two are assemblies and objects of type C ++).
Thanks to the independent design of the three components, it is easy to support new front-end languages, as well as support new CPU architectures on the back-end, even those that do not exist at the time. Application point of birth.
Thanks to this advantage, Apple said that Bitcode helps “the application automatically take advantage of the new capabilities of Apple additional CPU in the future that the programmer does not need to fix the app”. Why? Because the front-end and the bitcode remain the same, only the back-end is changed, but this back-end compilation will now be handled by the App Store, which is Apple’s responsibility, not And the developer.
Currently the company is using ARM architecture for iOS and watchOS, and OS X is based on x86_64. With bitcode, later if Apple changes to use some new XYZ architecture, the app containing the bitcode can still work normally on this new platform without the programmer changing the source code, all are taken care of by the App Store. Similarly, on a narrower scale, suppose that Apple continues to use ARM for iOS and watchOS but its new CPUs have some special functions, thanks to the bitcode, the applications still make use of the This function does not require programmers to rewrite the app.
Take a simple example like this. With the iPad Pro, assuming that Apple no longer uses ARM chips and switches to Intel chips, any iOS app with integrated bitcode will still be able to run on the new platform without the programmer having to fix anything. Similarly, the S1 chip in Apple Watch is now ARM, but if Apple wants to use Intel architecture for the S2 chip, it will accept it, the application will always run, Apple does not need to wait for the programmer to reload the app their.
But in the future, with bitcode, developers will no longer have to worry about CPU architecture transformations, no matter how big the change is. Even if Apple switched to using a completely new architecture, their app would still make sure it ran. And at that time, the only thing Apple needed to think about was how to make their CPU run better, stronger, less battery power, no longer have to worry about app compatibility.
So we can see that Apple is gradually “forcing” developers to use bitcode, starting with their watch apps. On iOS, the word “default” can change to “mandatory” in the future at any time.
With its own bitcode and ARM chip in hand, Apple can get rid of its dependence on Intel, no longer having to worry about the company’s chip delays. They are also completely autonomous in terms of CPU performance and power consumption, thereby optimizing their hardware better. In addition, Apple does not need to inform the developer in advance when it wants to change the processor architecture, thereby helping to keep its business plan more secret.
In short, with bitcode, both Apple and programmers benefit. Apple has become more flexible in changing CPU architecture for both computer and mobile products, and programmers do not have to spend effort, money and time to rewrite the app on such occasions. Of course, bitcode will take time to be popular and be integrated into many apps, then the above benefits will work, but only a few dozen apps use bitcode, everything will not change. how much
ITZone via Viblo
Source : Viblo