SlideShare a Scribd company logo
training@instil.co
September 2018
© Instil Software 2018
Down With JavaScript!
Develop	
Consult	
Train
Where Things Were Better…
Did	you	know	that	the	original	
4GL’s	were	designed	to	be		an	
ideal	coding	environment	for	
GUI’s?	Where	no	one	would	
suffer,	and	everyone	could	
leave	the	office	at	5pm?
Happiness is Visual Basic 6
True Happiness is Delphi
Imagine a Developer Was Frozen in the 1990’s
What Would They Expect?
What Do We Have Instead?
The Myth Of The Full Stack Developer…
But Salvation Is At Hand!!!
But Salvation Is At Hand!!!
React 101
<Ticker	name=“Fred”/>
class	Ticker	extends	React.Component	{	
				constructor(props)	{	
								super(props);	
								this.state	=	{secondsElapsed:	0};	
				}	
				componentDidMount()	{	
								this.interval	=	setInterval(()	=>	this.tick(),	1000);		
				}	
				componentWillUnmount()	{	
								clearInterval(this.interval);		
				}	
				tick()	{	
								this.setState({secondsElapsed:	this.state.secondsElapsed	+	1});	
				}	
				render()	{	
								return	(	
												<div>	
																<h1>Hello,	{this.props.name}!</h1>	
																<p>Page	open	{this.state.secondsElapsed}	seconds.</p>	
												</div>	
								);	
				}	
}
class	Ticker	extends	React.Component	{	
				constructor(props)	{	
								super(props);	
								this.state	=	{secondsElapsed:	0};	
				}	
				componentDidMount()	{	
								this.interval	=	setInterval(()	=>	this.tick(),	1000);		
				}	
				componentWillUnmount()	{	
								clearInterval(this.interval);		
				}	
	
