SlideShare a Scribd company logo
Scala.js
Yet Another What... ?
Created by /Artur Skowroński @arturskowronski
#JavascriptEverywhere
There are a problems with big
apps in Javascript
We have transpiled languages
Scala.js - yet another what..?
Scala.js - yet another what..?
Scala.js - yet another what..?
We have compiled languages
Google Web Toolkit
Opal (Rb 2 JS)
CobolScript
Brainfuck.js
Scala.js
Said to be production ready
Functional JavaScript is getting
popularity
Scala.js - yet another what..?
Scala.js - yet another what..?
Scala.js - yet another what..?
Functional Reactive
Programming
Example 1
object ScalaJSExample extends js.JSApp{
def main() = {
var x = 0
while(x < 999){
x = x + "2".toInt
}
println(x)
}
}
ScalaJS.c.Lexample_ScalaJSExample$.prototype.main__V = (function() {
var x = 0;
while ((x < 999)) {
var jsx$1 = x;
var this$2 = new ScalaJS.c.sci_StringOps().init___T("2");
var this$4 = ScalaJS.m.jl_Integer$();
var s = this$2.repr$1;
x = ((jsx$1 + this$4.parseInt__T__I__I(s, 10)) | 0)
};
var x$1 = x;
var this$6 = ScalaJS.m.s_Console$();
var this$7 = this$6.outVar$2;
ScalaJS.as.Ljava_io_PrintStream(this$7.tl$1.get__O()).println__O__V(x$1)
});
<script type="text/javascript" src="/oursample-fastopt.js"></script>
<script>
</script>
oursample.ScalaJSExample().main();
Example 2
object ScalaJSExample extends js.JSApp{
def main() = {}
def exported = {}
def exported2 = {}
}
@JSExport
object ScalaJSExample extends js.JSApp{
def main() = {}
@JSExport
def exported() = {}
@JSExport
def exported2() = {}
}
<script>
oursample.ScalaJSExample().exported();
oursample.ScalaJSExample().exported2();
</script>
$.val()?
val is forbidden in Scala
@JSName
object ScalaJSExample extends js.JSApp{
def main() = {}
@JSExport
def exported() = {}
@JSExport
def exported2() = {}
@JSExport
@JSName('val')
def valueOfObject() = {}
}
<script>
oursample.ScalaJSExample().val();
</script>
General problem with
Transpiler
SBT Plugin
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.0")
compile
package
fastOptJS
fullOptJS
run
test
compile
Initial Compilation: .scala files to .class and .sjsir files
package
fastOptJs
Fast Optimization: .sjsir files to one smallish/fast .js file
fullOptJs
Clojure Compiler
Full Optimization: .sjsir files to one smaller/faster .js file
Clojure Compiler
run
object RunMe extends js.JSApp{
def main(): Unit = {
println("Hello World!")
}
}
Hello World!
Rhino
Node.js
PhantomJs
test
Source Maps
Example 3
@JSExport
object Client extends js.JSApp{
@JSExport
def main(container: html.Div) = {
val inputBox = input.render
val outputBox = ul.render
def update() = Ajax.post("/ajax/list", inputBox.value).foreach{ xhr =>
def response = xhr.responseText
(Raw Json Operation)
}
}
}
Not Strongly Typed
autowire
@JSExport
object Client extends js.JSApp{
@JSExport
def main(container: html.Div) = {
val inputBox = input.render
val outputBox = ul.render
def update() = Ajaxer[Api].post("/ajax/list", inputBox.value).foreach{ data =>
(Business Logic on Strongly typed operations)
}
}
}
org.scala-js.scalajs-dom
org.lihaoyi.scalatags
com.lihaoyi.utest
com.lihaoyi.uPickle
me.chrons.boopickle
com.lihaoyi.autowire
com.lihaoyi.workbench
Quirks
Float
println(1.4f)
1.3999999761 58142
Lack Of Exception Checking
Regular expressions
Reflection Support
Conclusion
Better than
expected :)
Strenghts
Strongly Typed
IDE Autocompletion
Better know language (for Scala Dev)
Single Language Codebase
Weaknes
Big Result Files
Harder Debugging
Don't part of JS Ecosystem
Lack of Support to many libraries (fe. Akka and Guice)
Performance payoffs and don't able to perfomance by hand
Opportunities
Our Holy Grail :)
More Scalable Codebase
Chances to more library support in future
Creators promise better performance
Treats /
Concerns
Project will loose interests and support
Every Abstraction Leaks :(
Links
Activator: play-scalajs-showcase
http://lihaoyi.github.io/hands-on-scala-js/
http://www.scala-js-fiddle.com/
http://ochrons.github.io/scalajs-spa-tutorial/
Thank You

More Related Content

PPTX
Alberto Paro - Hands on Scala.js
PPTX
Scala.js for large and complex frontend apps
PDF
Full Stack Scala
PDF
Scala.js & friends: SCALA ALL THE THINGS
PPTX
Scala.js: Next generation front end development in Scala
ODP
Introduction to Scala JS
PDF
Scala in a wild enterprise
ODP
Introduction to ScalaZ
Alberto Paro - Hands on Scala.js
Scala.js for large and complex frontend apps
Full Stack Scala
Scala.js & friends: SCALA ALL THE THINGS
Scala.js: Next generation front end development in Scala
Introduction to Scala JS
Scala in a wild enterprise
Introduction to ScalaZ

What's hot (20)

PDF
とりあえず使うScalaz
ODP
Scal`a`ngular - Scala and Angular
PDF
Reactive Thinking in Java
PDF
Intro to Scala.js - Scala UG Cologne
PDF
Intro to sbt-web
ODP
Drilling the Async Library
PPTX
Building an aws sdk for Perl - Granada Perl Workshop 2014
PPTX
Testing in Scala. Adform Research
PPTX
Paws - Perl AWS SDK Update - November 2015
PPTX
Alasql JavaScript SQL Database Library: User Manual
PPTX
Spark intro by Adform Research
PDF
V8 javascript engine for フロントエンドデベロッパー
PPTX
Paws - A Perl AWS SDK
PPTX
Scala elegant and exotic part 1
PDF
Resilient Applications with Akka Persistence - Scaladays 2014
ODP
An Introduction to Quill
PDF
Akka lsug skills matter
PDF
Angular Weekend
PDF
"Xapi-lang For declarative code generation" By James Nelson
PDF
Modernizing Infrastructures for Fast Data with Spark, Kafka, Cassandra, React...
とりあえず使うScalaz
Scal`a`ngular - Scala and Angular
Reactive Thinking in Java
Intro to Scala.js - Scala UG Cologne
Intro to sbt-web
Drilling the Async Library
Building an aws sdk for Perl - Granada Perl Workshop 2014
Testing in Scala. Adform Research
Paws - Perl AWS SDK Update - November 2015
Alasql JavaScript SQL Database Library: User Manual
Spark intro by Adform Research
V8 javascript engine for フロントエンドデベロッパー
Paws - A Perl AWS SDK
Scala elegant and exotic part 1
Resilient Applications with Akka Persistence - Scaladays 2014
An Introduction to Quill
Akka lsug skills matter
Angular Weekend
"Xapi-lang For declarative code generation" By James Nelson
Modernizing Infrastructures for Fast Data with Spark, Kafka, Cassandra, React...
Ad

Viewers also liked (20)

PPTX
Share multi versioning scenarios
PDF
Oumh1303 20130712 155801
PPTX
designing windows user experiences
PPT
IBM Impact session Ed addison nuts and bolts ws
PPT
Share seattle health_center
PPT
Naturales.
PPT
Impact 2014 Best practices for_cics_soa_co
ODP
2829 liberty
ODP
IBM Impact session CICS & java a tale of liberty
PDF
4236 What Skills Issue? From the perspective of a Generation z CICS customer
PPT
Share seattle liberty
PPTX
Tarea d4e ingles
PPT
SHARE 2014, Pittsburgh Using policies to manage critical cics resources
PPT
z Technical Summit Track 3 Session 4 Developing mobilefirst app for z
PDF
2014 1 pr커뮤니케이션세미나 강의록 3월4월
PPTX
Theories of power
PPTX
Session 2546 - Solving Performance Problems in CICS using CICS Performance A...
PDF
Change Detection Anno Domini 2016
PDF
2014 multimuntanya powerpoint_mare de deu_sise_ (2)
PPTX
2545 Debugging back to-basics
Share multi versioning scenarios
Oumh1303 20130712 155801
designing windows user experiences
IBM Impact session Ed addison nuts and bolts ws
Share seattle health_center
Naturales.
Impact 2014 Best practices for_cics_soa_co
2829 liberty
IBM Impact session CICS & java a tale of liberty
4236 What Skills Issue? From the perspective of a Generation z CICS customer
Share seattle liberty
Tarea d4e ingles
SHARE 2014, Pittsburgh Using policies to manage critical cics resources
z Technical Summit Track 3 Session 4 Developing mobilefirst app for z
2014 1 pr커뮤니케이션세미나 강의록 3월4월
Theories of power
Session 2546 - Solving Performance Problems in CICS using CICS Performance A...
Change Detection Anno Domini 2016
2014 multimuntanya powerpoint_mare de deu_sise_ (2)
2545 Debugging back to-basics
Ad

Similar to Scala.js - yet another what..? (20)

PDF
Lecture1
PDF
Functional Scala 2022 - scalajs Alexis.pdf
PPTX
Introduction to Scala language
PPTX
flatMap Oslo presentation slides
PPTX
PPTX
Scala Italy 2015 - Hands On ScalaJS
PDF
Building Applications with Scala 1st Edition Pacheco
PPTX
Introduction to Scala
PDF
Functional programming in Scala
PDF
Programming in Scala: Notes
PDF
Scala js (kyiv js 30-01)
PDF
Learning Concurrent Programming In Scala Second Edition 2nd Edition Aleksanda...
PPTX
PPTX
Scala-Ls1
PDF
Programming in Scala - Lecture One
PPTX
Scala in practice
PPTX
Scala - The Simple Parts, SFScala presentation
PDF
Learning Concurrent Programming in Scala Second Edition Aleksandar Prokopec
PPTX
Principles of functional progrmming in scala
PDF
Learning Concurrent Programming in Scala Second Edition Aleksandar Prokopec
Lecture1
Functional Scala 2022 - scalajs Alexis.pdf
Introduction to Scala language
flatMap Oslo presentation slides
Scala Italy 2015 - Hands On ScalaJS
Building Applications with Scala 1st Edition Pacheco
Introduction to Scala
Functional programming in Scala
Programming in Scala: Notes
Scala js (kyiv js 30-01)
Learning Concurrent Programming In Scala Second Edition 2nd Edition Aleksanda...
Scala-Ls1
Programming in Scala - Lecture One
Scala in practice
Scala - The Simple Parts, SFScala presentation
Learning Concurrent Programming in Scala Second Edition Aleksandar Prokopec
Principles of functional progrmming in scala
Learning Concurrent Programming in Scala Second Edition Aleksandar Prokopec

More from Artur Skowroński (20)

PDF
Build your own NES Emulator... with Kotlin
PDF
Running Java on Arm - Is it worth it in 2025?
PDF
JVM in the Age of AI: Babylon, Valhalla, TornadoVM and friends
PDF
Kopiąc Trufle - Odkrywanie tajemnic najmniej zrozumiałego elementu GraalVM
PDF
The State of the Green IT at the beginning of 2024
PDF
My chcemy grać w Zielone! Czyli stan świata Green Technology końcówką 2023
PDF
GraalVM, CRaC, Leyden and friends
PDF
Od Czarnoksiężnik z krainy Oz do modeli na produkcji
PDF
JVM Iceberg... we need to go deeper
PDF
JVM Iceberg... we need to go deeper
PDF
Panie, kto tu Panu tak ... - czyli porozmawiajmy o Legacy
PDF
Panie, kto tu Panu tak ... - czyli porozmawiajmy o Legacy
PDF
Ciąg dalszy nastąpi - o wielowątkowości, Projekcie Loom i kotlinowych Korutynach
PDF
Artur Skowroński – Ten Typ tak ma - O systemach typów na przykładzie TypeScri...
PDF
Ten Typ tak ma - O systemach typów na przykładzie TypeScript’a
PDF
Type Systems on the example of TypeScript
PDF
Google Assistant po polsku - developerski punkt widzenia
PDF
Google Assistant & Alexa - Asystenci głosowi: możliwości, podobieństwa, różnice
PDF
To Be Continued - multithreading with Project Loom and Kotlin's Coroutines
PDF
To be Continued - multithreading with Project Loom and Kotlin's Coroutines
Build your own NES Emulator... with Kotlin
Running Java on Arm - Is it worth it in 2025?
JVM in the Age of AI: Babylon, Valhalla, TornadoVM and friends
Kopiąc Trufle - Odkrywanie tajemnic najmniej zrozumiałego elementu GraalVM
The State of the Green IT at the beginning of 2024
My chcemy grać w Zielone! Czyli stan świata Green Technology końcówką 2023
GraalVM, CRaC, Leyden and friends
Od Czarnoksiężnik z krainy Oz do modeli na produkcji
JVM Iceberg... we need to go deeper
JVM Iceberg... we need to go deeper
Panie, kto tu Panu tak ... - czyli porozmawiajmy o Legacy
Panie, kto tu Panu tak ... - czyli porozmawiajmy o Legacy
Ciąg dalszy nastąpi - o wielowątkowości, Projekcie Loom i kotlinowych Korutynach
Artur Skowroński – Ten Typ tak ma - O systemach typów na przykładzie TypeScri...
Ten Typ tak ma - O systemach typów na przykładzie TypeScript’a
Type Systems on the example of TypeScript
Google Assistant po polsku - developerski punkt widzenia
Google Assistant & Alexa - Asystenci głosowi: możliwości, podobieństwa, różnice
To Be Continued - multithreading with Project Loom and Kotlin's Coroutines
To be Continued - multithreading with Project Loom and Kotlin's Coroutines

Scala.js - yet another what..?