Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
fukuoka_kt_1
Search
gupuru
July 05, 2017
Technology
100
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
fukuoka_kt_1
https://cdg.connpass.com/event/60570/
gupuru
July 05, 2017
More Decks by gupuru
See All by gupuru
ng-fukuoka-meetup-1
gupuru
0
420
AngularとAzureのCustom Vision Serviceを使って 画像認識サイトを作ってみた
gupuru
0
670
紙について少し詳しくなる10分間
gupuru
0
410
make bot, fun bot
gupuru
0
340
firebase勉強会資料
gupuru
3
780
iOS and Android SVG
gupuru
0
380
Firebaseについて
gupuru
1
220
BLEを使って、すれ違い通信をやってみるよー
gupuru
0
2.3k
HiyokoDeveloperMeeting
gupuru
1
140
Other Decks in Technology
See All in Technology
【セミナー資料】Claude Code をセキュアに使うための考え方と設定の勘どころ / Claude Code Webinar 20260616
masahirokawahara
2
410
2026TECHFRESH畢業分享會 - 葬送的通靈師:化系統與用戶雜訊成行動訊號
line_developers_tw
PRO
0
1.3k
「勝手に広まる」人気 AI エージェントを爆速で作ろう!(AWS Summit Japan 2026講演資料)
minorun365
PRO
7
1.9k
AWS Security Agent といっしょに脅威モデリングをやってみよう
amarelo_n24
1
170
生成 AI 実践ガイド (概略版) AIガバナンス編
asei
0
110
iAEONの段階的リアーキテクト戦略 / iAEON's_Gradual_Re-architecture_Strategy
aeonpeople
0
230
攻撃者視点で考えるDetection Engineering
cryptopeg
3
2k
エラーバジェットのアラートのタイミングを考える.pdf
kairim0
0
170
Bucharest Tech Week 2026 - Guardians of the Cloud-Native Galaxy
edeandrea
PRO
0
120
Lightning近況報告
kozy4324
0
180
Agent Skills設計で柔軟性と硬さのバランスが難しい話
nassy20
0
140
失敗を資産に変えるClaude Code
shinyasaita
0
720
Featured
See All Featured
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
160
Test your architecture with Archunit
thirion
1
2.3k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
The untapped power of vector embeddings
frankvandijk
2
1.8k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
Side Projects
sachag
455
43k
Paper Plane (Part 1)
katiecoart
PRO
0
9.1k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
The browser strikes back
jonoalderson
0
1.3k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
66
55k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Transcript
WebͰKotlinʂ Kotlin to JavaScript
About me ৽ݟ ߊฏ ϑϩϯτΤϯυͱػցֶशͷΤϯδχΞʹͳΖ͏ͱؤு͍ͬͯ ·͢(ʆɾωɾ´) • Twitter: @gupuru •
GitHub: gupuru
None
Kotlin 1.1ͰɺJavaScriptαϙʔτ͞Ε·ͨ͠ʂ JavaScript͕kotlinͰॻ͚·͢(ʆɾТɾ´) https://blog.jetbrains.com/jp/2017/03/01/739
ͪͳΈʹɺ͜Εࢼͨ͜͠ͱ͕͋Δਓɺ ڍखϊʢসʣ
͡ΊʹಋೖͩΑ(ʆɾТɾ´)
͜ͷ4ͭͷํ๏͕͋ΔΑ(ʆɾТɾ´) • Gradle • Maven • IntelliJ IDEA • Command
Line
IntelliJ IDEA
࠷ॳɺ͜Μͳײ͡ͷϓϩδΣΫτߏ͓ͩ(ʆɾТɾ´)
Build͢Δͱɺout͕Ͱ͖Δ͓(ʆɾТɾ´)
Buildͯ͠ɺͰ͖ͨϑΝΠϧΛHTMLଆͰݺΜͰ͋͛Δͱ͑Δ͓(ʆɾТɾ´) <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>ΘΜ͜</title> </head>
<body> <script type="text/javascript" src="out/production/wanko/lib/kotlin.js"></script> <script type="text/javascript" src="out/production/wanko/wanko.js"></script> </body> </html>
Γͷํ๏ɺ͜͜ݟͯ(ʆɾТɾ´) https://kotlinlang.org/docs/tutorials/javascript/kotlin-to-javascript/kotlin-to-javascript.html
࣮ࡍʹॻ͍ͯΈΔΑ(ʆɾТɾ´)
͜Μͳײ͡ʹॻ͘Α(ʆɾТɾ´) fun main(args: Array<String>) { val message = "͍͵ɺ͔Θ͍͍" println(message)
}
HTML͜Μͳײ͡(ʆɾТɾ´) <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>wanko</title> </head>
<body> <script type="text/javascript" src="out/production/inukawaii/lib/kotlin.js"></script> <script type="text/javascript" src="out/production/inukawaii/inukawaii.js"></script> </body> </html>
͜Μͳײ͡ʹม͞Ε͍ͯΔΑ(ʆɾТɾ´) if (typeof kotlin === 'undefined') { throw new Error("Error
loading module 'kotlinJS'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'kotlinJS'."); } var kotlinJS = function (_, Kotlin) { 'use strict'; var println = Kotlin.kotlin.io.println_s8jyv4$; function main(args) { var message = '\u3044\u306C\u3001\u304B\u308F\u3044\u3044'; println(message); } _.main_kand9s$ = main; Kotlin.defineModule('kotlinJS', _); main([]); return _; }(typeof kotlinJS === 'undefined' ? {} : kotlinJS, kotlin);
গ͚ͩ͠ಈ͖͚ͭͯΈΔ͓(ʆɾТɾ´)
kotlin͓ͩ(ʆɾТɾ´) fun main(args: Array<String>) { val inputText: HTMLInputElement = document.getElementById("inputText")
as HTMLInputElement val button: HTMLButtonElement = document.getElementById("button") as HTMLButtonElement button.onclick = { window.alert(inputText.value) } }
HTML͓ͩ(ʆɾТɾ´) <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>ΘΜΘΜ</title> </head>
<body> <input id="inputText" type="text" value="" title="ͳʹ͔͍Εͨ·͑"> <button id="button">͋Βʔͱͩ͢Α</button> <script type="text/javascript" src="out/production/kotlinJS/lib/kotlin.js"></script> <script type="text/javascript" src="out/production/kotlinJS/kotlinJS.js"></script> </body> </html>
͜Μͳײ͡ม͞Ε͍ͯΔΑ(ʆɾТɾ´) if (typeof kotlin === 'undefined') { throw new Error("Error
loading module 'kotlinJS'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'kotlinJS'."); } var kotlinJS = function (_, Kotlin) { 'use strict'; function main$lambda(closure$inputText) { return function (it) { window.alert(closure$inputText.value); }; } function main(args) { var tmp$, tmp$_0; var inputText = Kotlin.isType(tmp$ = document.getElementById('inputText'), HTMLInputElement) ? tmp$ : Kotlin.throwCCE(); var button = Kotlin.isType(tmp$_0 = document.getElementById('button'), HTMLButtonElement) ? tmp$_0 : Kotlin.throwCCE(); button.onclick = main$lambda(inputText); } _.main_kand9s$ = main; main([]); Kotlin.defineModule('kotlinJS', _); return _; }(typeof kotlinJS === 'undefined' ? {} : kotlinJS, kotlin);
͞Βʹಈ͖͚ͭͯΈΔΑ(ʆɾТɾ´)
NodeͷαʔόΛͨͯͯΈΔ͓(ʆɾТɾ´)
package.json͓ͩ(ʆɾТɾ´) { "name": "wankoserver", "version": "1.0.0", "description": "", "main": "index.js",
"scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "gupuru", "license": "MIT", "dependencies": { "express": "^4.15.3", "kotlin": "^1.1.0" } }
gradle͓ͩ(ʆɾТɾ´) group 'wanko-express' version '1.0' buildscript { ext.kotlin_version = '1.1.1'
repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } apply plugin: 'kotlin2js' repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" } compileKotlin2Js.kotlinOptions { moduleKind = "commonjs" outputFile = "node/index.js" }
kotlin͓ͩ(ʆɾТɾ´) external fun require(module:String):dynamic fun main(args: Array<String>) { println("wanwan start")
val express = require("express") val app = express() app.get("/", { req, res -> res.type("text/plain") res.send("wanko kawaii") }) app.listen(3000, { println("port: 3000") }) }
͜Μͳײ͡ม͞Ε͍ͯΔ͓(ʆɾТɾ´) (function (_, Kotlin) { 'use strict'; var println =
Kotlin.kotlin.io.println_s8jyv4$; function main$lambda(req, res) { res.type('text/plain'); return res.send('wanko kawaii'); } function main$lambda_0() { println('port: 3000'); } function main(args) { println('wanwan start'); var express = require('express'); var app = express(); app.get('/', main$lambda); app.listen(3000, main$lambda_0); } _.main_kand9s$ = main; Kotlin.defineModule('index', _); main([]); return _; }(module.exports, require('kotlin')));
ৄ͘͠ɺ͜͜Έͯ(ʆɾТɾ´) • https://github.com/miquelbeltran/kotlin-node.js
·ͱΊ
Kotlinָ͍͠(ʆŋТŋ´)
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