Slide 1

Slide 1 text

Swi! Côté Serveur 1

Slide 2

Slide 2 text

Salut 2

Slide 3

Slide 3 text

Simone Cive!a 3

Slide 4

Slide 4 text

Je suis un développeur iOS 4

Slide 5

Slide 5 text

7 ans 5

Slide 6

Slide 6 text

6

Slide 7

Slide 7 text

4 ans 7

Slide 8

Slide 8 text

8

Slide 9

Slide 9 text

9

Slide 10

Slide 10 text

10

Slide 11

Slide 11 text

11

Slide 12

Slide 12 text

12

Slide 13

Slide 13 text

13

Slide 14

Slide 14 text

Enfin... 14

Slide 15

Slide 15 text

Plan 1. Les Origines 2. État de l'art 3. Pourquoi l'utiliser ? 4. Swift Server dans la vraie vie 5. Évolutions 15

Slide 16

Slide 16 text

1. Les origines 16

Slide 17

Slide 17 text

17

Slide 18

Slide 18 text

18

Slide 19

Slide 19 text

Pourquoi Open Source ? 19

Slide 20

Slide 20 text

20

Slide 21

Slide 21 text

21

Slide 22

Slide 22 text

22

Slide 23

Slide 23 text

23

Slide 24

Slide 24 text

24

Slide 25

Slide 25 text

2. État de l'art 25

Slide 26

Slide 26 text

Swi! 3.1 26

Slide 27

Slide 27 text

1.0 27

Slide 28

Slide 28 text

1.1 28

Slide 29

Slide 29 text

1.2 29

Slide 30

Slide 30 text

2.0 30

Slide 31

Slide 31 text

2.1 31

Slide 32

Slide 32 text

2.2 32

Slide 33

Slide 33 text

2.3 33

Slide 34

Slide 34 text

3.0 34

Slide 35

Slide 35 text

Swi! 3.1 35

Slide 36

Slide 36 text

En 2015-16 1 version tous les 2 mois 36

Slide 37

Slide 37 text

Un langage (presque) finalisé 37

Slide 38

Slide 38 text

Un langage complet 38

Slide 39

Slide 39 text

39

Slide 40

Slide 40 text

40

Slide 41

Slide 41 text

41

Slide 42

Slide 42 text

42

Slide 43

Slide 43 text

43

Slide 44

Slide 44 text

bibliothèques tierces 44

Slide 45

Slide 45 text

Beaucoup de bibliothèques tierces stables 45

Slide 46

Slide 46 text

46

Slide 47

Slide 47 text

47

Slide 48

Slide 48 text

48

Slide 49

Slide 49 text

Bibliothèques C 49

Slide 50

Slide 50 text

Frameworks Web 50

Slide 51

Slide 51 text

51

Slide 52

Slide 52 text

52

Slide 53

Slide 53 text

53

Slide 54

Slide 54 text

54

Slide 55

Slide 55 text

55

Slide 56

Slide 56 text

Swi! Package Manager 56

Slide 57

Slide 57 text

SPM swift package init swift package fetch swift package update swift package generate-xcodeproj 57

Slide 58

Slide 58 text

Swi! Package Catalog 58

Slide 59

Slide 59 text

59

Slide 60

Slide 60 text

60

Slide 61

Slide 61 text

61

Slide 62

Slide 62 text

Quelques images Docker — swiftdocker/swift/ — ibmcom/kitura-ubuntu/ — zewo/todobackend/ 62

Slide 63

Slide 63 text

Qualité du code 63

Slide 64

Slide 64 text

64

Slide 65

Slide 65 text

65

Slide 66

Slide 66 text

66

Slide 67

Slide 67 text

67

Slide 68

Slide 68 text

Metriques de qualité Pour en savoir plus... speakerdeck.com/viteinfinite/be-the-quality-you-want- to-see-in-your-app-swift-edition 68

Slide 69

Slide 69 text

69

Slide 70

Slide 70 text

70

Slide 71

Slide 71 text

nuclide.io/docs/languages/swift/ 71

Slide 72

Slide 72 text

! 72

Slide 73

Slide 73 text

Enfin... 73

Slide 74

Slide 74 text

3. Pourquoi l'utiliser ? 74

Slide 75

Slide 75 text

Développement actif 75

Slide 76

Slide 76 text

76

Slide 77

Slide 77 text

77

Slide 78

Slide 78 text

78

Slide 79

Slide 79 text

79

Slide 80

Slide 80 text

80

Slide 81

Slide 81 text

81

Slide 82

Slide 82 text

Performance 82

Slide 83

Slide 83 text

Performance 83

Slide 84

Slide 84 text

Performance 84

Slide 85

Slide 85 text

Mémoire Source: http://benchmarksgame.alioth.debian.org 85

Slide 86

Slide 86 text

Applications isomorphes 86

Slide 87

Slide 87 text

GCD 87

Slide 88

Slide 88 text

4. Dans la vraie vie 88

Slide 89

Slide 89 text

89

Slide 90

Slide 90 text

90

Slide 91

Slide 91 text

L'application Serveur 1. Routing 2. Fichiers statiques 3. Proxy YouTube 4. Caching 91

Slide 92

Slide 92 text

Package.swi! import PackageDescription let package = Package( name: "XebiaTV", dependencies: [ .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1, minor: 5), .Package(url: "https://github.com/vapor/redis-provider.git", majorVersion: 1) ] ) 92

Slide 93

Slide 93 text

