Dec.04

Knight on the horizon!

Knight on the horizon to bring peace in our kingdom of mobile application development. Knight is coming and coming strong.

Nowadays lots of companies are going for cross-platform development to reduce development time and cost. Question is … how safe is it for long-term investment? 🤔

I’m working on mobile application development for a while and I saw many cross-platform projects died prematurely. Many projects died because those were depending 100% on 3rd party technologies. When these 3rd party technologies slow down, our projects slow down and when those die, take our projects with those as well. 😥

😭 THEN WHAT ARE WE GOING TO DO? WHO IS GOING TO SAVE US?

Well, we need to evaluate our long-term objectives and find balances. We might have chosen those paths because we didn’t have any other option at that time. But it’s about to change. 😉

3rd party technologies should be our projects’ supports but not souls. Our objective should be using those for our benefits, but if necessary we should be able to cut those off without killing our projects.

Let’s check iOS and Android native technologies.

iOS: Swift + Objective-C + UI Components (Proprietary).
Android: Kotlin + Java + UI Components (Proprietary).

Now let’s check widely used cross-platform technologies nowadays.

React Native: JavaScript + UI Components (Proprietary).
Flutter: Dart + UI Components (Proprietary).

We write whole application in React Native or Flutter. Those compile whole application natively for platforms.

As we can see, there are no common grounds between iOS/Android and React Native/Flutter in terms of technologies until compilation. 🥺

We just can’t cut those off whenever we want because whole existences of our applications depend on their existences. React Native and Flutter don’t correspond to native iOS and Android technologies until compilation.

Behold! Knight aka Kotlin Multiplatform is here to save us. 🛡

Kotlin Multiplatform allow us to compile codes and create libraries in native languages and formats. This technology compile codes written in Kotlin and generate libraries for Android and frameworks for iOS.

Check out: 😃 Kotlin Multiplatform 😍

We should develop user interface natively for platforms to provide native experience, smooth performance and customization whenever necessary.

We can compile sharable codes e.g. business rules, etc written for Android projects with Kotlin Multiplatform and can use those for iOS projects.

Later, if we don’t want to continue cross-platform development or share codes among platforms, we can just write those codes e.g. business rules, etc for iOS projects natively. Android projects can keep using existing codes as those are written in Kotlin.

Even after separation, both iOS and Android projects are alive and developments can continue independently with native technologies. 😍

Don’t worry! Our knight aka Kotlin Multiplaform is coming. Everything will be alright soon. 😁

Kotlin,Multiplaform,Thought

Nov.26

Kotlin Multiplatform

Kotlin Multiplatform allows cross-platform development with native languages! 😃 😍

With this approach, we can use native Android and iOS user interface and share libraries e.g. business rules in native format. 😃

Kotlin Multiplatform makes it possible to reduce costs and make business rules between platforms more reliable. 😍

Presentation on demo (Android and iOS) based on Velib Stations and Google Maps. 😎

Come on … let’s discover Kotlin Multiplatform. 😃

GitHub: https://github.com/muhammedsafiulazam/velibstations


Kotlin_Multiplatform_Version_1.0_Web

Kotlin,Multiplaform

Nov.07

Interview: Android – Kotlin

Queston: What are Lambda Expressions and Anonymous Functions?

Lambda expressions and anonymous functions are ‘function literals’, i.e. functions that are not declared, but passed immediately as an expression.

Lambda expression is always surrounded by curly braces, parameter declarations in the full syntactic form go inside curly braces and have optional type annotations, the body goes after an -> sign. If the inferred return type of the lambda is not Unit, the last (or possibly single) expression inside the lambda body is treated as the return value.

Anonymous function looks very much like a regular function declaration, except that its name is omitted. Its body can be either an expression or a block. We can specify return type in anonymous function.


Question: What are Coroutines?

Coroutines are a new way of writing asynchronous, non-blocking codes (and much more). Coroutines are sort of tasks that threads can execute. Threads can stop executing coroutines at some specific “suspension points”, and go do some other work. Also threads can resume executing coroutines later on, or another thread could even take over.


Question: What are CoroutineContext and CoroutineDispatcher?

Coroutines always execute in some context represented by a value of the CoroutineContext type, defined in the Kotlin standard library. CoroutineContext is a set of various elements. The main elements are the job of the coroutine and its dispatcher.

Coroutine context includes a coroutine dispatcher that determines what thread or threads the corresponding coroutine uses for its execution. CoroutineDispatcher can confine coroutine execution to a specific thread, dispatch it to a thread pool, or let it run unconfined.


Question: What are GlobalScope and CoroutineScope?

GlobalScope is used to launch top-level coroutines which are operating on application lifetime and are not cancelled prematurely.

CoroutineScope defines a scope for new coroutines. Coroutine builders are extensions on CoroutineScope and inherit CoroutineContext to automatically propagate context elements and cancellation.


Question: What are Suspend functions?

Suspend functions are at the center of every coroutine. Suspend function is a function that can be paused and resumed at a later time. These functions can execute long running operations and wait to complete without blocking threads.


Question: What are runBlocking and coroutineScope?

runBlocking runs a new coroutine and blocks the current thread interruptibly until its completion. It is not a suspend function and should not be used from a coroutine.

coroutineScope is a suspend fun. When coroutine suspends, coroutineScope function suspends as well.


Question: What are async and launch?

launch starts fire-and-forget coroutine and it returns Job.

async starts coroutine which computes some results and it returns Deferred<*>.


Question: What is Deferred?

Deferred is a kind of analog of future which encapsulates an operation that will be finished at some point in future after it’s initialization.

Android,Kotlin,Interview