38
To Protect & To Serve Jorge D. Ortiz-Fuentes @jdortiz

To Protect & To Serve

Embed Size (px)

Citation preview

Page 1: To Protect & To Serve

To Protect & To ServeJorge D. Ortiz-Fuentes

@jdortiz

Page 2: To Protect & To Serve

A Canonical Examples

production

#Swift3Arch

Page 3: To Protect & To Serve

Agenda

★Swift Backend

★DIY

★The Test App

Page 4: To Protect & To Serve

Swift Backend

Page 5: To Protect & To Serve

Disclaimer

Not a backend developer

Page 6: To Protect & To Serve

Then, Why?

Page 7: To Protect & To Serve

– 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

And you are asking me?

No Refactoring

Compiler Segmentation Fault

Migrations

Moving targetNo examples

No reflection&introspection

Xcode

Page 9: To Protect & To Serve

Always Look at the Bright Side of Life

★Opportunity to learn

★ Linux

★Backend

★Swift Package Manager

Page 10: To Protect & To Serve

Does it mean that…

Page 11: To Protect & To Serve

NO

Page 12: To Protect & To Serve

Not ready for production yet

Page 13: To Protect & To Serve

Not ready for production yetSome Scenarios

Page 14: To Protect & To Serve

Just an Experiment?

Page 15: To Protect & To Serve

Kinda

Page 16: To Protect & To Serve

Useful Scenarios

★Training

★Prototyping

★Embedded devices

★Private servers

Page 17: To Protect & To Serve

Server Side Swift is an IDE

Immature Development Environment

Page 18: To Protect & To Serve

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

I couldn’t make libdistpatch

😢

Page 20: To Protect & To Serve

I couldn’t make LLDB work

😢😢😢

Illegal instruction (core dumped)

Page 21: To Protect & To Serve

But there is hope

https://swift.org/server-apis/Saint Chris, Chapter 42 verse FF

Page 22: To Protect & To Serve

DIY

Page 23: To Protect & To Serve

The Tools

★Emacs (https://emacsformacosx.com/)

• Tramp (SSH)

• Swift-mode (2.2)

★ iTerm + tmux

★Google Chrome

Page 24: To Protect & To Serve

Frameworks

★Kitura

★Perfect

★Vapor

★Zewo

Page 25: To Protect & To Serve

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

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

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

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

The Pieces

Server Middleware Controller PersistenceRouter

Views

Page 30: To Protect & To Serve

That Sounds Familiar!

Page 31: To Protect & To Serve

Clean Architecture: iOS

App Delegate

View (VC) Presenter InteractorEntity

Gateway

Connector

Page 32: To Protect & To Serve

The Pieces

Server Middleware Controller PersistenceRouter

Views

Interactor

Page 33: To Protect & To Serve

Clean Architecture

Page 34: To Protect & To Serve

The Test App

Page 35: To Protect & To Serve

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

Things I Would Like

★ JSON home page / JSONAPI

★Better (Some) debugging

★Better support for Raspberry Pi

Page 37: To Protect & To Serve

Thank you!

Page 38: To Protect & To Serve

@jdortiz #Swift3Arch