Router import Foundation import Vapor let drop = Droplet() let categoryController = CategoryController() let youtubeController = YouTubeController() drop.get("/categories", handler: categoryController.categories) drop.get("/playlistItems", handler: youtubeController.playlistItems) drop.get("/search", handler: youtubeController.search) drop.get("/live", handler: youtubeController.live) drop.get("/video", String.self, handler: youtubeController.video) drop.run() 93

Slide 94

Slide 94 text

Fichiers statiques import Foundation import Vapor import Core import HTTP final class CategoryController { private let dataLoader = DataFile() func categories(_ req: Request) throws -> ResponseRepresentable { let fileBody = try dataLoader.load(path: drop.workDir + "Data/categories.json") return Response(body: .data(fileBody)) } } 94

Slide 95

Slide 95 text

Proxy YouTube public final class YouTubeController { // ... func search(_ req: Request) throws -> ResponseRepresentable { let query = "\(googleApisBaseUrl)/search?key=\(apiKey)&channelId=\(channelId)" return try drop.client.get(query) } } 95

Slide 96

Slide 96 text

// ... public func video(_ req: Request, videoId: String) throws -> ResponseRepresentable { let cacheKey = "video-\(videoId)" guard let cached = try cacheService.load(for: cacheKey) else { let urls = try videoUrls(for: videoId) try cacheService.save(node: urls, with: cacheKey, expiration: cacheExpiration) return try JSON(node: urls) } return try JSON(node: cached) } private func videoUrls(for videoId: String) throws -> Node { guard let urls = try LiveStreamerReader.read(videoId: videoId) else { throw Error.noVideo } return Node(["urls": Node.array(urls)]) } 96

Slide 97

Slide 97 text

Intégration avec LiveStreamer static func launch(_ command: String, args: [String] = []) throws -> Data { #if os(Linux) let task = Task() #else let task = Process() #endif let pipe = Pipe() task.launchPath = command task.arguments = args task.standardOutput = pipe task.launch() let data = pipe.fileHandleForReading.readDataToEndOfFile() task.waitUntilExit() return data } 97

Slide 98

Slide 98 text

Cache avec Redis public protocol CacheService { func load(for key: String) throws -> Node? func save(node: Node, with key: String, expiration: TimeInterval) throws } public class RedisService : CacheService { private let drop: Droplet public init(drop: Droplet) throws { try drop.addProvider(VaporRedis.Provider(config: drop.config)) self.drop = drop } public func load(for key: String) throws -> Node? { return try drop.cache.get(key) } public func save(node: Node, with key: String, expiration: TimeInterval) throws { try drop.cache.set(key, node) if let redisCache = drop.cache as? RedisCache { try redisCache.redbird.command("EXPIRE", params: [key, "\(Int(expiration))"]) } } } 98

Slide 99

Slide 99 text

Build $ swift build Compile CLibreSSL xts128.c Compile CLibreSSL x_x509a.c Compile CLibreSSL xcbc_enc.c Compile CLibreSSL x_spki.c .... Compile Swift Module 'libc' (1 sources) Compile Swift Module 'SocksCore' (15 sources) Compile Swift Module 'Jay' (21 sources) Linking CLibreSSL Compile Swift Module 'Core' (28 sources) Compile Swift Module 'Routing' (11 sources) Compile Swift Module 'HTTPRouting' (5 sources) Compile Swift Module 'TypeSafeRouting' (3 sources) Compile Swift Module 'Cache' (3 sources) Compile Swift Module 'Auth' (15 sources) Compile Swift Module 'Vapor' (92 sources) Compile Swift Module 'VaporRedis' (2 sources) Compile Swift Module 'App' (6 sources) 99

Slide 100

Slide 100 text

Tests class AppTests: XCTestCase { // ... Create a StubCategoryController func testCategoryRoute() throws { let drop = try makeTestDroplet(categoryController: StubCategoryController()) let request = try Request(method: .get, uri: "/categories") let response = try drop.respond(to: request) let jsonBody = try JSON(bytes: response.body.bytes!) XCTAssertEqual(jsonBody["categories"]?.string, "someCategory") } } 100

Slide 101

Slide 101 text

101

Slide 102

Slide 102 text

Tout s'est bien passé™ 102

Slide 103

Slide 103 text

Enfin... 103

Slide 104

Slide 104 text

104

Slide 105

Slide 105 text

105

Slide 106

Slide 106 text

Cross platform #if os(Linux) import Glibc #else import Darwin #endif 106

Slide 107

Slide 107 text

Swift Build 107

Slide 108

Slide 108 text

Swi! Package Manager Mess swift package generate-xcodeproj 108

Slide 109

Slide 109 text

Tester c'est linker (?) Undefined symbols for architecture x86_64: "test2.test2.init () -> test2.test2", referenced from: test2Tests.test2Tests.(testExample () -> ()). (implicit closure #1) in test2Tests.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 109

Slide 110

Slide 110 text

5. Évolutions 110

Slide 111

Slide 111 text

Encore plus de Frameworks 111

Slide 112

Slide 112 text

Encore plus de APIs Swi! 112

Slide 113

Slide 113 text

113

Slide 114

Slide 114 text

114

Slide 115

Slide 115 text

Peut-on le déployer en prod ? 115

Slide 116

Slide 116 text

Oui ! 116

Slide 117

Slide 117 text

Enfin... 117

Slide 118

Slide 118 text

Merci ! 118

Slide 119

Slide 119 text

Simone Cive!a 119

Slide 120

Slide 120 text

Je suis un développeur iOS 120

Slide 121

Slide 121 text

Je suis un développeur Back 121

Slide 122

Slide 122 text

Enfin... 122

Slide 123

Slide 123 text

123

Slide 124

Slide 124 text

Be a Be!er Developer beabe!er.ninja 124

Slide 125

Slide 125 text

125