SlideShare a Scribd company logo
1 of 38
Modern Programming
Languages - Overview
Ayman Mahfouz
July 2018
With Kotlin as an Example
Biography
- VP of Engineering at Webalo (webalo.com)
- Los Angeles based
- Branch in Alexandria
- UX4IIoT
- 20+ years of software development
- PhD. in software engineering
- BSc. Computer Science - Alexandria 1997
Programming Languages
Pascal C C++
Java
Python C# Objective-C ActionScript
Scala Ruby Octave
JavaScript
Go TypeScript Kotlin
BASIC
Swift Groovy
Why Many Languages Exist?
Optimized for different objectives
● Productivity
● Readability
● Portability
● Performance
○ Compile-time
○ Runtime
Some Notable Languages
Released By Notes
Groovy 2007 Pivotal Concise, easy-to learn, Java-interoperable, scripting
language for the JVM.
Go 2009 Google High-speed compilation compared to C , built-in
support for concurrency.
Swift 2014 Apple Many safety and syntax improvements to replace
Objective-C.
Kotlin 2016 JetBrains Designed to be “better than Java” - Interoperable for
incremental migration.
Kotlin Arrives!
● Paid little attention until Google I/O announcement.
● Android Studio Canary 3.
● Immediately fell in love
○ Strong Typing
○ Brevity
○ Expressiveness
○ Interoperability
○ Growing support
● Starts from where others ended (Java, Python, Go, Swift)
● One app built on github.
● Still learning.
Brevity
Null Safety
Conditionals
Smart Cast
Lambdas
Collections
Features we will go through:
Brevity
In Java, one would normally write this:
With my background, I translated this into Kotlin verbatim:
Not idiomatic but still
shorter! Can you spot
the omissions?
● No ;
● No “new”
● “override” is a modifier
● “:” not “implements”
● “public” is default
● Return type
In Java one would typically write code like this:
Brevity
Using “Single Expression Function” syntax
Pass a lambda expression to a function that accepts a single-method interface
Brevity
Omit parameter type
Omit parameter name as well
Eliminate left hand side completely
Lambda expression only argument so we can eliminate the parenthesis
Omit parameter type
Brevity - From Java to Kotlin
to Kotlin ...
From Java ...
We will go through:
Brevity
Null Safety
Conditionals
Smart Cast
Lambdas
Collections
Null Safety - Explicit handling
The dreaded NPE
Handle explicitly
Null Safety - Java Optionals
Handle via Java 8 Optionals - very verbose!
Handle by convention:
- Special member naming (IfAny)
- Null checks in constructor
- Hand-coded
- Annotations
- Aspects
Or let it throw! (pun intended)
Null Safety - Safe Navigation
Kotlin safe navigation operator
Compile-time language-enforced null safety
Forced init
Force null guard
Allowing late init
Conscious NPE
We will go through:
Brevity
Null Safety
Conditionals
Smart Cast
Lambdas
Collections
Conditionals
I cringe when I see if statements that look like this
Use the ternary operator please!
Conditionals - Expressions
In Kotlin, if statement is an expression
Combined with single expression function shorthand
So you can write a function like this
Conditionals - when
I hate “Switch” statements!
But I love “when” expressions!
1. No annoying “break” or even “case”
2. Match against any type
3. Switch variable can be of any type
4. The “else” section is mandatory
We will go through:
Brevity
Null Safety
Conditionals
Smart Cast
Lambdas
Collections
Smart Cast
In Java explicit cast is needed
In Kotlin Smart Cast takes place automatically
Smart Cast
In Java
Smart Cast
In Kotlin
Smart Cast - Nullables
Automatic cast to non-null
We will go through:
Brevity
Null Safety
Conditionals
Smart Cast
Lambdas
Collections
Lambdas
Think of it as a “function literal”
The function “Array” produces an array by applying a lambda
Lambdas - Higher-order Functions
Higher-order functions: functions that take other functions as arguments
Lambdas - Closures
Closures: lambdas can access variables in their outer scope
We will go through:
Brevity
Null Safety
Conditionals
Smart Cast
Lambdas
Collections
Collections
With Lambdas
it
Collections - Streaming
Chaining lambda operations
Collections - Immutability
In Java both mutable and immutable collections implement the same interface
Kotlin uses different interfaces - Compile error
What about the others?
● Brevity
○ No semicolons
○ Optional “return”
○ Variable types
○ Omit parens in a call
○ Default imports
● Null Safety
● Closures
● Most of other Kotlin features
● And more
○ Parameterized Strings
Groovy
def list = [1, 2, 3]
list.each { println it }
person?.address.?city
def name = ‘World’
println “Hello $name!”
Swift
● Brevity
○ No semicolons
○ Implicit variable types
● Null Safety
● Closures
● Ranges
● Switch
○ Any type
○ Not just equality
○ No fallthrough
● Other
○ Parameterized Strings
○ Dynamic Extension
for i in 0..3 { println(“i”) }
extension Double {
c2f -> Double() {
return self * 9 / 5 + 32
}
}
…
let c = 100.0
print(c.c2f())
result, error := callSomeFunction()
Go
● Brevity
○ No semicolons
○ Implicit variable types
○ (But must use braces sometimes)
● Null Safety
● Switch
○ Non-constants
○ (But same type)
● Closures
● Multiple return values
● Missing some features
○ e.g. Inheritance
if i % 2 == 0 {
// even
} else {
// odd
}
Comparison Matrix
JVM GC Classes No ; Type
Inference
Safe
Null
If Expr Rich
Switch
Closure Variable
Arguments
Collection
Streaming
Dynamic
Extension
Tuples
Kotlin
✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
Groovy
✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
Swift
✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
Go
✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
Thank You!
Ayman Mahfouz
amahfouz@gmail.com
www.linkedin.com/in/amahfouz/
amahfouz.wordpress.com
github.com/amahfouz
amahfouz.com
AymanMahfouz.com

