ClojureScript

Javascript

A typical day with Javascript

A tense day with Javascript

A brutal day with Javascript

@lxsameer

  • Senior Engineer with 12 years experience in the field
  • A free software guy
  • Contributed to projects like: Rails, Debian, Emacs, GNU, ReactNative, Clojure, ClojureScript, Pedestal, etc

I'm here to share an interesting experience I had

JS has a lot of Stupid in it.

- Brendan Eich (creator of Javascript)

Why Javascript

  • About 20 years with Javascript
  • It's everywhere
  • It's going to be there for a long time
  • Well engineered engines

Why not Javascript ?

  • Poor design
  • Constant changes
  • Weird behaviors 

Transpilers

  • CoffeeScript
  • TypeScript
  • PureScript
  • ...

Enter ClojureScript

Clojure is a dynamic, general-purpose programming language supporting interactive development; a functional programming language featuring a rich set of immutable, persistent data structures. As a dialect of Lisp, it has a code-as-data philosophy and a powerful macro system.

What's Clojure?

Clojure & ClojureScript

  • Simple
  • Dynamically Typed
  • Data oriented 
  • Functional

Why Google Closure?

  • ‌Backed by Google
  • Many years in production
  • Robust libraries
  • Best compiler in JS world

Syntax

Clojurescript syntax is stable. It doesn't change every year

List of Javascript operators 

List of ClojureScript operators 

(....)

It might looks scary, but it's really easy

Count the parenthesis in your code!

Size

CLJS

goog.dom: 23k

 

JS

JQuery: 29k

 

Advance Compilaiton

JS dependencies

Only required functions

Tooling

JS Tooling

Clojurescript Tooling

Leiningen

Workflow

  • REPL
  • Tools like Cider
  • Figwheel
  • Devcard

Demo

CallBack Hell

Core Async

Fragile foundations

  • No stdlib for JS
  • Constant changes
  • Backward incompatible
  • Google Closure is there

Debugging

Interop

Performance

No, it's not slow at all

Immutable data structures

Types & Spec

Put types where it makes sence

Clojure.spec

Demo

Editors

  • Emacs

  • Atom

  • Cursive

  • LightTable

  • NightLight

  • Vim

  • ....

CLJS & Rails

1) Do it manually

2) Separate Client and Server

3) Gems

Community

It's not as big as JS, but...

re-frame stars: 2,709

CLJS stars: 7,280

References

Stay in touch

  • lxsameer@gnu.org
  • @lxsameer everywhere
  • #clojure-ireland
  • #clojure

Q&A

Thanks

ClojureScript

By Sameer Rahmani