				tick()	{	
								this.setState({secondsElapsed:	this.state.secondsElapsed	+	1});	
				}	
				render()	{	
								return	(	
												<div>	
																<h1>Hello,	{this.props.name}!</h1>	
																<p>Page	open	{this.state.secondsElapsed}	seconds.</p>	
												</div>	
								);	
				}	
}
Initial	State	
Lifecycle	
Methods	
Changing	state	marks	component	as	dirty	
Rendering	uses	embedded	JSX	templating	language
We Still Need Services and a Data Source
Having	defined	the	problem,	the	first	step	
towards	a	solution	is	the	acquisition	of	data.
The Neo4J Desktop
The Neo4J REST API
The Neo4J REST API
© Instil Software 2018
•  Using Kotlin.js
Demo No1
Kotlin.js Support in IntelliJ
Kotlin.js React Support
Kotlin Wrappers Repo
Kotlin Conf Presentation
The Demo…
Summing Up
Scala js with
Slinky
Flames
Flames
➔ Scala code compiled to JS
➔ Full Scala support (apart from reflection)
➔ Fast dev feedback loop
➔ Compact production JS code generated
➔ Performance within 1-3x as optimised JS
➔ Type safety across multiple platforms
What is Scala JS
Scala for JS
Devs
Ref: scala-js.org
JS Comparison: Variables
// mutable variable
let x = 5;
// immutable variable
const y = "Constant";
// mutable variable
var x = 5
// immutable variable
val y = "Constant"
Prefer
Immutability
JS Comparison: Functions
function mult(x, y) {
return x * y;
}
def mult(x: Double,
y: Double): Double = x * y
JS Comparison: Anonymous functions
const f = (x, y) => x + y;
const p = ["Fox", "jumped",
"over", "me"];
const l = p.map(s => s.length)
.reduce((a, b) => a + b, 0);
// == 15
val f = (x: Double,
y: Double) => x + y
val p = Array("Fox", "jumped",
"over", "me")
val l = p.map(s => s.length)
.foldLeft(0)((a,b) => a + b)
// == 15
JS Comparison: Higher order functions
function minmaxBy(arr, f) {
return arr.reduce(
([min, max], e) => {
const v = f(e);
return [Math.min(min, v),
Math.max(max, v)]
},
[Number.MAX_VALUE,Number.MIN_VALUE]
)
}
const [youngest, oldest] =
minmaxBy(persons, e => e.age);
def minmaxBy[T](seq: Seq[T],
f: T => Int): (Int, Int) = {
seq.foldLeft(( Int.MaxValue,
Int.MinValue)) {
case ((min, max), e) =>
val v = f(e)
(math.min(min, v),
math.max(max, v))
}
}
val (youngest, oldest) =
minmaxBy[Person](persons, _.age)
JS Comparison: Futures
function onLoadPromise(img) {
if (img.complete) {
return Promise.resolve(img.src);
} else {
const p = new Promise((success)=> {
img.onload = (e) => {
success(img.src);
};
});
return p;
}
}
def onLoadFuture(img:
HTMLImageElement) = {
if (img.complete) {
Future.successful(img.src)
} else {
val p = Promise[String]()
img.onload = { (e: Event) =>
p.success(img.src)
}
p.future
}
}
Other features
● Traits (Mixins)
● Singleton Objects
● Immutable Collections
● Case Classes
● Tuples
● Pattern Matching / destructuring
● Default parameter values
● Lazy Initialization
● Reified Generics
● TypeClass Support
● Higher Kinded Types Support
● Macros
…….
JavaScript Interop : Facades
@js.native
trait Window extends js.Object {
val document: HTMLDocument = js.native
var location: String = js.native
def innerWidth: Int = js.native
def innerHeight: Int = js.native
…
} Typescript definitions to Scala.js Binding transformer available
https://github.com/sjrd/scala-js-ts-importer
JavaScript Interop : Exposing Scala.js
package example
import scala.scalajs.js.annotation._
@JSExportTopLevel("HelloWorld")
object HelloWorld {
@JSExport
def sayHello(): Unit = {
println("Hello world!")
}
}
HelloWorld.sayHello();
Also @JSExportTopLevel("..")
to export a class
Slinky
➔ Scala JS wrapper for React
➔ Stays close as possible to React
conventions
➔ Excellent integration with existing react
components
React Stateless Component
React Stateless Component expanded
Slinky: getting started
● Dependent on Java 8, SBT, NPM
Demo
Diode
● Immutable application state
● Controlled data flow
● Similar to react
● React components integration
ScalaCSS: Typesafe CSS DSL
Slinky React Native
● Dependent on SBT and Java 8, NPM, xcode
training@instil.co
September 2018
© Instil Software 2018
F# and Fable
Functional Client Side Development
Eamonn.Boyle@instil.co
@BoyleEamonn
F# and Fable
Functional Client Side Development
.NET strongly & statically typed multi-paradigm language
• Imperative
• Object Oriented
• Functional First
Open source, cross platform
• Mono, .NET Framework & .NET Core
Stable – currently on version 4.5 (August 2018)
• Version 1.0 released in 2005
• Passionate Community
A lot of nice C# features originated in F#
F#
Originally a .NET implementation of OCaml so the syntax is similar
Heavy use of type inference
• Expressions, function parameters and return types etc all inferred from usage
• Can reduce the amount of typing (pun intended)
• Can lead to very strange error messages
Focuses on pushing runtime errors to compile time
• Very strict type system
Easy interop with .NET (C#) libraries
F# Syntax
Type bindings and helpers for easy interop with JavaScript
• Including Type Safe helpers for React
Supports most of the F# core library
There’s a tool to convert TypeScript bindings to Fable bindings
• https://github.com/fable-compiler/ts2fable
Fable
Fable is an F# to JavaScript compiler powered by
Babel, designed to produce readable and standard
code.
Elm-like abstractions for F#
Facilitates creating Model-View-Update applications
• Similar to using Redux with something like React
• Does not include the View part, instead you use the Fable React helpers
The main building blocks are
• Model
• Messages
• Commands
• Initialisation
• Update
• Views
• Program
Elmish
© Instil Software 2018
Demo
© Instil Software 2018
The Bad Stuff
“This was the hardest development
experience, period!!”
Type inference can be very confusing
• I enjoy type inference in C#, Kotlin etc
• This is at another level
• Inference in one part of the program can be dictated by usage far away
• This can lead to confusing error messages
• Explicit types can help here
• But then the syntax can be longer than other languages
File order matters – this caught me out a few times
Tooling is not perfect
• I found myself moving between VS Code and JetBrains Rider
Runtime errors can still occur and can be difficult to debug
• Some of the error messages are minimal
The Bad Stuff (very subjective)
I found the React bindings a pain compared to using HTML
• It’s better because it’s type safe but…
• Tooling around HTML + CSS is pretty mature while this isn’t
• More difficult if working with other tools, designers and existing skills
• I find standard JSX with React much easier
White space significance is a pain
I found it difficult to structure the app
• Some blocks of code were getting very large
• I would need to build much larger apps to see how this scales
The Bad Stuff (very subjective)
© Instil Software 2018
The Good Stuff
The language is pretty cool - succinct functional syntax
• Pipes
• Function Composition
• Type Definition and Domain Modeling
• Operator Overloading
• etc
Strict Type System
• Catches a lot of errors
• Exhaustive pattern matching
• Units of measure
• Etc
Easy interop and drop down to OO or imperative style if required
The Good Stuff
This ability to use OO & imperative is essential when targeting JavaScript platform
• Good bindings to access dynamic types
Tooling is very good
• Very quick to create a project from templates
• Visual Studio Code + Ionide is pretty good and is completely free
• HTML to Elmish converter - https://mangelmaxime.github.io/html-to-elmish/
• Hot Module Reloading while retaining state
Elmish MVU pattern is very good and is well implemented
• Very succinct to build up types, state and views
The Good Stuff
© Instil Software 2018
Conclusion
It is very impressive what these projects have accomplished
Some aspects of the development are succinct, safe and neat
If you are a functional fan & especially if doing F#, then this is pretty awesome
My Conclusion
But…
For my money, TypeScript is a better solution
Better balance (compromise) on safety, succinctness & productivity
• Gives me type safety (even if less expressive)
• Much easier interop with JavaScript (it’s a superset)
• Easier consumption of existing JavaScript libraries
• Better tooling
I would stick with standard HTML/JSX for my view definitions
• Not because it is necessarily better for defining views
• Simply because the tooling, documentation and onboarding is easier
Angular has excellent TypeScript APIs
My Conclusion

More Related Content

PDF
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
PDF
Evolving a Clean, Pragmatic Architecture - A Craftsman's Guide
PDF
Tdd is not about testing
PDF
Pure Functions and Immutable Objects
PPTX
Android with kotlin course
PPT
C#/.NET Little Wonders
PDF
OO Design and Design Patterns in C++
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Evolving a Clean, Pragmatic Architecture - A Craftsman's Guide
Tdd is not about testing
Pure Functions and Immutable Objects
Android with kotlin course
C#/.NET Little Wonders
OO Design and Design Patterns in C++

What's hot (16)

PDF
Thinkful - Intro to JavaScript
PDF
Exploring French Job Ads, Lynn Cherny
PDF
The Art of Unit Testing - Towards a Testable Design
PDF
Don't Be Mocked by your Mocks - Best Practices using Mocks
PDF
Introduction to Kotlin coroutines
PDF
Living With Legacy Code
PDF
Transitioning Android Teams Into Kotlin
PPTX
Clean Pragmatic Architecture - Avoiding a Monolith
PPTX
Kotlin for Android - Goto Copenhagan 2019
PDF
Clean architecture - Protecting the Domain
PPTX
Go fundamentals
PPTX
Clean Code with Java 8 - Functional Patterns and Best Practices
PDF
Clean pragmatic architecture @ devflix
PDF
Clean Lambdas & Streams in Java8
PPTX
Clean Code
PDF
Kotlin & arrow: the functional way
Thinkful - Intro to JavaScript
Exploring French Job Ads, Lynn Cherny
The Art of Unit Testing - Towards a Testable Design
Don't Be Mocked by your Mocks - Best Practices using Mocks
Introduction to Kotlin coroutines
Living With Legacy Code
Transitioning Android Teams Into Kotlin
Clean Pragmatic Architecture - Avoiding a Monolith
Kotlin for Android - Goto Copenhagan 2019
Clean architecture - Protecting the Domain
Go fundamentals
Clean Code with Java 8 - Functional Patterns and Best Practices
Clean pragmatic architecture @ devflix
Clean Lambdas & Streams in Java8
Clean Code
Kotlin & arrow: the functional way

Similar to Down With JavaScript! (20)

PPTX
2018-09 - F# and Fable
PPTX
SubmitJS: Is react + redux + typescript a good combination? Dmytro Beseda
PPTX
TDD and the Legacy Code Black Hole
PDF
React Native One Day
KEY
OOP in JS
PPTX
BelTech 2017 - Building Quality in the Browser
PPTX
JS Essence
PDF
JavaScript for impatient programmers.pdf
PDF
Practical JavaScript Programming - Session 8/8
PDF
Pieter De Baets - An introduction to React Native
PDF
Cross-platform UI Engines Rendering Performance
PDF
JAVASCRIPT Test Driven Development & Jasmine
PDF
50 common web developer interview questions [2020 updated] [www.full stack....
PPTX
Frontend War: Angular vs React vs Vue
PDF
Refactoring JavaScript turning bad code into good code First Edition Burchard
PPTX
Awesomeness of JavaScript…almost
PPTX
React & redux
PDF
The Future of JavaScript (Ajax Exp '07)
PPTX
Java 8 - Gateway Drug or End of Line?
PDF
Modern front-end Workflow
2018-09 - F# and Fable
SubmitJS: Is react + redux + typescript a good combination? Dmytro Beseda
TDD and the Legacy Code Black Hole
React Native One Day
OOP in JS
BelTech 2017 - Building Quality in the Browser
JS Essence
JavaScript for impatient programmers.pdf
Practical JavaScript Programming - Session 8/8
Pieter De Baets - An introduction to React Native
Cross-platform UI Engines Rendering Performance
JAVASCRIPT Test Driven Development & Jasmine
50 common web developer interview questions [2020 updated] [www.full stack....
Frontend War: Angular vs React vs Vue
Refactoring JavaScript turning bad code into good code First Edition Burchard
Awesomeness of JavaScript…almost
React & redux
The Future of JavaScript (Ajax Exp '07)
Java 8 - Gateway Drug or End of Line?
Modern front-end Workflow

More from Garth Gilmour (20)

PPTX
Compose in Theory
PPTX
Kotlin / Android Update
PPTX
TypeScript Vs. KotlinJS
PPTX
Shut Up And Eat Your Veg
PPTX
Lies Told By The Kotlin Compiler
PPTX
A TypeScript Fans KotlinJS Adventures
PPTX
The Heat Death Of Enterprise IT
PPTX
Lies Told By The Kotlin Compiler
PPTX
Type Driven Development with TypeScript
PPTX
Generics On The JVM (What you don't know will hurt you)
PPTX
Using Kotlin, to Create Kotlin, to Teach Kotlin, in Space
PPTX
Is Software Engineering A Profession?
PPTX
Social Distancing is not Behaving Distantly
PDF
The Great Scala Makeover
PDF
Simpler and Safer Java Types (via the Vavr and Lambda Libraries)
PDF
The Three Horse Race
PDF
The Bestiary of Pure Functional Programming
PDF
BelTech 2019 Presenters Workshop
PDF
Kotlin The Whole Damn Family
PDF
The Philosophy of DDD
Compose in Theory
Kotlin / Android Update
TypeScript Vs. KotlinJS
Shut Up And Eat Your Veg
Lies Told By The Kotlin Compiler
A TypeScript Fans KotlinJS Adventures
The Heat Death Of Enterprise IT
Lies Told By The Kotlin Compiler
Type Driven Development with TypeScript
Generics On The JVM (What you don't know will hurt you)
Using Kotlin, to Create Kotlin, to Teach Kotlin, in Space
Is Software Engineering A Profession?
Social Distancing is not Behaving Distantly
The Great Scala Makeover
Simpler and Safer Java Types (via the Vavr and Lambda Libraries)
The Three Horse Race
The Bestiary of Pure Functional Programming
BelTech 2019 Presenters Workshop
Kotlin The Whole Damn Family
The Philosophy of DDD

Recently uploaded (20)

PPTX
Introduction to Artificial Intelligence
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
L1 - Introduction to python Backend.pptx
PDF
Understanding Forklifts - TECH EHS Solution
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
medical staffing services at VALiNTRY
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
AI in Product Development-omnex systems
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
ISO 45001 Occupational Health and Safety Management System
PPT
Introduction Database Management System for Course Database
Introduction to Artificial Intelligence
How Creative Agencies Leverage Project Management Software.pdf
Operating system designcfffgfgggggggvggggggggg
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Online Work Permit System for Fast Permit Processing
L1 - Introduction to python Backend.pptx
Understanding Forklifts - TECH EHS Solution
How to Migrate SBCGlobal Email to Yahoo Easily
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
medical staffing services at VALiNTRY
CHAPTER 2 - PM Management and IT Context
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
AI in Product Development-omnex systems
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
ISO 45001 Occupational Health and Safety Management System
Introduction Database Management System for Course Database

Down With JavaScript!