SlideShare a Scribd company logo
An introduction to scala-js
Presented By: Divyanshu Srivastava
Software Consultant
Knoldus Inc.
About Knoldus
Knoldus is a technology consulting firm with focus on modernizing the digital systems
at the pace your business demands.
DevOps
Functional. Reactive. Cloud Native
Our Agenda
● Introduction to Scala.js
● Code Comparison: JS & Scala.js
● Code Comparison: TypeScript & Scala.js
● Chart based comparison : JS, TypeScript & Scala.js
● Demo
● Community Support
● References
Introduction
The Scala Programming Language
Scala combines object-oriented and functional
programming in one concise, high-level language.
Scala's static types help avoid bugs in complex
applications, and its JVM and JavaScript runtimes let
you build high-performance systems with easy access
to huge ecosystems of libraries.
- scala-lang.org
Why Scala.js?
● Correctness :-
Strong typing guarantees our code to be free from silly mistakes.
● Performance :-
Scala.js optimizes our Scala code into highly efficient JavaScript.
● Interoperability:-
We can use any JavaScript library right from our Scala.js code,
either in a statically or dynamically typed way, including most popular
one React and AngularJs
● Excellent editor support: -
With Scala.js, typos and type-errors are immediately caught and
shown on our editor, without even needing to compile our code,
refactor any field or method with ease.
Code Comparison: JS & Scala.js
JS & Scala.js
class Person
{
constructor(firstName, lastName)
{
this.firstName = firstName;
this.lastName = lastName;
}
fullName()
{
return `${this.firstName} ${this.lastName}`;
}
}
class Person(val firstName: String,
val lastName: String)
{
def fullName(): String =
s"$firstName $lastName"
}
JS & Scala.js
console.log("Hello World!"); println("Hello World!")
const names = persons
.map(p =>p.firstName);
val names = persons
.map(p => p.firstName)
val names = persons.map(_.firstName)
JS & Scala.js
const personMap = new Map([
[10, new Person("Roger", "Moore")],
[20, new Person("James", "Bond")]]);
const names = [];
for (const [key, person] of personMap)
{
if (key > 15)
{
names.push(`${key} = ${person.firstName}`);
}
}
val personMap = Map(
10 -> new Person("Roger", "Moore"),
20 -> new Person("James", "Bond"))
val names = for
{
(key, person) <- personMap
if key > 15
} yield s"$key = ${person.firstName}"
JS & Scala.js
const xhr = new XMLHttpRequest();
xhr.open("GET", "http://localhost:8080”);
xhr.onload = (e) =>
{
if (xhr.status === 200)
{
const r =
JSON.parse(xhr.responseText);
$("#id").html(parse(r));
}
};
xhr.send();
val xhr = new XMLHttpRequest()
xhr.open("GET", "http://localhost:8080”)
xhr.onload =
{
(e: Event) =>
if (xhr.status == 200)
{
val r =
JSON.parse(xhr.responseText)
$("#id").html(parse(r))
}
}
xhr.send()
Code Comparison: TypeScript & Scala.js
TypeScript & Scala.js
class Person
{
public firstName: String;
public lastName: String;
constructor(firstName: string,
lastName: string)
{
this.firstName = firstName;
this.lastName = lastName;
}
fullName()
{
return `${this.firstName} ${this.lastName}`;
}
}
class Person(val firstName: String,
val lastName: String)
{
def fullName(): String =
s"$firstName $lastName"
}
TypeScript & Scala.js
console.log("Hello World!"); println("Hello World!")
const names = persons
.map(p =>p.firstName);
val names = persons
.map(p => p.firstName)
val names = persons.map(_.firstName)
TypeScript & Scala.js
const personMap = new Map<number, Person>([
[10, new Person("Roger", "Moore")],
[20, new Person("James", "Bond")]]);
const names = new Array<string>();
for (const [key, person] of personMap)
{
if (key > 15)
{
names.push(`${key} = ${person.firstName}`);
}
}
val personMap = Map(
10 -> new Person("Roger", "Moore"),
20 -> new Person("James", "Bond"))
val names = for
{
(key, person) <- personMap
if key > 15
} yield s"$key = ${person.firstName}"
Chart based comparison : JS, TypeScript & Scala.js
An introduction to Scala.js
DEMO
Community Support
● https://stackoverflow.com/users/1829647/sjrd -> @sjrd author of scala-js and very much active to
answer the query related to Scala-js.
● https://stackoverflow.com/ -> Stack Overflow has good community support for scala-js with tag as
[scala.js].
● https://gitter.im/scala-js/scala-js -> Gitter channel for scala-js for quick and fast response.
● https://www.scala-js.org/
● https://www.scala-js.org/doc/sjs-for-js/
● https://www.lihaoyi.com/hands-on-scala-js/#GettingStarted
● https://www.scala-lang.org/
References
Thank You!
divyanshu.srivastava@knoldus.com
https://in.linkedin.com/in/divyanshu-sriva
stava-1a4968167

More Related Content

PDF
Nestoria new design
PPTX
Working with NoSQL in a SQL Database (XDevApi)
PPTX
NoSQL in SQL - Lior Altarescu
PDF
Tools and Projects Dec 2018 Edition
PDF
Scaling MongoDB; Sharding Into and Beyond the Multi-Terabyte Range
PDF
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
PDF
Leave your Room behind - UA Mobile 2019
PPTX
Node.js and angular js
Nestoria new design
Working with NoSQL in a SQL Database (XDevApi)
NoSQL in SQL - Lior Altarescu
Tools and Projects Dec 2018 Edition
Scaling MongoDB; Sharding Into and Beyond the Multi-Terabyte Range
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
Leave your Room behind - UA Mobile 2019
Node.js and angular js

What's hot (20)

PPSX
Logging your node.js application
PDF
NoSQL - An introduction to CouchDB
PDF
MySQL Without The SQL -- Oh My! PHP Detroit July 2018
PDF
Enonic Content Repository built on elasticsearch
PDF
MySQL Without the SQL - Oh My! August 2nd presentation at Mid Atlantic Develo...
PDF
Scalaで実装してみる簡易ブロックチェーン
PDF
Datacon LA - MySQL without the SQL - Oh my!
PPTX
Mongo db 101 dc group
PDF
jQuery's Secrets
PDF
Converting a Rails application to Node.js
PPTX
Using Arbor/ RGraph JS libaries for Data Visualisation
PDF
はじめてのMongoDB
KEY
Mongo db presentation
PPTX
Querying mongo db
PPT
Play With Theschwartz
PPTX
PPTX
12c Mini Lesson - JSON in the database
PDF
JSONSchema with golang
PPTX
HTML Views: Where are my classes gone?
PPTX
Mythbusting: Understanding How We Measure the Performance of MongoDB
Logging your node.js application
NoSQL - An introduction to CouchDB
MySQL Without The SQL -- Oh My! PHP Detroit July 2018
Enonic Content Repository built on elasticsearch
MySQL Without the SQL - Oh My! August 2nd presentation at Mid Atlantic Develo...
Scalaで実装してみる簡易ブロックチェーン
Datacon LA - MySQL without the SQL - Oh my!
Mongo db 101 dc group
jQuery's Secrets
Converting a Rails application to Node.js
Using Arbor/ RGraph JS libaries for Data Visualisation
はじめてのMongoDB
Mongo db presentation
Querying mongo db
Play With Theschwartz
12c Mini Lesson - JSON in the database
JSONSchema with golang
HTML Views: Where are my classes gone?
Mythbusting: Understanding How We Measure the Performance of MongoDB
Ad

Similar to An introduction to Scala.js (20)

PDF
Scala js (kyiv js 30-01)
PPTX
Alberto Paro - Hands on Scala.js
PPTX
Scala Italy 2015 - Hands On ScalaJS
PPTX
Scala.js for large and complex frontend apps
PPTX
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
PPTX
Scala.js
ODP
Introduction to Scala JS
PPTX
Scala-Ls1
PDF
Software Engineering Thailand: Programming with Scala
ODP
PDF
An Introduction to Scala JS
PDF
Building Applications with Scala 1st Edition Pacheco
PDF
Scala for Java Programmers
PDF
A Brief, but Dense, Intro to Scala
PDF
Intro to Scala.js - Scala UG Cologne
PPTX
Scala, Play 2.0 & Cloud Foundry
PDF
Quick introduction to scala
PDF
Short intro to scala and the play framework
PDF
Play framework
PDF
Scala Intro
Scala js (kyiv js 30-01)
Alberto Paro - Hands on Scala.js
Scala Italy 2015 - Hands On ScalaJS
Scala.js for large and complex frontend apps
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Scala.js
Introduction to Scala JS
Scala-Ls1
Software Engineering Thailand: Programming with Scala
An Introduction to Scala JS
Building Applications with Scala 1st Edition Pacheco
Scala for Java Programmers
A Brief, but Dense, Intro to Scala
Intro to Scala.js - Scala UG Cologne
Scala, Play 2.0 & Cloud Foundry
Quick introduction to scala
Short intro to scala and the play framework
Play framework
Scala Intro
Ad

More from Knoldus Inc. (20)

PPTX
Angular Hydration Presentation (FrontEnd)
PPTX
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
PPTX
Self-Healing Test Automation Framework - Healenium
PPTX
Kanban Metrics Presentation (Project Management)
PPTX
Java 17 features and implementation.pptx
PPTX
Chaos Mesh Introducing Chaos in Kubernetes
PPTX
GraalVM - A Step Ahead of JVM Presentation
PPTX
Nomad by HashiCorp Presentation (DevOps)
PPTX
Nomad by HashiCorp Presentation (DevOps)
PPTX
DAPR - Distributed Application Runtime Presentation
PPTX
Introduction to Azure Virtual WAN Presentation
PPTX
Introduction to Argo Rollouts Presentation
PPTX
Intro to Azure Container App Presentation
PPTX
Insights Unveiled Test Reporting and Observability Excellence
PPTX
Introduction to Splunk Presentation (DevOps)
PPTX
Code Camp - Data Profiling and Quality Analysis Framework
PPTX
AWS: Messaging Services in AWS Presentation
PPTX
Amazon Cognito: A Primer on Authentication and Authorization
PPTX
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
PPTX
Managing State & HTTP Requests In Ionic.
Angular Hydration Presentation (FrontEnd)
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Self-Healing Test Automation Framework - Healenium
Kanban Metrics Presentation (Project Management)
Java 17 features and implementation.pptx
Chaos Mesh Introducing Chaos in Kubernetes
GraalVM - A Step Ahead of JVM Presentation
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
DAPR - Distributed Application Runtime Presentation
Introduction to Azure Virtual WAN Presentation
Introduction to Argo Rollouts Presentation
Intro to Azure Container App Presentation
Insights Unveiled Test Reporting and Observability Excellence
Introduction to Splunk Presentation (DevOps)
Code Camp - Data Profiling and Quality Analysis Framework
AWS: Messaging Services in AWS Presentation
Amazon Cognito: A Primer on Authentication and Authorization
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Managing State & HTTP Requests In Ionic.

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PPT
Teaching material agriculture food technology
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Cloud computing and distributed systems.
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Encapsulation theory and applications.pdf
PDF
KodekX | Application Modernization Development
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
cuic standard and advanced reporting.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
sap open course for s4hana steps from ECC to s4
Teaching material agriculture food technology
Understanding_Digital_Forensics_Presentation.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Cloud computing and distributed systems.
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Spectroscopy.pptx food analysis technology
Advanced methodologies resolving dimensionality complications for autism neur...
Encapsulation theory and applications.pdf
KodekX | Application Modernization Development
NewMind AI Weekly Chronicles - August'25 Week I
cuic standard and advanced reporting.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Encapsulation_ Review paper, used for researhc scholars
Mobile App Security Testing_ A Comprehensive Guide.pdf
Building Integrated photovoltaic BIPV_UPV.pdf

An introduction to Scala.js

  • 1. An introduction to scala-js Presented By: Divyanshu Srivastava Software Consultant Knoldus Inc.
  • 2. About Knoldus Knoldus is a technology consulting firm with focus on modernizing the digital systems at the pace your business demands. DevOps Functional. Reactive. Cloud Native
  • 3. Our Agenda ● Introduction to Scala.js ● Code Comparison: JS & Scala.js ● Code Comparison: TypeScript & Scala.js ● Chart based comparison : JS, TypeScript & Scala.js ● Demo ● Community Support ● References
  • 5. The Scala Programming Language Scala combines object-oriented and functional programming in one concise, high-level language. Scala's static types help avoid bugs in complex applications, and its JVM and JavaScript runtimes let you build high-performance systems with easy access to huge ecosystems of libraries. - scala-lang.org
  • 6. Why Scala.js? ● Correctness :- Strong typing guarantees our code to be free from silly mistakes. ● Performance :- Scala.js optimizes our Scala code into highly efficient JavaScript. ● Interoperability:- We can use any JavaScript library right from our Scala.js code, either in a statically or dynamically typed way, including most popular one React and AngularJs ● Excellent editor support: - With Scala.js, typos and type-errors are immediately caught and shown on our editor, without even needing to compile our code, refactor any field or method with ease.
  • 7. Code Comparison: JS & Scala.js
  • 8. JS & Scala.js class Person { constructor(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } fullName() { return `${this.firstName} ${this.lastName}`; } } class Person(val firstName: String, val lastName: String) { def fullName(): String = s"$firstName $lastName" }
  • 9. JS & Scala.js console.log("Hello World!"); println("Hello World!") const names = persons .map(p =>p.firstName); val names = persons .map(p => p.firstName) val names = persons.map(_.firstName)
  • 10. JS & Scala.js const personMap = new Map([ [10, new Person("Roger", "Moore")], [20, new Person("James", "Bond")]]); const names = []; for (const [key, person] of personMap) { if (key > 15) { names.push(`${key} = ${person.firstName}`); } } val personMap = Map( 10 -> new Person("Roger", "Moore"), 20 -> new Person("James", "Bond")) val names = for { (key, person) <- personMap if key > 15 } yield s"$key = ${person.firstName}"
  • 11. JS & Scala.js const xhr = new XMLHttpRequest(); xhr.open("GET", "http://localhost:8080”); xhr.onload = (e) => { if (xhr.status === 200) { const r = JSON.parse(xhr.responseText); $("#id").html(parse(r)); } }; xhr.send(); val xhr = new XMLHttpRequest() xhr.open("GET", "http://localhost:8080”) xhr.onload = { (e: Event) => if (xhr.status == 200) { val r = JSON.parse(xhr.responseText) $("#id").html(parse(r)) } } xhr.send()
  • 13. TypeScript & Scala.js class Person { public firstName: String; public lastName: String; constructor(firstName: string, lastName: string) { this.firstName = firstName; this.lastName = lastName; } fullName() { return `${this.firstName} ${this.lastName}`; } } class Person(val firstName: String, val lastName: String) { def fullName(): String = s"$firstName $lastName" }
  • 14. TypeScript & Scala.js console.log("Hello World!"); println("Hello World!") const names = persons .map(p =>p.firstName); val names = persons .map(p => p.firstName) val names = persons.map(_.firstName)
  • 15. TypeScript & Scala.js const personMap = new Map<number, Person>([ [10, new Person("Roger", "Moore")], [20, new Person("James", "Bond")]]); const names = new Array<string>(); for (const [key, person] of personMap) { if (key > 15) { names.push(`${key} = ${person.firstName}`); } } val personMap = Map( 10 -> new Person("Roger", "Moore"), 20 -> new Person("James", "Bond")) val names = for { (key, person) <- personMap if key > 15 } yield s"$key = ${person.firstName}"
  • 16. Chart based comparison : JS, TypeScript & Scala.js
  • 18. DEMO
  • 19. Community Support ● https://stackoverflow.com/users/1829647/sjrd -> @sjrd author of scala-js and very much active to answer the query related to Scala-js. ● https://stackoverflow.com/ -> Stack Overflow has good community support for scala-js with tag as [scala.js]. ● https://gitter.im/scala-js/scala-js -> Gitter channel for scala-js for quick and fast response.
  • 20. ● https://www.scala-js.org/ ● https://www.scala-js.org/doc/sjs-for-js/ ● https://www.lihaoyi.com/hands-on-scala-js/#GettingStarted ● https://www.scala-lang.org/ References