Skip to content

protez/modern-cljs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

modern-cljs

A series of tutorials to guide you in creating and setting up ClojureScript (CLJS) projects.

If you ask yourself why the series has been named modern-cljs even if the ClojureScript language is only a couple of years old, you're right. It just happens that I started this series while trying to port on ClojureScript few examples from the Modern JavaScript: Develop and Design book. Its correct title should have been current-cljs. Now it's too late to change it.

Required background

This series requires some programming experience. I assume you already made your hands dirty with Clojure programming language, but you need not to be proficient with it or even with the underlying Java and JavaScript programming languages.

If you don't know anything about Clojure (or Lisp), I strongly recommend to study it before to start reading this series.

Even if the net is plenty of outstanding resources on Clojure programming language, you can't understimate the benefit of reading few books on Clojure and on other Lisp dialects:

  • SICP - Structure and Interpretation of Computer Programs: this is still the best book I have ever read about Computer Programming in my very long carrier, even if it uses the Scheme programming language (a Lisp dialect);
  • On Lisp: if you want to make your hands dirty with macros, this is the place to start from even if it uses CommonLisp (a well known Lisp dialect);
  • Clojure Programming: written by three of the most heroics clojureans, it contains everything you need to know about Clojure and its ecosystem;
  • Programming Clojure: written by another legendary clojurean, it represents the easiest path to approach Clojure;
  • The Joy of Clojure: the title speaks by itself. A must read
  • ClojureScript Up and Running: at the moment, it's the only available book on ClojureScript. Due to the youth of the ClojureScript language, the book is now a little bit outdated. It's so brief that you can read it in a very short time with some profit, specially if you want to integrate external JavaScript libraries in your code.
  • The Annotated Clojure Reference Manual by Rich Hickey: The most missed book on Clojure :).

Tooling

More people asked me which operating system and editor/IDE are most appropriated for developing Clojure/ClojureScript code. I personally use Mac OS X and Ubuntu. On top of those I use Emacs with the standard stuff to be productive with Clojure programming. Because I'm aged, *nix and Emacs are the OS/Editor I know better. That said, in this series you're not going to find any suggestion about any OS or IDE/Editor. Use whatever tool fits better your habits. I have too much respect for people developing IDE/plugins for Clojure/ClojureScript to say that one is better than another.

Introduction

This series of tutorials will guide you in creating, setting up and running simple CLJS projects. The series follows a progressive enhancement of the project itself.

NOTE 1: I suggest to code yourself the content of the series. In my experience it is always the best choice if you are not already fluent with the programming language you have under your fingers.

That said, assuming you already have installed leiningen 2, to run the latest available tutorial without coding:

  1. git clone https://github.com/magomimmo/modern-cljs.git
  2. cd modern-cljs
  3. lein cljx once # used from tutorial-16 forward
  4. lein ring server-headless
  5. open a new terminal and cd in the modern-cljs main directory
  6. lein cljsbuild once
  7. lein trampoline cljsbuild repl-listen
  8. visit login-dbg.html and/or shopping-dbg.html
  9. play with the repl connected to the browser

NOTE 2: If you want to access the code of any single tutorial because you don't want to copy&paste it or you don't want to write it yourself, do as follows:

  • git clone https://github.com/magomimmo/modern-cljs.git
  • cd modern-cljs
  • git checkout tutorial-01 # for tutorial 1, tutorial-02 for tutorial 2 etc

In the first tutorial you are going to create and configure a very basic CLJS project.

In this tutorial you are going to set up a browser connected CLJS REPL (bRepl) using an external http-server.

In this tutorial you are going to substitute the external http-server with ring, a CLJ based http-server.

In this tutorial we start having some fun with CLJS form validation, by porting from JS to CLJS the login form example of Modern Javascript: Development and design by Larry Ullman.

In this tutorial we're going to use domina library to make our login form validation more clojure-ish.

In this tutorial we're going to investigate and solve in two different ways the not so nice issue we met in the last tutorial.

In this tutorial we're going to explore CLJS/CLS compilation modes by using the usual lein-cljsbuild plugin of leiningen, but we'll discover a trouble we'll solve by using a new feature of the 0.3.0 of lein-cljsbuild plugin.

In this Tutorial we're going to introduce domina events which, by wrapping Google Closure Library event management, allows to follow a more clojure-ish approach in handing DOM events.

In this tutorial we're going to face the need to programmatically manipulate DOM elements as a result of the occurrence of some DOM events.

In this tutorial we're going to extend our comprehension of CLJS by introducing Ajax to let the CLJS client-side code to communicate with the CLJ server-side code.

In this tutorial we're going to enrich our understanding of Domina events by applying them to the login form example we introduced in the 4th Tutorial.

In this tutorial we're going to cover the highest and the deepest layers of the Login Form example we started to cover in the previous tutorial.

One of our long term objectives is to eliminate any code duplication from our web applications. That's like to say we want firmly stay as compliant as possible with the Don't Repeat Yourself (DRY) principle. In this tutorial we're going to respect the DRY principle by sharing validators between the client (i.e. CLJS) and the server (i.e. CLJ).

In this tutorial we are going to prepare the stage for affording the unit testing topic. We'll also introduce the Enlive template sytem to implement a server-side only version of the Shopping Calculator aimed at adhering to the progressive enanchement implementation strategy. We'll even see how to exercize code refactoring to satisfy the DRY principle and to solve a cyclic namespaces dependency problem.

In this tutorial, after having added the validators for the shoppingForm, we're going to introduce unit testing.

In this tutorial we make unit testing portable from CLJ to CLJS (and vice-versa) by using the clojurescript.test lib and the cljx lein plugin.

To be respectful with the progressive enhancement strategy, in this tutorial we're going to integrate the form validators for the server-side Shopping Calculator into the corresponding WUI (Web User Interface) in such a way that the user will be notified with the right error messages when the she/he types in invalid values in the form.

In this tutorial we're going to digress about two topics. The setup of a more comfortable browser REPL based on nREPL. The setup of a more comfortable project structure by using the profiles features of Leiningen

In this tutorial we are going to explain how to contribute to someone else's repositories and how to publish snapshot releases on clojars for using them in your project.

In this tutorial, while studying the Enfocus lib with the objective of sharing as much code as possibile with the corresponding Enlive lib, we'll start to be collaborative by proposing few improvements to the Enfocus directories layout and the adoption of the clojurescript.test lib for implementing its unit tests.

In this tutorial we're going to adjust Enfocus for packaging it in a jar. Then we'll instrument it with the piggieback lib, publish it on clojars and even used it as a dependency in a very simple project to demonstrate that all the changes we did are not affecting the Enfocus codebase which is still working as expected.

In this tutorial we're going to improve Enfocus even more, by applying again the separation of concerns principle and by starting to implement few unit tests which follow my personal strategy when unit testing: unit test edge cases first. In doing that, we'll discover few bugs in the enfocus codebase and we even correct them by first interacting with the REPL.

License

Copyright © Mimmo Cosenza, 2012-2013. Released under the Eclipse Public License, the same as Clojure.

About

A series of tutorials on ClojureScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published