More Related Content

What's hot

Steps for c program execution
Steps for c program executionSteps for c program execution
Steps for c program executionRumman Ansari
 
Programming Fundamentals lecture 2
Programming Fundamentals lecture 2Programming Fundamentals lecture 2
Programming Fundamentals lecture 2REHAN IJAZ
 
PYTHON FEATURES.pptx
PYTHON FEATURES.pptxPYTHON FEATURES.pptx
PYTHON FEATURES.pptxMaheShiva
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in JavaJin Castor
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating SystemsMukesh Chinta
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexityAnaya Zafar
 
Functions Of Operating System
Functions Of Operating SystemFunctions Of Operating System
Functions Of Operating SystemDr.Suresh Isave
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonManishJha237
 
C Programming Language Detailed Notes with Solved program
 C Programming Language Detailed Notes with Solved program C Programming Language Detailed Notes with Solved program
C Programming Language Detailed Notes with Solved programNikhilGhodse
 
Operating Systems Basics
Operating Systems BasicsOperating Systems Basics
Operating Systems Basicsnishantsri
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languageseducationfront
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process ConceptsMukesh Chinta
 
Operating systems Basics
Operating systems BasicsOperating systems Basics
Operating systems BasicsSherif Mousa
 

What's hot (20)

Steps for c program execution
Steps for c program executionSteps for c program execution
Steps for c program execution
 
Computer Programming - Lecture 2
Computer Programming - Lecture 2Computer Programming - Lecture 2
Computer Programming - Lecture 2
 
Programming Fundamentals lecture 2
Programming Fundamentals lecture 2Programming Fundamentals lecture 2
Programming Fundamentals lecture 2
 
Data representation in computers
Data representation in computersData representation in computers
Data representation in computers
 
PYTHON FEATURES.pptx
PYTHON FEATURES.pptxPYTHON FEATURES.pptx
PYTHON FEATURES.pptx
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating Systems
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexity
 
Functions Of Operating System
Functions Of Operating SystemFunctions Of Operating System
Functions Of Operating System
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
System software
System softwareSystem software
System software
 
C Programming Language Detailed Notes with Solved program
 C Programming Language Detailed Notes with Solved program C Programming Language Detailed Notes with Solved program
C Programming Language Detailed Notes with Solved program
 
Operating Systems Basics
Operating Systems BasicsOperating Systems Basics
Operating Systems Basics
 
Lesson 2 History Of Operating System
Lesson 2 History Of Operating SystemLesson 2 History Of Operating System
Lesson 2 History Of Operating System
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languages
 
C Programming Unit-5
C Programming Unit-5C Programming Unit-5
C Programming Unit-5
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
Operating systems Basics
Operating systems BasicsOperating systems Basics
Operating systems Basics
 

Similar to Modern Programming Languages - An overview

