SlideShare a Scribd company logo
A Journey from
Callback Hell
to
Kotlin Coroutines
Ahmed Nabil
Kotlin Egypt
@AhmedNMahran
Sat. Jan 1 2022
About Me
About Me
1. Writing Code since I was 11
2. 8+ years in Mobile App development
3. Given talks to thousands of audiences
4. Prev. Android Mentor at 1M Arab Coders.
5. Worked at Hungerstation,Codly, and others.
6. Software Tech. Lead at Vodafone (_VOIS).
7. Head of Kotlin Egypt.
About Me
About Me
What
is Kotlin ?
1. A modern Programming Language.
2. Developed by Jetbrains & Open-Source community
3. Since 2010.
4. Current Stable Version is 1.6.10 (as of 31-12-2021)
Kotlin
1. Multiplatform-Mobile
2. Server-Side
3. Web Front-End
4. Android
5. WatchOS
6. Data Science
7. and more
Used to Develop
About Me
Let
the journey
Begin
ANR
● any operation > 16ms may cause Lag
● I/O operations, long running operation
● Main thread should ONLY do
UI operations
About Me
Asynchronous
Code
1.Threading
2.Callbacks
3.Futures, Promises
4.Reactive Extensions (Rx)
5.Coroutines
Approaches
About Me
Problem
Code running in Main
thread causing Crash or
Lag.
About Me
Threads
A program splits itself
into 2 or more running
tasks
1.Expensive
2.Not Infinite, limited with device capabilities
3.Not always available, (e.g. JS doesn’t have threading)
4.Hard to Error-handle and debug
Threads Limitations
About Me
Callbacks
a function sent as an
argument to another
function to be executed
at certain point in time.
1.Nested Callbacks not easy to understand
2.Hard to Error-handle and debug
Callback Limitations
About Me
Futures
and Promises
I promise I’ll return at
some point in the future.
1.Nested Callbacks not easy to understand
2.Return Type :
Needs changing the models (extra steps in getting the data)
3.Hard to Error-handle and debug
Limitations
About Me
Rx
Everything is a stream
and it’s observable
Needs learning new apis
:(
About Me
Coroutines
Kotlin’s approach to work
with async. code
Process
Thread1
Thread2
Coroutine1
Coroutine2
Coroutine3
Couroutine4
1.No new apis needed, same language used (kotlin)
2.Return type doesn’t change.
3.Write sequential code while being thread-safe
4.Lightweight, can run many of them in one thread,
5.Easy to switch between threads
6.Platform independent
7.Easy to debug and detect errors.
Coroutines
Quiz
& Prize
About Me
Follow Me
@AhmedNMahran
Thanks!
Twitter Youtube Linkedin Medium Github
Thanks
Ahmed Nabil
Kotlin Egypt
@AhmedNMahran

More Related Content

Similar to A Journey From Callback Hell To Kotlin Coroutines

Introduction To Kotlin - Google Official Programming Language
Introduction To Kotlin - Google Official Programming LanguageIntroduction To Kotlin - Google Official Programming Language
Introduction To Kotlin - Google Official Programming Language
Soumya Suman
 
Types Of Kotlin App Development Services
Types Of Kotlin App Development ServicesTypes Of Kotlin App Development Services
Types Of Kotlin App Development Services
MobibizIndia1
 
Building Hybrid Apps with AngularJS and Ionic
Building Hybrid Apps with AngularJS and IonicBuilding Hybrid Apps with AngularJS and Ionic
Building Hybrid Apps with AngularJS and Ionic
Younes Adounis
 
Flutter session 01
Flutter session 01Flutter session 01
Flutter session 01
DSC IEM
 
Civi mobile & CiviSync Mobile
Civi mobile & CiviSync MobileCivi mobile & CiviSync Mobile
Civi mobile & CiviSync Mobile
Ireland India Business Association
 
Introduction to Mobile Application Development on Android
Introduction to Mobile Application Development on AndroidIntroduction to Mobile Application Development on Android
Introduction to Mobile Application Development on AndroidJulian Shen
 
Android Training Course In Chandigarh
Android Training Course In ChandigarhAndroid Training Course In Chandigarh
Android Training Course In Chandigarh
Excellence Academy
 
Simon Bates, Manifesto Digital - Mobile Application Development: Past, Presen...
Simon Bates, Manifesto Digital - Mobile Application Development: Past, Presen...Simon Bates, Manifesto Digital - Mobile Application Development: Past, Presen...
Simon Bates, Manifesto Digital - Mobile Application Development: Past, Presen...
Simon Bates
 
Cross-Platform App Development in C#
Cross-Platform App Development in C#Cross-Platform App Development in C#
Cross-Platform App Development in C#
MobilePundits
 
Mobile Programming - 1 Introduction
Mobile Programming - 1 IntroductionMobile Programming - 1 Introduction
Mobile Programming - 1 Introduction
AndiNurkholis1
 
Android ppt
Android pptAndroid ppt
Android ppt
Ram Bharosh Raut
 
Journey to become Android Developer - NgodingJeh! @STMIKCIC Cirebon - By: Riz...
Journey to become Android Developer - NgodingJeh! @STMIKCIC Cirebon - By: Riz...Journey to become Android Developer - NgodingJeh! @STMIKCIC Cirebon - By: Riz...
Journey to become Android Developer - NgodingJeh! @STMIKCIC Cirebon - By: Riz...
Rizal Khilman
 
Android operating system by udayan thakurdesai
Android operating system by udayan thakurdesaiAndroid operating system by udayan thakurdesai
Android operating system by udayan thakurdesaiUdayan Thakurdesai
 
Android Development with Kotlin course
Android Development  with Kotlin courseAndroid Development  with Kotlin course
Android Development with Kotlin course
GoogleDevelopersLeba
 
Android with kotlin course
Android with kotlin courseAndroid with kotlin course
Android with kotlin course
Abdul Rahman Masri Attal
 
Multi-platform Mobile apps with Phonegap
Multi-platform Mobile apps with PhonegapMulti-platform Mobile apps with Phonegap
Multi-platform Mobile apps with Phonegap
Gautam Chaudhary
 
Smartphone trends
Smartphone trendsSmartphone trends
Smartphone trends
Mohammed Elsammak, MBA
 
Building Mobile Application Using PhoneGap
Building Mobile Application Using PhoneGapBuilding Mobile Application Using PhoneGap
Building Mobile Application Using PhoneGap
Rajashekar Bhagavatula
 
iOS Development - A Beginner Guide
iOS Development - A Beginner GuideiOS Development - A Beginner Guide
iOS Development - A Beginner Guide
Andri Yadi
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android Programming
'Zamin Mammadov
 

Similar to A Journey From Callback Hell To Kotlin Coroutines (20)

Introduction To Kotlin - Google Official Programming Language
Introduction To Kotlin - Google Official Programming LanguageIntroduction To Kotlin - Google Official Programming Language
Introduction To Kotlin - Google Official Programming Language
 
Types Of Kotlin App Development Services
Types Of Kotlin App Development ServicesTypes Of Kotlin App Development Services
Types Of Kotlin App Development Services
 
Building Hybrid Apps with AngularJS and Ionic
Building Hybrid Apps with AngularJS and IonicBuilding Hybrid Apps with AngularJS and Ionic
Building Hybrid Apps with AngularJS and Ionic
 
Flutter session 01
Flutter session 01Flutter session 01
Flutter session 01
 
Civi mobile & CiviSync Mobile
Civi mobile & CiviSync MobileCivi mobile & CiviSync Mobile
Civi mobile & CiviSync Mobile
 
Introduction to Mobile Application Development on Android
Introduction to Mobile Application Development on AndroidIntroduction to Mobile Application Development on Android
Introduction to Mobile Application Development on Android
 
Android Training Course In Chandigarh
Android Training Course In ChandigarhAndroid Training Course In Chandigarh
Android Training Course In Chandigarh
 
Simon Bates, Manifesto Digital - Mobile Application Development: Past, Presen...
Simon Bates, Manifesto Digital - Mobile Application Development: Past, Presen...Simon Bates, Manifesto Digital - Mobile Application Development: Past, Presen...
Simon Bates, Manifesto Digital - Mobile Application Development: Past, Presen...
 
Cross-Platform App Development in C#
Cross-Platform App Development in C#Cross-Platform App Development in C#
Cross-Platform App Development in C#
 
Mobile Programming - 1 Introduction
Mobile Programming - 1 IntroductionMobile Programming - 1 Introduction
Mobile Programming - 1 Introduction
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Journey to become Android Developer - NgodingJeh! @STMIKCIC Cirebon - By: Riz...
Journey to become Android Developer - NgodingJeh! @STMIKCIC Cirebon - By: Riz...Journey to become Android Developer - NgodingJeh! @STMIKCIC Cirebon - By: Riz...
Journey to become Android Developer - NgodingJeh! @STMIKCIC Cirebon - By: Riz...
 
Android operating system by udayan thakurdesai
Android operating system by udayan thakurdesaiAndroid operating system by udayan thakurdesai
Android operating system by udayan thakurdesai
 
Android Development with Kotlin course
Android Development  with Kotlin courseAndroid Development  with Kotlin course
Android Development with Kotlin course
 
Android with kotlin course
Android with kotlin courseAndroid with kotlin course
Android with kotlin course
 
Multi-platform Mobile apps with Phonegap
Multi-platform Mobile apps with PhonegapMulti-platform Mobile apps with Phonegap
Multi-platform Mobile apps with Phonegap
 
Smartphone trends
Smartphone trendsSmartphone trends
Smartphone trends
 
Building Mobile Application Using PhoneGap
Building Mobile Application Using PhoneGapBuilding Mobile Application Using PhoneGap
Building Mobile Application Using PhoneGap
 
iOS Development - A Beginner Guide
iOS Development - A Beginner GuideiOS Development - A Beginner Guide
iOS Development - A Beginner Guide
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android Programming
 

More from Ahmed Nabil

What’s new in Kotlin 12-08-2023 Google IO Cairo 23
What’s new in Kotlin 12-08-2023 Google IO Cairo 23What’s new in Kotlin 12-08-2023 Google IO Cairo 23
What’s new in Kotlin 12-08-2023 Google IO Cairo 23
Ahmed Nabil
 
DroidConEgypt-21-10-2022-Coroutines-AhmedNabil.pdf
DroidConEgypt-21-10-2022-Coroutines-AhmedNabil.pdfDroidConEgypt-21-10-2022-Coroutines-AhmedNabil.pdf
DroidConEgypt-21-10-2022-Coroutines-AhmedNabil.pdf
Ahmed Nabil
 
Create Multiplatform Chat App with Compose and Ktor
Create Multiplatform Chat App with Compose and KtorCreate Multiplatform Chat App with Compose and Ktor
Create Multiplatform Chat App with Compose and Ktor
Ahmed Nabil
 
Kotlin mufix 31 10-2019 by Ahmed Nabil(AhmedNMahran)
Kotlin mufix 31 10-2019 by Ahmed Nabil(AhmedNMahran)Kotlin mufix 31 10-2019 by Ahmed Nabil(AhmedNMahran)
Kotlin mufix 31 10-2019 by Ahmed Nabil(AhmedNMahran)
Ahmed Nabil
 
What’s new in android o
What’s new in android oWhat’s new in android o
What’s new in android o
Ahmed Nabil
 
Kotlin for android
Kotlin for androidKotlin for android
Kotlin for android
Ahmed Nabil
 

More from Ahmed Nabil (6)

What’s new in Kotlin 12-08-2023 Google IO Cairo 23
What’s new in Kotlin 12-08-2023 Google IO Cairo 23What’s new in Kotlin 12-08-2023 Google IO Cairo 23
What’s new in Kotlin 12-08-2023 Google IO Cairo 23
 
DroidConEgypt-21-10-2022-Coroutines-AhmedNabil.pdf
DroidConEgypt-21-10-2022-Coroutines-AhmedNabil.pdfDroidConEgypt-21-10-2022-Coroutines-AhmedNabil.pdf
DroidConEgypt-21-10-2022-Coroutines-AhmedNabil.pdf
 
Create Multiplatform Chat App with Compose and Ktor
Create Multiplatform Chat App with Compose and KtorCreate Multiplatform Chat App with Compose and Ktor
Create Multiplatform Chat App with Compose and Ktor
 
Kotlin mufix 31 10-2019 by Ahmed Nabil(AhmedNMahran)
Kotlin mufix 31 10-2019 by Ahmed Nabil(AhmedNMahran)Kotlin mufix 31 10-2019 by Ahmed Nabil(AhmedNMahran)
Kotlin mufix 31 10-2019 by Ahmed Nabil(AhmedNMahran)
 
What’s new in android o
What’s new in android oWhat’s new in android o
What’s new in android o
 
Kotlin for android
Kotlin for androidKotlin for android
Kotlin for android
 

Recently uploaded

GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 

Recently uploaded (20)

GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 

A Journey From Callback Hell To Kotlin Coroutines