SlideShare a Scribd company logo
Scala.js
Next-gen front end development in Scala
by Otto Chrons, 2015-11-04 @ HelsinkiJS
@ochrons - otto@chrons.me
What does this JavaScript do?
var xhr = new XMLHttpRequest()
xhr.open("GET",
"https://api.twitter.com/1.1/search/" +
"tweets.json?q=%23scalajs"
)
xhr.onload = (e: Event) => {
if (xhr.status == 200) {
var r = JSON.parse(xhr.responseText)
$("#tweets").html(parseTweets(r))
}
}
xhr.send()
Is it actually JavaScript? Look again!
var xhr = new XMLHttpRequest()
xhr.open("GET",
"https://api.twitter.com/1.1/search/" +
"tweets.json?q=%23scalajs"
)
xhr.onload = (e: Event) => {
if (xhr.status == 200) {
var r = JSON.parse(xhr.responseText)
$("#tweets").html(parseTweets(r))
}
}
xhr.send()
It's strongly
typed Scala,
really!
What is Scala.js?
Write Scala, compile to JavaScript, run in browser
Full support of Scala language
Full JavaScript interoperability
As fast code as hand-written JavaScript
Generated JS code is "small enough"
Fast edit-compile-run cycle
Live Demo
How does Scala.js compare to ...
Opal
WebSharper
Everyone wants a better JavaScript
Safer
More modular, expressive, reusable code
One language across client/server
More tool-able & better IDE support
Fewer warts
Why Scala.js?
Safety Expressive Interoperability Toolable
ES6/7 Still un-typed Some new
syntax
Native Still JavaScript
TypeScript Types! Some new
syntax
Native Visual Studio
IntelliJ
ClojureScript Still un-typed Very powerful
language
Complicated Similar to
JavaScript
Dart Types! 50% JS,
50% Java
Complicated Eclipse
IntelliJ
Scala.js Very strong
types!
Very powerful
language
Very good Eclipse
IntelliJ
Why now?
Front end evolution
Stone age
aka
JQuery era
Server-rendered HTML pages
Simple JS animations
Ajax calls to server
Direct DOM manipulation
Medieval times
Rise of the Single Page App
HTML template driven
REST APIs
Angular, Backbone, Ember, ...
Renaissance
JS centric complex apps
DOM is code-generated
GraphQL, Falcor
Rise of transpilers: TS, Babel
React, Angular 2, ...
Next generation
Modern times
Rise of new languages: Scala, Clojure, Dart, TS
Complex client-server systems with shared code
JS reduced to a compile target and platform
Cross-platform: mobile and web
Live Demo 2
(if enough time)
What do JS developers get from Scala.js?
Everything in ES6/7 (=>, destructuring, string-interpolation, ...)
Everything in TypeScript (types, generics, ...)
Everything in Immutable.js (immutable collections)
+
Great language, extensive standard library, functional
programming, access to all JS libs and peace of mind 😌
How to get started?
www.scala-js.org
new website at
http://tiny.cc/sjs-new
Gitter room
https://gitter.im/scala-js/scala-js

More Related Content

What's hot

Airbnb Search Architecture: Presented by Maxim Charkov, Airbnb
Airbnb Search Architecture: Presented by Maxim Charkov, AirbnbAirbnb Search Architecture: Presented by Maxim Charkov, Airbnb
Airbnb Search Architecture: Presented by Maxim Charkov, Airbnb
Lucidworks
 
HBase RowKey design for Akka Persistence
HBase RowKey design for Akka PersistenceHBase RowKey design for Akka Persistence
HBase RowKey design for Akka Persistence
Konrad Malawski
 
Log analysis with the elk stack
Log analysis with the elk stackLog analysis with the elk stack
Log analysis with the elk stack
Vikrant Chauhan
 
How ElasticSearch lives in my DevOps life
How ElasticSearch lives in my DevOps lifeHow ElasticSearch lives in my DevOps life
How ElasticSearch lives in my DevOps life琛琳 饶
 
Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014Holden Karau
 
Connect S3 with Kafka using Akka Streams
Connect S3 with Kafka using Akka Streams Connect S3 with Kafka using Akka Streams
Connect S3 with Kafka using Akka Streams
Seiya Mizuno
 
