Amit Shekhar Profile picture
Aug 8 โ€ข 12 tweets โ€ข 3 min read
How does the Kotlin Multiplatform work?

A thread ๐Ÿงต

Please do retweet for max reach ๐Ÿ™

#AndroidDev #Kotlin #iosdev
First, we write the shared code in Kotlin. For Android, it gets converted to the Java bytecode that can be executed in the JVM. So, Android already has a Virtual Machine(VM) that is easily capable of running it.
But what about iOS, how can it run Kotlin? Can we do it without the Virtual Machine(VM)? Have you ever wondered how it works?

For iOS, Kotlin code must be converted to the source code(native code executable on iOS) that goes inside the framework. That source code works on iOS.
How does the Kotlin code get converted to the source code that is capable of running on iOS?

Here comes the Kotlin Compiler into the picture. It has two parts as follows:
1. Frontend - It converts the Kotlin Code into the IR (Intermediate Representation). That IR is capable of getting converted into the native code that is machine-executable using the backend which is described below.
2. Backend - It converts the IR into the native code that is machine-executable. This is possible because of the Kotlin/Native Infrastructure built by JetBrains.For Android, it converts the IR to Java Bytecode and for iOS, it converts IR to the iOS native machine-executable code.
It is important to note that we are able to run the shared business logic code written in Kotlin on a platform like iOS without the Virtual Machine(VM).
Here, Kotlin/Native plays an important role. What exactly is Kotlin/Native?

From the official documentation:

Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain.
It is designed to allow compilation for platforms where virtual machines are not desirable or possible (such as iOS or embedded targets), or where a developer is willing to produce a reasonably-sized self-contained program without the need to ship an additional execution runtime.
Now, the next question arises in our mind, what is LLVM?

We can say that LLVM is a library for programmatically creating the machine native code from the Intermediate Representation(IR).
We first create the Intermediate Representation(IR) which is needed by the LLVM and then LLVM does its magic.

Summary:
Kotlin Code > Intermediate Representation(IR) > Machine-Executable Native Code.
This way, the Kotlin Multiplatform works.

That's it for now.

Happy Learning :)

Show your love by sharing this tweet with your fellow developers.

Follow @amitiitbhu for learning and sharing.

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Amit Shekhar

Amit Shekhar Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @amitiitbhu

Aug 5
Evolution of HTTP

HTTP 1.0 -> HTTP 1.1 -> HTTP 2.0 -> HTTP 3.0

A thread ๐Ÿงต

HTTP 1.0

Problem: Each request to the same server needed a new TCP connection.

continued...
HTTP 1.1

It solves the HTTP 1.0 problem.

Problem: HOL blocking issue. HOL(head-of-line) blocking issue - new request had to wait for the earlier request to complete.

HOL blocking issue at two layers:

1. Application
2. Transport(TCP)
HTTP 2.0

It solves the HTTP 1.1 problem of the HOL issue at the application layer using request multiplexing.

Problem: HOL blocking issue at TCP.
Read 4 tweets
May 14
How does the Voice And Video Call Work?

This tweet is all about how the voice and video call works on a high level.

Continued in this thread ๐Ÿงต [Follow the thread below] ๐Ÿ‘‡

#AndroidDev #Kotlin #Android #Developer
Both voice and video calls depend on how we stream media between the two clients who are connected to each other. So, there must be something that can do the work of media streaming from one client to another client.

For media streaming, we need to know about WebRTC.
WebRTC is a free, open project that provides browsers and mobile applications with Real-Time Communications (RTC) capabilities via simple APIs. The WebRTC components have been optimized to best serve this purpose.
Read 16 tweets
May 13
What is Feature Engineering for Machine Learning?

A thread ๐Ÿงต

#MachineLearning
Feature engineering is the process of using domain knowledge of the data to create features that make machine learning algorithms work.
If feature engineering is done correctly, it increases the predictive power of machine learning algorithms by creating features from raw data that help facilitate the machine learning process.
Read 15 tweets
Apr 13
Why an Android App lags?

A thread ๐Ÿงต

I will start with the following statement:

Garbage Collector: The TAX on Android App Performance

#AndroidDev
The main reason for the low-performance Android App is that it runs GC very frequently.

Simple in one line: The time for which GC is running the actual app is not running.
When the app runs, it allocates many objects on the basis of your code, and when the objects are no longer referred to, the system call GC when there is memory pressure to deallocate those objects, so if the object allocation and deallocation are occurring on regular basis.
Read 10 tweets
Aug 21, 2021
How does Voice And Video Call Works?

This tweet is all about how the voice and video call works on a high level.

Continued in this thread ๐Ÿ‘‡ [Follow the thread below]

#AndroidDev #Kotlin #Android #Developer
Both voice and video calls depend on how we stream media between the two clients which are connected to each other. So, there must be something that can do the work of media streaming from one client to another client.

For media streaming, we need to know about WebRTC.
WebRTC is a free, open project that provides browsers and mobile applications with Real-Time Communications (RTC) capabilities via simple APIs. The WebRTC components have been optimized to best serve this purpose.
Read 16 tweets
Aug 20, 2021
Android App Release Checklist For The Production Launch

Continued in this thread ๐Ÿ‘‡ [Follow the thread below]

#AndroidDev #Kotlin #Android #Developer
Add analytics to your Android application.
Turn off logging and debugging.
Read 21 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(