32
JS S I M O N B E L A K @SBELAK

Escape from JS

Embed Size (px)

Citation preview

JSS I M O N B E L A K

@SBELAK

Javascript is …

… ubiquitous

Javascript is …

… ubiquitous

… (surprisingly) fast

… ubiquitous

… (surprisingly) fast

… SHIT

Javascript is …

Transpiling to JS: have your cake and eat it too

source code compiler JS

Transpiling to JS: have your cake and eat it too

source code compiler JS

bootstrap +

selfhosted

compile to JS(no runtime)

• ClojureScript • Elm • PureScript

ClojureScript

CLJS at a glance• Dialect of Clojure (code mostly interoperable,

different libraries on different runtimes)

• Functional, dynamic, immutable

• Bootstrapped + self hosted, impeccable JS interoperability

• Uses Google Closure as core library & complier

What makes it special

• Emphasis on concurrency and state management

• Unparalleled data manipulation

• Homoiconicity & macros (code = data)

code

data

code

data =AST

Macroscode that writes code

A live environment

System paradigmLanguage paradigm

infoq.com/presentations/Mixin-based-Inheritance realworldclojure.com/the-system-paradigm

The system paradigm

1. Nibble at the problem from different directions

2. Compose partial solutions into the final solution

Elm

Elm at a glance

• Statically typed & strict: no null, undefined or runtime exceptions

• Functional & pure

• Compiles to JS, limited interoperation with JS (via Ports)

What makes it special• Front-end building language

• Optimized for simplicity, friendliness. Fantastic error messages.

• Package system enforces semantic versioning

• Reactive by design (Model-Update-View architecture)

The program is a pure function that's being evaluated in a loop over the inputs. Impureness is pushed to the runtime where it can be controlled (via Mailboxes).

Initial state: [“”] [ "" ] -> [ "Hello" ] -------> [ "" ] -> [ "Hello" ] -> [ "Hello World" ] ------->

PureScript

PureScript: a clean modern Haskell?

• Compiles to JS, no runtime, can interoperate with JS

• Statically typed, powerful type system

• Functional & pure

Why should you care

Better tools for thought

ToolingSome languages are easier to build tooling for than

others

Same language on client and server is a good idea (but JS is a shit choice)

Clojure(Script) + Onyx/Pyroclast

Shore up deficiencies in your main language

Questions