Analyzing Log Data With Apache Spark
Analyzing Log Data With Apache SparkAnalyzing Log Data With Apache Spark
Analyzing Log Data With Apache Spark
Spark Summit
 
Scalable Applications with Scala
Scalable Applications with ScalaScalable Applications with Scala
Scalable Applications with ScalaNimrod Argov
 
Reactive streams processing using Akka Streams
Reactive streams processing using Akka StreamsReactive streams processing using Akka Streams
Reactive streams processing using Akka Streams
Johan Andrén
 
ELK Stack
ELK StackELK Stack
ELK Stack
Phuc Nguyen
 
Using akka streams to access s3 objects
Using akka streams to access s3 objectsUsing akka streams to access s3 objects
Using akka streams to access s3 objects
Mikhail Girkin
 
Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)
Tzach Zohar
 
Reactive stream processing using Akka streams
Reactive stream processing using Akka streams Reactive stream processing using Akka streams
Reactive stream processing using Akka streams
Johan Andrén
 
Akka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutesAkka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutes
Konrad Malawski
 
Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015
Jose Luis Martínez
 
My Top 5 APEX JavaScript API's
My Top 5 APEX JavaScript API'sMy Top 5 APEX JavaScript API's
My Top 5 APEX JavaScript API's
Roel Hartman
 
Next generation actors with Akka
Next generation actors with AkkaNext generation actors with Akka
Next generation actors with Akka
Johan Andrén
 
2014 akka-streams-tokyo-japanese
2014 akka-streams-tokyo-japanese2014 akka-streams-tokyo-japanese
2014 akka-streams-tokyo-japanese
Konrad Malawski
 
Reactive Streams / Akka Streams - GeeCON Prague 2014
Reactive Streams / Akka Streams - GeeCON Prague 2014Reactive Streams / Akka Streams - GeeCON Prague 2014
Reactive Streams / Akka Streams - GeeCON Prague 2014
Konrad Malawski
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Roel Hartman
 

What's hot (20)

Airbnb Search Architecture: Presented by Maxim Charkov, Airbnb
Airbnb Search Architecture: Presented by Maxim Charkov, AirbnbAirbnb Search Architecture: Presented by Maxim Charkov, Airbnb
Airbnb Search Architecture: Presented by Maxim Charkov, Airbnb
 
HBase RowKey design for Akka Persistence
HBase RowKey design for Akka PersistenceHBase RowKey design for Akka Persistence
HBase RowKey design for Akka Persistence
 
Log analysis with the elk stack
Log analysis with the elk stackLog analysis with the elk stack
Log analysis with the elk stack
 
How ElasticSearch lives in my DevOps life
How ElasticSearch lives in my DevOps lifeHow ElasticSearch lives in my DevOps life
How ElasticSearch lives in my DevOps life
 
Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014
 
Connect S3 with Kafka using Akka Streams
Connect S3 with Kafka using Akka Streams Connect S3 with Kafka using Akka Streams
Connect S3 with Kafka using Akka Streams
 
Analyzing Log Data With Apache Spark
Analyzing Log Data With Apache SparkAnalyzing Log Data With Apache Spark
Analyzing Log Data With Apache Spark
 
Scalable Applications with Scala
Scalable Applications with ScalaScalable Applications with Scala
Scalable Applications with Scala
 
Reactive streams processing using Akka Streams
Reactive streams processing using Akka StreamsReactive streams processing using Akka Streams
Reactive streams processing using Akka Streams
 
ELK Stack
ELK StackELK Stack
ELK Stack
 
Using akka streams to access s3 objects
Using akka streams to access s3 objectsUsing akka streams to access s3 objects
Using akka streams to access s3 objects
 
Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)
 
Reactive stream processing using Akka streams
Reactive stream processing using Akka streams Reactive stream processing using Akka streams
Reactive stream processing using Akka streams
 
Akka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutesAkka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutes
 
Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015
 
My Top 5 APEX JavaScript API's
My Top 5 APEX JavaScript API'sMy Top 5 APEX JavaScript API's
My Top 5 APEX JavaScript API's
 
Next generation actors with Akka
Next generation actors with AkkaNext generation actors with Akka
Next generation actors with Akka
 
2014 akka-streams-tokyo-japanese
2014 akka-streams-tokyo-japanese2014 akka-streams-tokyo-japanese
2014 akka-streams-tokyo-japanese
 
