Programming Paradigms Which One Is The Best?
-
Upload
netguru -
Category
Technology
-
view
1.830 -
download
2
Transcript of Programming Paradigms Which One Is The Best?
![Page 1: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/1.jpg)
PROGRAMMING PARADIGMS
WHICH ONE IS THE BEST?
@akashivskyy
![Page 2: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/2.jpg)
PROGRAMMING PARADIGMS
![Page 3: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/3.jpg)
WAY OF LOOKING AT CONTROL FLOW AND
EXECUTION OF A PROGRAM
![Page 4: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/4.jpg)
1. OBJECT-ORIENTED PROGRAMMING
![Page 5: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/5.jpg)
PROGRAM IS DEFINED BY OBJECTS WHICH COMBINE
STATE AND BEHAVIOR
![Page 6: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/6.jpg)
3 ASSUMPTIONS
![Page 7: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/7.jpg)
1. ABSTRACTION 2. ENCAPSULATION
3. INHERITANCE
![Page 8: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/8.jpg)
protocol Shape ! var area: Double
"
func printShapeArea(shape: Shape) ! println("area = \(shape.area)")
"
![Page 9: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/9.jpg)
struct Square: Shape ! let side: Double
let area: Double ! return side # side " "
printShapeArea(Square(side: 4)) // 16.$
![Page 10: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/10.jpg)
struct Circle: Shape ! var radius: Double
var area: Double ! return M_PI # radius # radius " "
printShapeArea(Circle(radius: 2)) // 12.56
![Page 11: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/11.jpg)
struct Plane: Shape ! var area: Double ! return Double.infinity
" "
printShapeArea(Plane()) // infinity
![Page 12: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/12.jpg)
1. ABSTRACTION 2. ENCAPSULATION
3. INHERITANCE
![Page 13: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/13.jpg)
class EncryptionAssistant ! private var key = "42$mlg$crub"
public func encrypt(pass: String) -> String ! return rsaEncrypt(pass, key)
" "
![Page 14: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/14.jpg)
let assistant = EncryptionAssistant()
assistant.encrypt("secret") // 1Ll$$Myn4RtY
assistant.key // compile error!
![Page 15: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/15.jpg)
1. ABSTRACTION 2. ENCAPSULATION
3. INHERITANCE
![Page 16: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/16.jpg)
VEHICLE
RAILWAY ROAD
TRAM TRAIN BICYCLE CAR
![Page 17: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/17.jpg)
class Car ! var color: String = "red"
var name: String ! return "\(color) car"
" "
class BlueCar: Car ! override var color = "blue"
"
![Page 18: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/18.jpg)
Car().name // red car
BlueCar().name // blue car
![Page 19: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/19.jpg)
2. IMPERATIVE PROGRAMMING
![Page 20: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/20.jpg)
IMPERATIVE PHRASES WHICH CHANGE THE GLOBAL STATE OF
A PROGRAM
![Page 21: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/21.jpg)
let numbers = [1, 2, 3, 4, 5, 6]
var sum = $ var odds: [Int] = []
for number in numbers ! sum += number
if number % 2 == 1 ! odds.append(number)
" "
![Page 22: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/22.jpg)
getRemoteData("url", ! data, error in if error == nil ! parseData(data, ! parsed, error in if error == nil ! handleParsedData(parsed) " else ! displayError(error) " ") " else ! displayError(error) " ")
![Page 23: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/23.jpg)
IMPERATIVE PROGRAMMING IS
THE MOST POPULAR
![Page 24: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/24.jpg)
IMPERATIVE PROGRAMMING IS
THE EASIEST
![Page 25: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/25.jpg)
IMPERATIVE PROGRAMMING IS
THE WORST
![Page 26: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/26.jpg)
1. ERROR-PRONE 2. NOT SCALABLE
3. TOO COMPLICATED
![Page 27: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/27.jpg)
getRemoteData("example.com", ! data, error in if error == nil ! parseData(data, ! parsed, error in if error == nil ! handleParsedData(parsed) " else ! displayError(error) " ") " else ! displayError(error) " ")
![Page 28: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/28.jpg)
getRemoteData("example.com", ! data, error in if error == nil ! parseData(data, ! parsed, error in if error == nil ! if parsedDataValid(parsed) ! handleParsedData(parsed) " " else ! displayError(error) " ") " else ! displayError(error) " ")
![Page 29: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/29.jpg)
getRemoteData("example.com", ! data, error in if error == nil ! parseData(data, ! parsed, error in if error == nil ! if parsedDataValid(parsed) ! saveParsedDataInCache(parsed, ! error in if error == nil ! handleParsedData(parsed) " else ! displayError(error) " ") " " else ! displayError(error)
![Page 30: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/30.jpg)
getRemoteData("example.com", ! data, error in if error == nil ! parseData(data, ! parsed, error in if error == nil ! if parsedDataValid(parsed) ! saveParsedDataInCache(parsed, ! error in if error == nil ! handleParsedData(parsed, ! error in if error == nil ! displaySuccess() " else ! displayError(error) " ") " else !
![Page 31: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/31.jpg)
![Page 32: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/32.jpg)
3. DECLARATIVE PROGRAMMING
![Page 33: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/33.jpg)
DECLARE WHAT YOU’RE TRYING TO ACCOMPLISH, NOT
HOW TO DO IT
![Page 34: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/34.jpg)
let numbers = [1, 2, 3, 4, 5, 6]
var sum = $ var odds: [Int] = []
for number in numbers ! sum += number
if number % 2 == 1 ! odds.append(number)
" "
![Page 35: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/35.jpg)
var sum = $ var odds: [Int] = []
let numbers = [1, 2, 3, 4, 5, 6]
for number in numbers ! sum += number // reduction
if number % 2 == 1 ! // filtration odds.append(number)
" "
![Page 36: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/36.jpg)
let numbers = [1, 2, 3, 4, 5, 6]
let sum = reduce(numbers, $, ! memo, number in
return memo + number
") let odds = filter(numbers, ! number in
return number % 2 == 1
")
![Page 37: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/37.jpg)
let numbers = [1, 2, 3, 4, 5, 6]
let sum = reduce(numbers, $, +)
let odds = filter(numbers, ! $$ % 2 == 1 ")
![Page 38: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/38.jpg)
get
Rem
oteD
ata
("ex
ampl
e.co
m", !
data
, er
ror
in
if e
rror
== n
il !
pa
rseD
ata
(data
, !
pars
ed,
erro
r in
if e
rror
== n
il !
if p
ars
edData
Valid(
pars
ed) !
sa
vePa
rsed
Data
InCach
e(pa
rsed
, !
erro
r in
if e
rror
== n
il !
ha
ndle
Pars
edData
(pars
ed, !
erro
r in
if e
rror
== n
il !
di
spla
ySuc
cess
()
"
else
!
di
spla
yErr
or(e
rror
) "
")
"
else
!
di
spla
yErr
or(e
rror
) "
")
"
"
else
!
di
spla
yErr
or(e
rror
) "
")
"
else
!
di
spla
yErr
or(e
rror
) "
")
![Page 39: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/39.jpg)
PIPES
![Page 40: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/40.jpg)
DOWNLOAD PARSE SAVE IN CACHE DISPLAY
ERRORS
![Page 41: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/41.jpg)
DOWNLOAD PARSE SAVE IN CACHE DISPLAY
ERRORS
![Page 42: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/42.jpg)
DOWNLOAD PARSE SAVE IN CACHE DISPLAY
ERRORS
![Page 43: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/43.jpg)
getRemoteData("example.com")
.then(! data in parseData(data) ") .filter(! parsed in parsedDataValid(parsed) ") .then(! parsed in saveInCache(parsed) ") .then(! parsed in handleParsedData(parsed) ") .error(! error in displayError(error) ")
![Page 44: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/44.jpg)
getRemoteData("example.com")
.then(! data in parseData(data) ") .filter(! parsed in parsedDataValid(parsed) ") .filter(! parsed in !alreadyInCache(parsed) ") .then(! parsed in saveInCache(parsed) ") .then(! parsed in handleParsedData(parsed) ") .error(! error in displayError(error) ")
![Page 45: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/45.jpg)
getRemoteData("example.com")
.then(! data in parseData(data) ") .filter(! parsed in parsedDataValid(parsed) ") .filter(! parsed in !alreadyInCache(parsed) ") .then(! parsed in saveInCache(parsed) ") .then(! parsed in handleParsedData(parsed) ") .error(! error in displayError(error) ")
![Page 46: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/46.jpg)
DECLARATIVE PROGRAMMING IS
MUCH SIMPLER
![Page 47: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/47.jpg)
DECLARATIVE PROGRAMMING IS
MUCH SAFER
![Page 48: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/48.jpg)
DECLARATIVE PROGRAMMING IS MORE SCALABLE
![Page 49: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/49.jpg)
WHICH PARADIGM IS THE BEST?
![Page 50: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/50.jpg)
1. OBJECT-ORIENTED 2. IMPERATIVE
3. DECLARATIVE
![Page 51: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/51.jpg)
1. OBJECT-ORIENTED 2. IMPERATIVE
3. DECLARATIVE
![Page 52: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/52.jpg)
TOGETHER
![Page 53: Programming Paradigms Which One Is The Best?](https://reader030.fdocuments.in/reader030/viewer/2022032420/55a524b11a28abea0e8b45b2/html5/thumbnails/53.jpg)
THANK YOUADRIAN KASHIVSKYY
@akashivskyy github.com/akashivskyy/talks