Server Side Swift
Hüseyin APTİOĞLU | Software Infrastructure
Agenda
• Crash-Course Swift
• Swift Package Manager
• Server Side
• Benchmarking
Swift
• 1940s -> 9 programming languages
• 1950s -> 58 programming languages
• Fortran (concept)
• Fortran II
• Lisp
• …
•...
Swift
• 1990s -> 292 programming languages
• Python
• Java
• Ruby
• Visual Basic
• Delphi
• ….
• 2000s -> 339 programming ...
Swift
• 355. Swift
• v1.0 in September 2014
• Opened in Dec 2015
• v2.2 first ver. in the Open
• v3.0.1
Swift Tour
Mutable
Variables
Immutable
Swift Tour
Mutable
Type Inference
Immutable
Swift Tour
Optionals
Swift Tour
Function parameter names
Swift Tour
Guard Statement
Swift Tour
Closures
Swift Tour
Tuples
Swift Tour
Extensions
Swift Tour
and more …
• Enumerations
• Inheritance
• Initialization
• Error Handling
• Type Casting
• Generics
• Access Co...
Swift
Why is Swift a good choice for server-side ?
• Fast
• Modern
• Safe
• Interactive
• Open Source
• Apple
Server-side App Trade Off
Why is Swift a good choice for server-side ?AppPerformance
Developer Productivity
C
C++
Obj.C
Ja...
ARC
Automatic Reference Counting (ARC)
Swift manages the memory for you, but unlike many other high level
languages, it do...
Automatic Reference Counting (ARC)
LLVM
LLVM is actually an umbrella project that includes a variety of compilers and low
level tools
In short, LLVM compiles...
SPM
Swift Package Manager
• Part of Swift 3
• Init project
• Generate Xcode Proj
• Resolve dependencies
The Swift Package ...
Swift
• Swift is easier to read
• Swift is easier to maintain
• Swift is safe
• Swift is unified with memory management
• ...
Swift
Swift vs Java
Swift version 3.0-dev (LLVM 491f98861f, Clang 2ff6ce54d0, Swift fd4bd4c965)
swift-DEVELOPMENT-SNAPSHOT...
II. Most Loved
GitHub - apple/swift
Server Side Swift
open-source
Officially, only Linux is supported
open-source
Unofficially
Swift on Android
Install swift to linux
• Install required dependencies
$ sudo apt-get install clang libicu-dev
• Download the latest swift...
Swift Scripts
#!/usr/bin/env swift
let fruits = ["Banana", "Mango", "Apple", "Orange"]
let sortedFruits = fruits.sorted{$0...
Creating an Executable
Contents of file hello.swift
println("Hello world")
$ swiftc hello.swift
$ ./hello Hello world
Web Frameworks
• Perfect (9871)
• Vapor (7786)
• IBM Kitura (5002)
• Swifton (2042)
• Swifter (1852)
• Zewo (1502)
• …
• ....
Perfect 2.0
Vapor
Kitura
Benchmarking
wrk -d 10m -t 4 -c 20 http://10.0.1.11:(PORT)/blog
Benchmarking
wrk -d 10m -t 4 -c 20 http://10.0.1.11:(PORT)/json
Ready for Production?
Not Yet !!!
- Web frameworks < 1 year
- Server = Maturity
IBTECH
Próxima SlideShare
Cargando en…5
×

Server Side Swift

253 visualizaciones

Publicado el

SMG Internal Presentation

Publicado en: Software
0 comentarios
1 recomendación
Estadísticas
Notas
  • Sé el primero en comentar

Sin descargas
Visualizaciones
Visualizaciones totales
253
En SlideShare
0
De insertados
0
Número de insertados
1
Acciones
Compartido
0
Descargas
9
Comentarios
0
Recomendaciones
1
Insertados 0
No insertados

No hay notas en la diapositiva.

Server Side Swift

  1. 1. Server Side Swift Hüseyin APTİOĞLU | Software Infrastructure
  2. 2. Agenda • Crash-Course Swift • Swift Package Manager • Server Side • Benchmarking
  3. 3. Swift • 1940s -> 9 programming languages • 1950s -> 58 programming languages • Fortran (concept) • Fortran II • Lisp • … • 1960s -> 113 programming languages • Fortran IV • Basic • Cobol • … • 1970s -> 170 programming languages • Pascal • Smaltalk • C • …. • 1980s -> 231 programming languages • Turbo Pascal • Erlang • C ++ • Objective C • …. http://www.slideshare.net/GiordanoScalzo/the-joy-of-serverside-swift-development?qid=c2bc7c73-5bac-47e1-b834-45ac4b35edde&v=&b=&from_search=7
  4. 4. Swift • 1990s -> 292 programming languages • Python • Java • Ruby • Visual Basic • Delphi • …. • 2000s -> 339 programming languages • C# • Scala • Go • …. • 2010s -> 354 programming languages • Rust • Kotlin • Elm • …. http://www.slideshare.net/GiordanoScalzo/the-joy-of-serverside-swift-development?qid=c2bc7c73-5bac-47e1-b834-45ac4b35edde&v=&b=&from_search=7
  5. 5. Swift • 355. Swift • v1.0 in September 2014 • Opened in Dec 2015 • v2.2 first ver. in the Open • v3.0.1
  6. 6. Swift Tour Mutable Variables Immutable
  7. 7. Swift Tour Mutable Type Inference Immutable
  8. 8. Swift Tour Optionals
  9. 9. Swift Tour Function parameter names
  10. 10. Swift Tour Guard Statement
  11. 11. Swift Tour Closures
  12. 12. Swift Tour Tuples
  13. 13. Swift Tour Extensions
  14. 14. Swift Tour and more … • Enumerations • Inheritance • Initialization • Error Handling • Type Casting • Generics • Access Control • … • …
  15. 15. Swift Why is Swift a good choice for server-side ? • Fast • Modern • Safe • Interactive • Open Source • Apple
  16. 16. Server-side App Trade Off Why is Swift a good choice for server-side ?AppPerformance Developer Productivity C C++ Obj.C Java Perl JavaScript Python Ruby Lua Groovy
  17. 17. ARC Automatic Reference Counting (ARC) Swift manages the memory for you, but unlike many other high level languages, it doesn’t use a garbage collector to do this. - No periodically running - No pause - The CPU cycles for your own program
  18. 18. Automatic Reference Counting (ARC)
  19. 19. LLVM LLVM is actually an umbrella project that includes a variety of compilers and low level tools In short, LLVM compiles your code to a platform-neutral Intermediary Representation (IR), which can then be optimised and converted to the desired architecture. This allows all platform optimisation efforts to be concentrated in one place For Swift, Apple added a new layer to this architecture: the Swift Intermediate Language (SIL).
  20. 20. SPM Swift Package Manager • Part of Swift 3 • Init project • Generate Xcode Proj • Resolve dependencies The Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies. Package.swift
  21. 21. Swift • Swift is easier to read • Swift is easier to maintain • Swift is safe • Swift is unified with memory management • Swift requires less code Swift vs Objective-C
  22. 22. Swift Swift vs Java Swift version 3.0-dev (LLVM 491f98861f, Clang 2ff6ce54d0, Swift fd4bd4c965) swift-DEVELOPMENT-SNAPSHOT-2016-11-29-a-ubuntu16.04 Target: x86_64-unknown-linux-gnu java version "1.8.0_92" Java(TM) SE Runtime Environment (build 1.8.0_92-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode) https://benchmarksgame.alioth.debian.org/u64q/swift.html
  23. 23. II. Most Loved
  24. 24. GitHub - apple/swift
  25. 25. Server Side Swift
  26. 26. open-source Officially, only Linux is supported
  27. 27. open-source Unofficially
  28. 28. Swift on Android
  29. 29. Install swift to linux • Install required dependencies $ sudo apt-get install clang libicu-dev • Download the latest swift binary release from https://swift.org/download/#releases • Extract the archive $ tar xzf swift-<VERSION>-<PLATFORM>.tar.gz • Add the Swift toolchain to your path $ export PATH=/path/to/usr/bin:"${PATH}" • Test with REPL (Read Eval Print Loop)
  30. 30. Swift Scripts #!/usr/bin/env swift let fruits = ["Banana", "Mango", "Apple", "Orange"] let sortedFruits = fruits.sorted{$0 < $1} print(sortedFruits) chmod +x sort.swift ./sort.swift
  31. 31. Creating an Executable Contents of file hello.swift println("Hello world") $ swiftc hello.swift $ ./hello Hello world
  32. 32. Web Frameworks • Perfect (9871) • Vapor (7786) • IBM Kitura (5002) • Swifton (2042) • Swifter (1852) • Zewo (1502) • … • ... • ...
  33. 33. Perfect 2.0
  34. 34. Vapor
  35. 35. Kitura
  36. 36. Benchmarking wrk -d 10m -t 4 -c 20 http://10.0.1.11:(PORT)/blog
  37. 37. Benchmarking wrk -d 10m -t 4 -c 20 http://10.0.1.11:(PORT)/json
  38. 38. Ready for Production? Not Yet !!! - Web frameworks < 1 year - Server = Maturity
  39. 39. IBTECH

×