Reactive Streams / Akka Streams - GeeCON Prague 2014
Reactive Streams / Akka Streams - GeeCON Prague 2014Reactive Streams / Akka Streams - GeeCON Prague 2014
Reactive Streams / Akka Streams - GeeCON Prague 2014
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
 

Similar to Scala.js: Next generation front end development in Scala

JavaScript Lessons 2023
JavaScript Lessons 2023JavaScript Lessons 2023
JavaScript Lessons 2023
Laurence Svekis ✔
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
Andy McKay
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
Stuart Roebuck
 
Opa presentation at GamesJs
Opa presentation at GamesJsOpa presentation at GamesJs
Opa presentation at GamesJsHenri Binsztok
 
From Node to Go
From Node to GoFrom Node to Go
From Node to Go
John Maxwell
 
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data EcosystemWprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Sages
 
Document Conversion & Retrieve and Rank 一問一答
Document Conversion & Retrieve and Rank 一問一答Document Conversion & Retrieve and Rank 一問一答
Document Conversion & Retrieve and Rank 一問一答
Hisashi Komine
 
Luis Atencio on RxJS
Luis Atencio on RxJSLuis Atencio on RxJS
Luis Atencio on RxJS
Luis Atencio
 
Pick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruitPick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruit
Vaclav Pech
 
Pragmatic Real-World Scala
Pragmatic Real-World ScalaPragmatic Real-World Scala
Pragmatic Real-World Scalaparag978978
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
Jonas Bonér
 
Introduction to-scala
Introduction to-scalaIntroduction to-scala
Introduction to-scala
Hamid Jafarian
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVMVaclav Pech
 
用Tornado开发RESTful API运用
用Tornado开发RESTful API运用用Tornado开发RESTful API运用
用Tornado开发RESTful API运用Felinx Lee
 

Similar to Scala.js: Next generation front end development in Scala (20)

Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
huhu
huhuhuhu
huhu
 
JavaScript Lessons 2023
JavaScript Lessons 2023JavaScript Lessons 2023
JavaScript Lessons 2023
 
Os Pruett
Os PruettOs Pruett
Os Pruett
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
Opa presentation at GamesJs
Opa presentation at GamesJsOpa presentation at GamesJs
Opa presentation at GamesJs
 
From Node to Go
From Node to GoFrom Node to Go
From Node to Go
 
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data EcosystemWprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
 
Document Conversion & Retrieve and Rank 一問一答
Document Conversion & Retrieve and Rank 一問一答Document Conversion & Retrieve and Rank 一問一答
Document Conversion & Retrieve and Rank 一問一答
 
Luis Atencio on RxJS
Luis Atencio on RxJSLuis Atencio on RxJS
Luis Atencio on RxJS
 
Pick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruitPick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruit
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
Pragmatic Real-World Scala
Pragmatic Real-World ScalaPragmatic Real-World Scala
Pragmatic Real-World Scala
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
 
Introduction to-scala
Introduction to-scalaIntroduction to-scala
Introduction to-scala
 
JQuery Flot
JQuery FlotJQuery Flot
JQuery Flot
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVM
 
Not your Grandma's XQuery
Not your Grandma's XQueryNot your Grandma's XQuery
Not your Grandma's XQuery
 
用Tornado开发RESTful API运用
用Tornado开发RESTful API运用用Tornado开发RESTful API运用
用Tornado开发RESTful API运用
 

Recently uploaded

Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 

Recently uploaded (20)

Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 

