Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Swift - Pushing technology limits
Search
Konstantin
April 30, 2015
Programming
340
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Swift - Pushing technology limits
Why Swift is Awesome!!!
Konstantin
April 30, 2015
Transcript
37 slides
Kostiantyn Koval 1 Rocketfarm.no
Swift - Pushing technology limits
How should look Modern Language?
Clean and Clear
Programs must be written for people to read, and only
incidentally for machines to execute 1 Harold Abelson
.global _start .text _start: # write(1, message, 13) mov $1,
%rax mov $1, %rdi mov $message, %rsi mov $13, %rdx syscall message: .ascii "Hello, world\n" mov rax, 1 mov rdi, 1 mov rsi, message mov rdx, 13 syscall
None
int compare(const void * a, const void * b) {
if ( *(uint32_t*)a < *(uint32_t*)b ) { return -1; } if ( *(uint32_t*)a > *(uint32_t*)b ) { return 1; } return 0; }
!
@interface Person : NSObject @property (nonatomic) NSString* name; @property (nonatomic)
NSInteger age; @end @implementation Person - (instancetype)initWith:(NSString *)name age:(NSInteger)age { self = [super init]; if (self) return nil; _name = name; _age = age; return self; } @end @implementation TestPerson - (void)test { NSArray *people = @[ [[Person alloc] initWith:@"Sam" age:10], [[Person alloc] initWith:@"Sara" age:24], [[Person alloc] initWith:@"Ola" age:42], [[Person alloc] initWith:@"Jon" age:19]]; NSArray *kids = [people filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"age < 18"]]; NSMutableArray *names = [NSMutableArray new]; for (Person *person in people) { [names addObject:person.name.lowercaseString]; } } @end
!
struct Person { let name: String let age: Int }
let people = [ Person(name: "Sam", age: 10), Person(name: "Sara", age: 24), Person(name: "Ola", age: 42), Person(name: "Jon", age: 19)] let kids = people.filter { person in person.age < 18 } let names = people.map { $0.name.lowercaseString }
!
60% Less Code 13 Lines Vs 34 Lines
Less Code Less Bugs Less money
Type inference var age = 19 var name = "Sara"
var isEmpty = name.isEmpty VS var age: Int = 19 var name: String = "Sara" var isEmpty: Bool = name.isEmpty
No Semicolons ; var age = 19
Other 4 Closures 4 Default initializers 4 Default parameters 4
Subscripts 4 Operators
//Closures let numbers = [1, 2, 3, 4] numbers.map {$0
+ 10} // Subscripts let num2 = numbers[2] //Operators infix operator <<< { } func <<< (a: Vector, b: Vector) -> Vector { return Vector(x: a.x + b.x, y: a.y + b.y) }
Smart
Features Rich
Features Reach 4 Functional Programming 4 OOP 4 Generic Purpose
4 Value types 4 Tuples 4 Optionals 4 ...
Safe
Safe 4 Types 4 Type casting 4 tUpos 4 Existing
Methods 4 Correct instructions - Exception
None
Error Handling func readFromFile(file: String) -> (result: String?, error: NSError?)
{ return ("file Content", nil) } let result = readFromFile("file.txt") if result.error != nil { println("handle error") }
Optionals
Optionals 4 Represent absence of a value 4 Safe Nil
handling [NullPointerException] 4 Nil value for Value type, Int: 0, -1, NSnotFound, IntMax
'?' Type String != String? Int != Int? func person(name:
String) -> Person func person(name: String, age: Int?) -> Person person("Elvis", age: nil) person(nil, age: 27) //Error
Optionals Is a Box that could store a value inside
or could be empty You can interact with the value only throw Box API
Safe var person: Person? = people.find("Elvis") // 1 - Unwrapping
`!` if person != nil { println("found \(person!)") } //2 - Optional binding if let person = person { println("found \(person)") } else { println("found found") }
Multithreading
Multithreading 4 Immutable value type 4 explicit 'self' capturing processAsync(var
people: [Peope]) -> [Peope] { // ... Run Async people.remove(...) return people } var people: [People] //Async code processAsync(people) processAsync(people) processAsync(people)
Fast
Fast 18 Times > Objetive-C 2,9 Times > C
Let's make better mistakes tomorrow
Thanks! QA?? ! Twitter - @KostiaKoval GitHub - /KostiaKoval Kostiantyn
Koval - Rocketfarm.no
More Decks by Konstantin
See All by Konstantin
How does complier see your app
konstantinkoval
3
210
Swift Package Manager
konstantinkoval
2
240
Swift rEvolution
konstantinkoval
1
280
Refactoring an Ugly Objective-C with Swift
konstantinkoval
0
280
React Native - from a mobile (iOS) developer prospective
konstantinkoval
0
100
WatchKit
konstantinkoval
0
120
Intro in WatchKit and Watch apps
konstantinkoval
0
120
Functional Swift
konstantinkoval
1
180
I love swift.pdf
konstantinkoval
1
240
Other Decks in Programming
See All in Programming
LambdaなのにVM?Lambda MicroVMsを調べてみた / About Lambda Micro VMs
ak2ie
2
110
テスト駆動開発から学ぶ 達人プログラマーの型 / TechRAMEN 2026 Conference
a_okui
0
3.2k
止まらない比較を止める — 余帰納法で無限ストリームを比べる
tarao
0
220
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
240
Promiseの向こう側へコンテキストを届ける ― proposal-async-context
seriseri
0
1.1k
Distance field of Julia set
kinakomoti321
0
340
Beyond Chatbots: Agentic UI with Open Standards @W-JAX 2026, München
manfredsteyer
PRO
0
130
AI駆動TDD ― 2026年10月版
hrmstrsmgs
0
120
Crash Auto Pipelines
veronikapj
1
460
高速開発を止めずに 性能を上げる Flyleのシステム刷新と改善の歴史
azihsoyn
0
110
ローカルLLMの基本と近況 2611 / Local LLM basics and recent situation 2611
kishida
3
680
はじめてのPLATEAU
nokonoko1203
1
680
Featured
See All Featured
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
850
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.3k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
61k
Chasing Engaging Ingredients in Design
codingconduct
0
410
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.5k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.3k
Heart Work Chapter 1 - Part 1
lfama
PRO
11
37k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.7k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
580
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
570
Docker and Python
trallard
47
4.3k