Upgrade to Pro — share decks privately, control downloads, hide ads and more …

忙しいSwiftエンジニアのためのKotlin入門

 忙しいSwiftエンジニアのためのKotlin入門

Yasuhiro Inami

May 23, 2017
Tweet

More Decks by Yasuhiro Inami

Other Decks in Programming

Transcript

  1. SwiftKotlin • ίϚϯυϥΠϯʴMacΞϓϦʹΑΔ Swift → Kotlinม׵ • 2017/05/23ݱࡏɺͦͦ͜͜ରԠ (Status: 50%)

    • ཪଆͰ͸ nicklockwood/SwiftFormat (ࣈ۟ղੳث) Λ࢖༻ • ΋ͬͱASTϨϕϧͰ͖ͪΜͱ࣮૷͍ͨ͠ ! • SourceKittenɺswiftc -dump-astɺํ๏͸͍Ζ͍Ζɾɾɾ • ࠷ۙɺΠέͯΔϥΠϒϥϦ͕։ൃ͞Εͨ
  2. SwiftScript • SwiftAST • Expression, Statement, LiteralͳͲͷܕ৘ใ • SwiftParse •

    Swiftίʔυ → AST΁ͷม׵ (tryswift/TryParsecΛ࢖༻) • SwiftScript (JavaScriptม׵) • VisitorύλʔϯΛ࢖ͬͨ AST → JavaScriptίʔυม׵
  3. // Swift let numbers: [Int] = [2, 3, 5] for

    number in numbers { print(number) } let squared = numbers.map { $0 * $0 } ɹɹɹɹɹ‑‑‑ // JavaScript (ES6) const numbers = [2, 3, 5]; for (number of numbers) { console.log(number); } const squared = numbers.map(x => x * x);
  4. // Swift let numbers: [Int] = [2, 3, 5] for

    number in numbers { print(number) } let squared = numbers.map { $0 * $0 } ɹɹɹɹɹ‑‑‑ // Kotlin val numbers: Array<Int> = arrayOf(2, 3, 5) for (number in numbers) { print(number) } val squared = numbers.map({ it * it })
  5. ·ͱΊ • Google I/O 2017ͰɺAndroid͕KotlinΛ࠾༻ ! • angelolloqui/SwiftKotlin • ͱͯ΋ྑ͍ग़དྷ͚ͩͲɺࣈ۟ղੳࢭ·Γ

    • SwiftScript • ASTϨϕϧͰॲཧ͕Մೳ • Swift͚ͩॻ͍ͯɺເͷKotlinରԠ✨#✨