Diving into ClojureScript

12
Joaquin Oltra
Buy a ticket

Duration: 4 hours

The objective of the workshop is to get a big dive into ClojureScript, for JavaScript programmers.

ClojureScript is a compile to JS language that provides multiple advantages to JavaScript, and is very different to other compile-to-JS languages. It brings the future of JavaScript as a language to you now, and that is what you will get from the workshop.

The idea is to get out of the workshop excited about a better way of coding JS and with enough confidence, knowledge and materials to code and continue with ClojureScript programming.

During the workshop, we will have a hands on introduction to the language, a general overview of the ecosystem and tooling, we will learn the advantages and differences with JavaScript, we will set up a project and code a small web game, learn more intermediate concepts of the language, code another web project to do a small web application, learn about advanced concepts of the language and show some advanced libraries.

All of it will be as hands-on as possible, while clarifying any doubts.

For a general view of the great things we will go through and why ClojureScript is awesome, see the following section aimed at prospective learners.

For attendants:

Why learn ClojureScript

If you like alt-js (languages that transpile to javascript) and think that they are the future of javascript; love javascript and the web but want a better language to code in; and want to use the future now in real applications; Clojurescript is the perfect fit, it is a modern language with great advantages and one of the most advanced compile-to-js languages.

Some of the advantages of the language that will be shown and learnt are:

Sane semantics

ClojureScript has sane, safe and sound semantics, avoiding the extra overhead that dealing with all JavaScript quirks imposes. No more hoisting issues, global variables, weird equality rules, semicolon discussions, etc.

Easy and clear JavaScript interop

Like other famous compile-to-js languages, you can interact with JavaScript without any problems, with special semantics that allow seamless interop.

You can use external JS libraries with ClojureScript.

Interactive development (REPL driven development)

Don’t reload your page millions of times a day. ClojureScript is thought up to be dynamic and to encourage an interactive development style. You can eval your code and test it as you go coding, making the feedback loop instant, providing the satisfaction and security that you are coding exactly what you want.

Think of having your browser, and the developer tools REPL in the same place, with a solid dynamic code injection mechanism.

Immutable by default

ClojureScript favors immutability by default, making it easier to program with values, and to reason about your code. All that at a really good performance.

Modern data structures

ClojureScript includes a set of rich modern data structures that are immutable by default and have good performance. Vectors, lazy lists, hash maps, sets, a whole group of performant immutable data structures to have you covered when expressing your programs.

The pack is completed with the excellent standard lib that comes with the language.

Excellent standard library

ClojureScript includes cljs.core, cljs.string, cljs.set and more, a library of hundreds of functions to operate on the standard data structures in all ways imaginable. Expressiveness and power included by default. This is something you will surely miss when you have to code in JavaScript.

Besides the core, it gives you access to google closure library, a huge pack of JavaScript libraries written by Google that cover lots of cases with cross browser compatibility in mind.

Functional programming

ClojureScript is very well suited for functional programming with its data structures and the libraries of functions for manipulating and composing data and functions, and being expression oriented.

Favor pure functions when possible with immutable inputs and outputs, and write solid and expressive code.

Modern language (and backwards compatible)

Everything that is and will be coming to JavaScript, is already in ClojureScript available at our fingertips, while remaining compatible among all browsers (including the old ones). That, and more, learnt from the experience of past languages and adopted good ideas.

Namespaces, destructuring, short function, code generation macros, lazyness, functional programming, immutability, multi-platform, variadic functions, polimorphism via protocols…

Concurrency semantics

With a library called core.async, ClojureScript provides CSP semantics (like in go lang) for great use with concurrent code. A great alternative to callbacks, promises, reactive programming and streams.

Advanced compiler

The ClojureScript compiler emits a subset of JavaScript that is optimizable by the google closure compiler, providing an advanced (production) mode that will minify all our code, and remove dead (unreachable) code while performing several types of optimizations (inlining code, etc), resulting in a exceptionally minified code and in some cases faster execution time.

I hope to convey and excite you about all this advantages, introduce and teach you the language, and make you enjoy the coding and learning with it.

Objectives

  • Why ClojureScript, rationale and advantages over JavaScript.
  • Learn the ClojureScript language and it’s comparison with JavaScript.
  • Tools and ecosystem for developing with ClojureScript applications.
  • How to do interactive development of web applications.
  • To create a small web game with ClojureScript.
  • To create a small web application with ClojureScript.
  • Learning resources and guidance to continue learning ClojureScript.
  • Advanced libraries that are ClojureScript-only and do things unimaginable in JavaScript.
  • A taste of CSP semantics in ClojureScript and why they are awesome.

Prerequisites

  • Interest about learning ClojureScript
  • A laptop.
  • Java > 1.6 http://www.java.com/en/download/help/download_options.xml
    • In a terminal do java -version and expect to see something similar:
      java version “1.6.0_65” Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
  • Leiningen > 2.0 http://leiningen.org/#install
    • If somebody can’t get this to work, I can help you in the workshop
  • Lighttable http://www.lighttable.com/
  • A working Git installation https://help.github.com/articles/set-up-git
    or a Git capable application like the Github app.
    • http://mac.github.com/ or http://windows.github.com/
    • Maybe a Github account
  • Chrome (latest stable)
  • Wifi enabled