Traditionally Use Node.js, Python, Ruby, etc… for Server-Side programming • Swift has… • Types, Protocol, Value Associated Enumeration, etc… for Better, Safer Programming • Good Performance • Alternatives for Scripting Programming Languages
W E B C R AW L E R • Backend service of our products • RSS/HTML Crawling / Web scraping • Crawl specified Web pages, Parse the HTML, Save to the database as a Search bot • Extract body text excluding Navigation or submenu on the HTML
A N G U A G E • Swift is LLVM based • Link with C based Library • Export C interface to Swift transparently • Swift Package Manager supports C compile (.c and .h) All C Libraries are Available on Swift!!
( A G A I N ) • HTTPClient, AWS S3Client • libcurl (C based) • XML/HTML Parsing, XPath(CSS Selector) traversal • libxml2 (C based) • MySQL Library • C based mysqlconnector • Japanese Charset converter (Shift-JIS, EUC_JP) • nkf(Network Kanji Filter) (C based)
S TAT U S • Code base(including Tests) • Crawler:~10,000 lines • In-house library: ~9,000 lines • Unit Tests is works well with Xcode • Running on macOS fine, ~20 days OK! • Running on our Development environment (Docker, Linux), 7 days OK!
• Control many Devices via GPIO and I2C bus • Various Sensors, Lights, LCD, … • Combine with Swift libraries • Of Course, Written in Swift all !! Swift for ARM: https://github.com/iachievedit/package-swift
pressure and temperature let device = try getCurrentI2CDevice() let sensor = BMP180(device: device) try sensor.reset() try sensor.calibrate() let result = try sensor.mesure(oversampling: .oss3) print("sensor data", result)
• Make it more Swifty ➜ • e.g.) libcurl, libxml, mysqlconnector 2. Find similar Libraries in Node.js, Python, Ruby… • Port other Language’s Library back to Swift ➜ • Make it more Swifty ➜ • e.g.) NKF Write your Swift program with them