Slides available on: Google Presentation https://goo.gl/CMVNqS Google Photo https://goo.gl/HpRLw4 Speaker Deck (by GitHub) https://speakerdeck.com/jacklt SlideShare (by LinkedIn) https://www.slideshare.net/OmarMiatello
of free hosting, since 2000) ◦ Altervista, Netsons, … • Solution PaaS (Platform as a Service) ◦ Google App Engine ▪ Support for: Node.js, Java, Ruby, C#, Go, Python e PHP, … ▪ 28 hours instance a day ◦ Amazon Web Services (Free tear only for the first 12 months) • Solution “serverless”
(Free) ◦ https://www.jetbrains.com/idea/download • New Project: Gradle > Kotlin (JavaScript) • GroupId: “com.example” & ArtifactId: “myservice” • Confirm default settings until “Finish” G etting started w ith K otlin for JavaScript
Firebase (optional) ◦ Use console: https://console.firebase.google.com • Open Functions section > click “Start” G etting started w ith K otlin for JavaScript
Firebase (optional) ◦ Use console: https://console.firebase.google.com • Open Functions section > click “Start” • Install Node.js: https://nodejs.org ◦ Command line: “npm install -g firebase-tools” and “npm install kotlin” ◦ Open Terminal in project folder and run “firebase init” (and follow instructions) G etting started w ith K otlin for JavaScript
◦ Deploy command: firebase deploy compileKotlin2Js.kotlinOptions { moduleKind = "commonjs" outputFile = "functions/index.js" } G etting started w ith K otlin for JavaScript
it does not check types at compile-time. You can freely talk to JavaScript from Kotlin via dynamic types, but if you want the full power of Kotlin type system, you can create Kotlin headers for JavaScript libraries.
to tell Kotlin that a certain declaration is written in pure JavaScript. Compiler assumes that the implementation for the corresponding class, function or property is provided by the developer. • dynamic - The dynamic type basically turns off Kotlin's type checker. The most peculiar feature of dynamic is that we are allowed to call any property or function with any parameters on a dynamic variable.
this value as a value of the dynamic type. • .unsafeCast<T>() - Reinterprets this “dynamic” value as a value of the specified type [T] (ex: String / Array) without any actual type checking. Methods: • js(code) - Puts the given piece of a JavaScript code right into the calling function. The compiler replaces call to `js(...)` code with the string constant provided as a parameter.