Scala.js: Next generation front end development in Scala

  • 1. Scala.js Next-gen front end development in Scala by Otto Chrons, 2015-11-04 @ HelsinkiJS @ochrons - otto@chrons.me
  • 2. What does this JavaScript do? var xhr = new XMLHttpRequest() xhr.open("GET", "https://api.twitter.com/1.1/search/" + "tweets.json?q=%23scalajs" ) xhr.onload = (e: Event) => { if (xhr.status == 200) { var r = JSON.parse(xhr.responseText) $("#tweets").html(parseTweets(r)) } } xhr.send()
  • 3. Is it actually JavaScript? Look again! var xhr = new XMLHttpRequest() xhr.open("GET", "https://api.twitter.com/1.1/search/" + "tweets.json?q=%23scalajs" ) xhr.onload = (e: Event) => { if (xhr.status == 200) { var r = JSON.parse(xhr.responseText) $("#tweets").html(parseTweets(r)) } } xhr.send() It's strongly typed Scala, really!
  • 4. What is Scala.js? Write Scala, compile to JavaScript, run in browser Full support of Scala language Full JavaScript interoperability As fast code as hand-written JavaScript Generated JS code is "small enough" Fast edit-compile-run cycle
  • 6. How does Scala.js compare to ... Opal WebSharper
  • 7. Everyone wants a better JavaScript Safer More modular, expressive, reusable code One language across client/server More tool-able & better IDE support Fewer warts
  • 8. Why Scala.js? Safety Expressive Interoperability Toolable ES6/7 Still un-typed Some new syntax Native Still JavaScript TypeScript Types! Some new syntax Native Visual Studio IntelliJ ClojureScript Still un-typed Very powerful language Complicated Similar to JavaScript Dart Types! 50% JS, 50% Java Complicated Eclipse IntelliJ Scala.js Very strong types! Very powerful language Very good Eclipse IntelliJ
  • 9. Why now? Front end evolution Stone age aka JQuery era Server-rendered HTML pages Simple JS animations Ajax calls to server Direct DOM manipulation Medieval times Rise of the Single Page App HTML template driven REST APIs Angular, Backbone, Ember, ... Renaissance JS centric complex apps DOM is code-generated GraphQL, Falcor Rise of transpilers: TS, Babel React, Angular 2, ...
  • 10. Next generation Modern times Rise of new languages: Scala, Clojure, Dart, TS Complex client-server systems with shared code JS reduced to a compile target and platform Cross-platform: mobile and web
  • 11. Live Demo 2 (if enough time)
  • 12. What do JS developers get from Scala.js? Everything in ES6/7 (=>, destructuring, string-interpolation, ...) Everything in TypeScript (types, generics, ...) Everything in Immutable.js (immutable collections) + Great language, extensive standard library, functional programming, access to all JS libs and peace of mind 😌
  • 13. How to get started? www.scala-js.org new website at http://tiny.cc/sjs-new Gitter room https://gitter.im/scala-js/scala-js

