to protect & to serve
TRANSCRIPT
![Page 1: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/1.jpg)
To Protect & To ServeJorge D. Ortiz-Fuentes
@jdortiz
![Page 2: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/2.jpg)
A Canonical Examples
production
#Swift3Arch
![Page 3: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/3.jpg)
Agenda
★Swift Backend
★DIY
★The Test App
![Page 4: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/4.jpg)
Swift Backend
![Page 5: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/5.jpg)
Disclaimer
Not a backend developer
![Page 6: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/6.jpg)
Then, Why?
![Page 7: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/7.jpg)
– Gustavo Adolfo Bécquer
“What is poetry? you ask, while fixing your blue pupil on mine.
What is poetry! And you are asking me? Poetry... is you.”
![Page 8: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/8.jpg)
And you are asking me?
No Refactoring
Compiler Segmentation Fault
Migrations
Moving targetNo examples
No reflection&introspection
Xcode
![Page 9: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/9.jpg)
Always Look at the Bright Side of Life
★Opportunity to learn
★ Linux
★Backend
★Swift Package Manager
![Page 10: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/10.jpg)
Does it mean that…
![Page 11: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/11.jpg)
NO
![Page 12: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/12.jpg)
Not ready for production yet
![Page 13: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/13.jpg)
Not ready for production yetSome Scenarios
![Page 14: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/14.jpg)
Just an Experiment?
![Page 15: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/15.jpg)
Kinda
![Page 16: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/16.jpg)
Useful Scenarios
★Training
★Prototyping
★Embedded devices
★Private servers
![Page 17: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/17.jpg)
Server Side Swift is an IDE
Immature Development Environment
![Page 18: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/18.jpg)
Swift Package Manager
★Promising… but not finished
★Not fully integrated with Xcode
★May not find a way to satisfy the dependencies
![Page 19: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/19.jpg)
I couldn’t make libdistpatch
😢
![Page 20: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/20.jpg)
I couldn’t make LLDB work
😢😢😢
Illegal instruction (core dumped)
![Page 21: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/21.jpg)
But there is hope
https://swift.org/server-apis/Saint Chris, Chapter 42 verse FF
![Page 22: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/22.jpg)
DIY
![Page 23: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/23.jpg)
The Tools
★Emacs (https://emacsformacosx.com/)
• Tramp (SSH)
• Swift-mode (2.2)
★ iTerm + tmux
★Google Chrome
![Page 24: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/24.jpg)
Frameworks
★Kitura
★Perfect
★Vapor
★Zewo
![Page 25: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/25.jpg)
Kitura
★Comes with everything and the kitchen sink
★Compiles flawlessly
★Good documentation and tutorials
★Failed to make libdispatch
for the Raspberry Pi
![Page 26: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/26.jpg)
Perfect★Also quite complete
★Excellent documentation & tutorials
★Doesn’t fully compile in Raspberry Pi 3: NetTCP.swift & NetTCPSSL.swift (solved)
★Slack channel
★Need more time
for the Raspberry Pi
![Page 27: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/27.jpg)
Vapor
★Worked without problems
★Abundant documentation and tutorials (vapor.university)
★ Less modular (HTTP server & router provided by Application class)
for the Raspberry Pi
![Page 28: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/28.jpg)
Zewo★More modular, from independent pieces
★Uses libmill/co-routines
★ Failed at compiling OpenSSL (Int size)
★Really helpful Slack channel (shares members with Swift-arm channel)
★Nice todo app example
★My choice for this experiment
for the Raspberry Pi
![Page 29: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/29.jpg)
The Pieces
Server Middleware Controller PersistenceRouter
Views
![Page 30: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/30.jpg)
That Sounds Familiar!
![Page 31: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/31.jpg)
Clean Architecture: iOS
App Delegate
View (VC) Presenter InteractorEntity
Gateway
Connector
![Page 32: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/32.jpg)
The Pieces
Server Middleware Controller PersistenceRouter
Views
Interactor
![Page 33: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/33.jpg)
Clean Architecture
![Page 34: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/34.jpg)
The Test App
![Page 35: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/35.jpg)
Conclusions★Swift code in Raspberry Pi has some glitches
★ The domain logic can be in a package:
• Fully tested
• Independent of the rest
★Use cases can be shared
• No asynchrony
• Some logic may be different
★Worth the investment
![Page 36: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/36.jpg)
Things I Would Like
★ JSON home page / JSONAPI
★Better (Some) debugging
★Better support for Raspberry Pi
![Page 37: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/37.jpg)
Thank you!
![Page 38: To Protect & To Serve](https://reader033.vdocument.in/reader033/viewer/2022051300/587603a31a28ab4a508b61c5/html5/thumbnails/38.jpg)
@jdortiz #Swift3Arch