Gdg dev fest 2107 to kotlin, with love
Gdg dev fest 2107   to kotlin, with loveGdg dev fest 2107   to kotlin, with love
Gdg dev fest 2107 to kotlin, with loveAyman Mahfouz
 
Exploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App developmentExploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App developmentJayaprakash R
 
New c sharp4_features_part_iv
New c sharp4_features_part_ivNew c sharp4_features_part_iv
New c sharp4_features_part_ivNico Ludwig
 
What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)Moaid Hathot
 
Kotlin what_you_need_to_know-converted event 4 with nigerians
Kotlin  what_you_need_to_know-converted event 4 with nigeriansKotlin  what_you_need_to_know-converted event 4 with nigerians
Kotlin what_you_need_to_know-converted event 4 with nigeriansjunaidhasan17
 
Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional waynluaces
 
Partial Continuations, Lessons From JavaScript and Guile in 2012 (Quasiconf 2...
Partial Continuations, Lessons From JavaScript and Guile in 2012 (Quasiconf 2...Partial Continuations, Lessons From JavaScript and Guile in 2012 (Quasiconf 2...
Partial Continuations, Lessons From JavaScript and Guile in 2012 (Quasiconf 2...Igalia
 
Power Up Your Build - Omer van Kloeten @ Wix 2018-04
Power Up Your Build - Omer van Kloeten @ Wix 2018-04Power Up Your Build - Omer van Kloeten @ Wix 2018-04
Power Up Your Build - Omer van Kloeten @ Wix 2018-04Omer van Kloeten
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developersMohamed Wael
 
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)PROIDEA
 
Kotlin & Arrow the functional way
Kotlin & Arrow the functional wayKotlin & Arrow the functional way
Kotlin & Arrow the functional wayThoughtworks
 
Grooming with Groovy
Grooming with GroovyGrooming with Groovy
Grooming with GroovyDhaval Dalal
 
New c sharp4_features_part_vi
New c sharp4_features_part_viNew c sharp4_features_part_vi
New c sharp4_features_part_viNico Ludwig
 

Similar to Modern Programming Languages - An overview (20)

Gdg dev fest 2107 to kotlin, with love
Gdg dev fest 2107   to kotlin, with loveGdg dev fest 2107   to kotlin, with love
Gdg dev fest 2107 to kotlin, with love
 
Exploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App developmentExploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App development
 
New c sharp4_features_part_iv
New c sharp4_features_part_ivNew c sharp4_features_part_iv
New c sharp4_features_part_iv
 
What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)
 
Intro to kotlin
Intro to kotlinIntro to kotlin
Intro to kotlin
 
Start with swift
Start with swiftStart with swift
Start with swift
 
Kotlin what_you_need_to_know-converted event 4 with nigerians
Kotlin  what_you_need_to_know-converted event 4 with nigeriansKotlin  what_you_need_to_know-converted event 4 with nigerians
Kotlin what_you_need_to_know-converted event 4 with nigerians
 
What`s New in Java 8
What`s New in Java 8What`s New in Java 8
What`s New in Java 8
 
Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional way
 
Partial Continuations, Lessons From JavaScript and Guile in 2012 (Quasiconf 2...
Partial Continuations, Lessons From JavaScript and Guile in 2012 (Quasiconf 2...Partial Continuations, Lessons From JavaScript and Guile in 2012 (Quasiconf 2...
Partial Continuations, Lessons From JavaScript and Guile in 2012 (Quasiconf 2...
 
Power Up Your Build - Omer van Kloeten @ Wix 2018-04
Power Up Your Build - Omer van Kloeten @ Wix 2018-04Power Up Your Build - Omer van Kloeten @ Wix 2018-04
Power Up Your Build - Omer van Kloeten @ Wix 2018-04
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
 
Kotlin from-scratch
Kotlin from-scratchKotlin from-scratch
Kotlin from-scratch
 
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
 
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor BuzatovićJavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
 
Kotlin & Arrow the functional way
Kotlin & Arrow the functional wayKotlin & Arrow the functional way
Kotlin & Arrow the functional way
 
Preparing for Scala 3
Preparing for Scala 3Preparing for Scala 3
Preparing for Scala 3
 
Grooming with Groovy
Grooming with GroovyGrooming with Groovy
Grooming with Groovy
 
New c sharp4_features_part_vi
New c sharp4_features_part_viNew c sharp4_features_part_vi
New c sharp4_features_part_vi
 
From Java to Kotlin
From Java to KotlinFrom Java to Kotlin
From Java to Kotlin
 

More from Ayman Mahfouz

Integrating Gmail with issue tracking 2018
Integrating Gmail with issue tracking 2018Integrating Gmail with issue tracking 2018
Integrating Gmail with issue tracking 2018Ayman Mahfouz
 
Career Day - Software Engineer
Career Day - Software EngineerCareer Day - Software Engineer
Career Day - Software EngineerAyman Mahfouz
 
Gdg dev fest hybrid apps your own mini-cordova
Gdg dev fest hybrid apps  your own mini-cordovaGdg dev fest hybrid apps  your own mini-cordova
Gdg dev fest hybrid apps your own mini-cordovaAyman Mahfouz
 
Hybrid apps - Your own mini Cordova
Hybrid apps - Your own mini CordovaHybrid apps - Your own mini Cordova
Hybrid apps - Your own mini CordovaAyman Mahfouz
 
Hybrid apps: Java conversing with JavaScript
Hybrid apps: Java  conversing with  JavaScriptHybrid apps: Java  conversing with  JavaScript
Hybrid apps: Java conversing with JavaScriptAyman Mahfouz
 
Bazillion New Technologies
Bazillion New TechnologiesBazillion New Technologies
Bazillion New TechnologiesAyman Mahfouz
 
Self-service Enterprise Mobility
Self-service Enterprise MobilitySelf-service Enterprise Mobility
Self-service Enterprise MobilityAyman Mahfouz
 
Working Abroad: Bridging the Culture Gap
Working Abroad: Bridging the Culture GapWorking Abroad: Bridging the Culture Gap
Working Abroad: Bridging the Culture GapAyman Mahfouz
 

More from Ayman Mahfouz (8)

Integrating Gmail with issue tracking 2018
Integrating Gmail with issue tracking 2018Integrating Gmail with issue tracking 2018
Integrating Gmail with issue tracking 2018
 
Career Day - Software Engineer
Career Day - Software EngineerCareer Day - Software Engineer
Career Day - Software Engineer
 
Gdg dev fest hybrid apps your own mini-cordova
Gdg dev fest hybrid apps  your own mini-cordovaGdg dev fest hybrid apps  your own mini-cordova
Gdg dev fest hybrid apps your own mini-cordova
 
Hybrid apps - Your own mini Cordova
Hybrid apps - Your own mini CordovaHybrid apps - Your own mini Cordova
Hybrid apps - Your own mini Cordova
 
Hybrid apps: Java conversing with JavaScript
Hybrid apps: Java  conversing with  JavaScriptHybrid apps: Java  conversing with  JavaScript
Hybrid apps: Java conversing with JavaScript
 
Bazillion New Technologies
Bazillion New TechnologiesBazillion New Technologies
Bazillion New Technologies
 
Self-service Enterprise Mobility
Self-service Enterprise MobilitySelf-service Enterprise Mobility
Self-service Enterprise Mobility
 
Working Abroad: Bridging the Culture Gap
Working Abroad: Bridging the Culture GapWorking Abroad: Bridging the Culture Gap
Working Abroad: Bridging the Culture Gap
 

Recently uploaded

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 

Recently uploaded (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 

Modern Programming Languages - An overview

  • 1. Modern Programming Languages - Overview Ayman Mahfouz July 2018 With Kotlin as an Example
  • 2. Biography - VP of Engineering at Webalo (webalo.com) - Los Angeles based - Branch in Alexandria - UX4IIoT - 20+ years of software development - PhD. in software engineering - BSc. Computer Science - Alexandria 1997
  • 3. Programming Languages Pascal C C++ Java Python C# Objective-C ActionScript Scala Ruby Octave JavaScript Go TypeScript Kotlin BASIC Swift Groovy
  • 4. Why Many Languages Exist? Optimized for different objectives ● Productivity ● Readability ● Portability ● Performance ○ Compile-time ○ Runtime
  • 5. Some Notable Languages Released By Notes Groovy 2007 Pivotal Concise, easy-to learn, Java-interoperable, scripting language for the JVM. Go 2009 Google High-speed compilation compared to C , built-in support for concurrency. Swift 2014 Apple Many safety and syntax improvements to replace Objective-C. Kotlin 2016 JetBrains Designed to be “better than Java” - Interoperable for incremental migration.
  • 6. Kotlin Arrives! ● Paid little attention until Google I/O announcement. ● Android Studio Canary 3. ● Immediately fell in love ○ Strong Typing ○ Brevity ○ Expressiveness ○ Interoperability ○ Growing support ● Starts from where others ended (Java, Python, Go, Swift) ● One app built on github. ● Still learning.
  • 8. Brevity In Java, one would normally write this: With my background, I translated this into Kotlin verbatim: Not idiomatic but still shorter! Can you spot the omissions? ● No ; ● No “new” ● “override” is a modifier ● “:” not “implements” ● “public” is default ● Return type In Java one would typically write code like this:
  • 9. Brevity Using “Single Expression Function” syntax Pass a lambda expression to a function that accepts a single-method interface
  • 10. Brevity Omit parameter type Omit parameter name as well Eliminate left hand side completely Lambda expression only argument so we can eliminate the parenthesis Omit parameter type
  • 11. Brevity - From Java to Kotlin to Kotlin ... From Java ...
  • 12. We will go through: Brevity Null Safety Conditionals Smart Cast Lambdas Collections
  • 13. Null Safety - Explicit handling The dreaded NPE Handle explicitly
  • 14. Null Safety - Java Optionals Handle via Java 8 Optionals - very verbose! Handle by convention: - Special member naming (IfAny) - Null checks in constructor - Hand-coded - Annotations - Aspects Or let it throw! (pun intended)
  • 15. Null Safety - Safe Navigation Kotlin safe navigation operator Compile-time language-enforced null safety Forced init Force null guard Allowing late init Conscious NPE
  • 16. We will go through: Brevity Null Safety Conditionals Smart Cast Lambdas Collections
  • 17. Conditionals I cringe when I see if statements that look like this Use the ternary operator please!
  • 18. Conditionals - Expressions In Kotlin, if statement is an expression Combined with single expression function shorthand So you can write a function like this
  • 19. Conditionals - when I hate “Switch” statements! But I love “when” expressions! 1. No annoying “break” or even “case” 2. Match against any type 3. Switch variable can be of any type 4. The “else” section is mandatory
  • 20. We will go through: Brevity Null Safety Conditionals Smart Cast Lambdas Collections
  • 21. Smart Cast In Java explicit cast is needed In Kotlin Smart Cast takes place automatically
  • 24. Smart Cast - Nullables Automatic cast to non-null
  • 25. We will go through: Brevity Null Safety Conditionals Smart Cast Lambdas Collections
  • 26. Lambdas Think of it as a “function literal” The function “Array” produces an array by applying a lambda
  • 27. Lambdas - Higher-order Functions Higher-order functions: functions that take other functions as arguments
  • 28. Lambdas - Closures Closures: lambdas can access variables in their outer scope
  • 29. We will go through: Brevity Null Safety Conditionals Smart Cast Lambdas Collections
  • 31. Collections - Streaming Chaining lambda operations
  • 32. Collections - Immutability In Java both mutable and immutable collections implement the same interface Kotlin uses different interfaces - Compile error
  • 33. What about the others?
  • 34. ● Brevity ○ No semicolons ○ Optional “return” ○ Variable types ○ Omit parens in a call ○ Default imports ● Null Safety ● Closures ● Most of other Kotlin features ● And more ○ Parameterized Strings Groovy def list = [1, 2, 3] list.each { println it } person?.address.?city def name = ‘World’ println “Hello $name!”
  • 35. Swift ● Brevity ○ No semicolons ○ Implicit variable types ● Null Safety ● Closures ● Ranges ● Switch ○ Any type ○ Not just equality ○ No fallthrough ● Other ○ Parameterized Strings ○ Dynamic Extension for i in 0..3 { println(“i”) } extension Double { c2f -> Double() { return self * 9 / 5 + 32 } } … let c = 100.0 print(c.c2f())
  • 36. result, error := callSomeFunction() Go ● Brevity ○ No semicolons ○ Implicit variable types ○ (But must use braces sometimes) ● Null Safety ● Switch ○ Non-constants ○ (But same type) ● Closures ● Multiple return values ● Missing some features ○ e.g. Inheritance if i % 2 == 0 { // even } else { // odd }
  • 37. Comparison Matrix JVM GC Classes No ; Type Inference Safe Null If Expr Rich Switch Closure Variable Arguments Collection Streaming Dynamic Extension Tuples Kotlin ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ Groovy ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ Swift ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ Go ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