Editor's Notes

  1. Hello everyone, my name is Otto and I'm going to talk about how to build next gen front end applications in Scala using Scala.js I'm a cofounder and CTO at Microtask and we've been using Scala on the server side for about 3 years and Scala.js on the front end for a little over half a year. Before that we had both GWT (java) and Angular JS apps. Let's start by taking a short poll. How many of you use JavaScript at work, hands up! Ok, and how many know Scala or have done something with Scala? How about using Scala at a work project? Ok, not so many.
  2. To get your brains activated, please look at the following JS code and tell me what it does. Should be quite familiar to any experienced JS developer :) Got it yet? Yes, it fetches some data from Twitter and uses JQuery to render the parsed tweets in an element identified by "tweets".
  3. Did you notice something strange about it? Maybe take another look. There seems to be a type definition on the function parameter, so maybe this is actually TypeScript? Well, it actually could be, but in reality it's just normal strongly typed Scala code. I bet most of you could read Scala.js code quite easily!
  4. Now, what is Scala.js? It's a Scala to JavaScript compiler that allows you to write normal Scala code, compile it to JS and run in a browser (or in Node.js if you want) It supports the full range of Scala language features, which is no small feat since Scala is quite an extensive multi-paradigm language. It also gives you full interoperability with all existing JavaScript code base, so you can use libraries like React and JQuery from your Scala code very easily. The compiler produces highly optimized Javascript, comparable in performance to hand-written JS, sometimes even a bit faster! Scala.js runs the produced code through Google Closure Compiler further doing DCE and minifaction, resulting in reasonably small JS file. Typically a few hundred kilobytes, including all the Scala libraries you use. Seeing the effects of your changes is fast, not quite as fast as with some JS transpilers, but fast enough to not be annoying. we're talking about 2-5 seconds here. And you don't need to do this so often as IDE and the compiler help so much
  5. Let's do a quick live demo to see what working with Scala.js is really like! .... As you saw, the code is nice and readable with great support from the IDE.
  6. There are literally hundreds of X to JavaScript compilers and transpilers out there because JavaScript is such a great platform for running code on all kinds of devices. But why do things like CoffeeScript, Dart and TypeScript exist?
  7. As great as JavaScript is as a platform, it lacks severly as a programming language. We all want better safety, to protect us from our own mistakes. Having Modularity is great and a highly experssive language gets more things done in a shorter time. Having one language across client and server, being able to reuse code and developers, which is a great benefit. When applications get more complex, the tooling and IDE support has to be there so you don't spend half your time googling around. And of course fewer warts that bite you when you least expect them.
  8. So, why Scala.js? Even though ES6 brought a lot of improvements to the JS language, it's still very unsafe and lacks in the tooling department. The IDEs try their best, but they simply cannot do much when it comes to vanilla JS code. TypeScript is addressing many issues in JS and has now support from the big players including of course Microsoft, but also Google in Angular2. But it's still Javascript :) ClojureScript is based on Clojure, a functional language much like Lisp, making it very powerful. But as it lacks static typing, it's also hard for IDEs. Interoperability with existing Javascript is quite complicated. Dart from Google is a new language inspired by JavaScript and Java (whether that's good or bad) and has a good type system. But its interoperability is not so great. Scala.js being Scala of course has very strong type system and has superb IDE support as we saw in the live demo. Core focus of Scala.js has been interoperability with JS which is where it really shines compared to many alternatives. Even though the Scala language is sometimes seen as complicated, it's really easy to get started and then move on to more complex things as you get familiar with the language.
  9. To understand why we are seeing such a boom in JS alternatives right now, we have to take a look at the evolution of front end development. It all starts in the stone age where JQuery is the king-of-the-hill when it comes to JS programming. Web pages are rendered server side and JS is really only used for simple animations and for making UX more bearable. More advanced sites are using Ajax to make live updates by doing direct DOM manipulation. At some point the applications started becoming more complex, so smart guys started thinking other ways of doing web apps and the Single Page App was born. Here we see a lot more JS being used, driven by HTML templates. REST APIs become the norm for communication and we get a lot of frameworks like Backbone, Ember and Angular. But as application complixity keeps growing, devs start seeing the problems with the HTML template driven approach so a new breed of architectures like React emerge. This time JavaScript is on the center stage, doing all the work from DOM generation to server communication. The REST model gives way to more flexible communication methods like GraphQL and Falcor. Alternatives to vanilla JS start to gain traction and the whole transpiler industry is born with the likes of TypeScript and Babel etc.
  10. But we don't want to get stuck with renaissance, what about the next generation? As complexity and application size grows, managing and refactoring large JS projects becomes quite challenging. New languages like Scala and Clojure enter the world of front end development. I would actually say that none of you in the audience is coding vanilla JS in five years time. With nodejs the front end language got traction on the server side, but now solid server side languages are moving on the front end to facilitate sharing code in complex applications. Over time Javascript is reduced to a compiler target, much like x86 assembly language, but continues to provide a great platform for applications. We're now seeing the first attempts at doing real cross-platform development on mobile and web, not just by running a browser view in a mobile app, but using native controls. You can actually now write your code in Scala, compile it to Javascript and run it natively under iOS or Android using React Native.
  11. Let's quickly look at a bit more realistic example of doing client-server in Scala.js and React
  12. So, you've been a happy puppy with JavaScript, why would you consider learning a new language and using Scala.js? First of all you get literally every language feature in ES6 and ES7, including the fat arrow, destructuring, string-interpolation, async/await etc. You also get everything in TypeScript like decent types, generics, etc. Not to mention stuff like Immutable.js, which is an immutable collection library for JavaScript. Guess what those collection algorithms are based on? Scala and Clojure collection libraries! So, you get everything JS has to offer, plus a great language, with which programming is really fun, a truly extensive standard library, access to real functional programming and associated FP libraries and but you still can use all the JS libs you know and love. Finally you get a peace of mind; when you make that critical edit at 2am to fix a bug in production, it's just going to work ok, not blow up as an Uncaught typeerror: undefined is not a function.
  13. If you got interested, head to the links shown on the slide and start learning. We are about to launch a new version of the Scala.js site, so please check out the lower link as well that will direct you to the beta site. Any questions?