ClojureScript

Android

figwheel REPL

Emacs configuration

  • add inf-clojure to dotspacemacs-additional-packages in .spacemacs
  • add figwheel-repl function to layers/+lang/clojure/funcs.el
  • open ~/Dropbox/Programming/clojure/flappy-bird-demo/src/flappy_bird_demo/core.cljs in Emacs and hit M-x figwheel-repl, open browser at http://localhost:3449/
(defun clojure/figwheel-repl ()
  (interactive)
  (run-clojure "lein figwheel"))

alternative: Using the Figwheel REPL within NRepl

Tutorial

Tutorial 1 - The Basics

suggested file layout

modern-cljs/
├── build.boot
├── html
│   └── index.html
└── src
    └── cljs
        └── modern_cljs
            └── core.cljs

Issue the following command at the terminal:

mkdir -p modern-cljs/{src/cljs/modern_cljs,html}

Let’s now create the three needed files by issuing the folowing command:

cd modern-cljs
touch html/index.html src/cljs/modern_cljs/core.cljs build.boot

Clojure

CIDER nREPL

Boot

print boot manual page to terminal
$ boot -h

create new project

Installation

using nix
$ nix-env -i boot

Configuration for CIDER

create symbolic link to file
$ mkdir ~/.boot
$ ln -s ~/Dropbox/Programming/clojure/.boot/profile.boot ~/.boot/

create file profile.boot with following content

(require 'boot.repl)

(swap! boot.repl/*default-dependencies* conj
       '[refactor-nrepl "1.2.0-SNAPSHOT"]
       '[cider/cider-nrepl "0.10.0-SNAPSHOT"])

(swap! boot.repl/*default-middleware* conj
       'refactor-nrepl.middleware/wrap-refactor)

piggieback for ClojureScript

(require 'boot.repl)

(swap! boot.repl/*default-dependencies* conj
       '[com.cemerick/piggieback "0.2.1"]
       '[org.clojure/tools.nrepl "0.2.10"])

(swap! boot.repl/*default-middleware* conj
       'cemerick.piggieback/wrap-cljs-repl)

https://github.com/boot-clj/boot/wiki/Cider-REPL

to separate regular REPL from CIDER REPL

(deftask cider "CIDER profile"
  []
  (require 'boot.repl)
  (swap! @(resolve 'boot.repl/*default-dependencies*)
         concat '[[org.clojure/tools.nrepl "0.2.12"]
                  [cider/cider-nrepl "0.10.0"]
                  [refactor-nrepl "2.0.0-SNAPSHOT"]])
  (swap! @(resolve 'boot.repl/*default-middleware*)
         concat '[cider.nrepl/cider-middleware
                  refactor-nrepl.middleware/wrap-refactor])
  identity)

In Emacs do M-x customize-variable cider-boot-parameters and set it to cider repl -s wait.

Leiningen

for automating Clojure projects without setting your hair on fire

create new project or see “Creating a project” below
$ lein new [project name]
built-in tutorial
$ lein help tutorial
install using shell script
$ cd ~/bin
$ wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
$ chmod a+x ~/bin/lein make executable
$ bash ~/bin/lein download installer

alternative install using default.nix

clojure-doc.org: Creating a project
$ cd ~/Dropbox/Programming/clojure
$ lein new command-line-args
$ cd command-line-args

Light Table

Light Table Plugins

  • clojure
  • css
  • html
  • images
  • javascript
  • lighttable-html-live
  • lt-markdown
  • node
  • paredit
  • python
  • rainbow

Emacs CIDER

create file profiles.clj with following content:

{:repl {:plugins [[cider/cider-nrepl "0.10.0-SNAPSHOT"]
                  [refactor-nrepl "2.0.0-SNAPSHOT"]]
        :dependencies [[alembic "0.3.2"]
                       [org.clojure/tools.nrepl "0.2.12"]]}}
create symbolic link from file
$ rm ~/.lein/profiles.clj
$ ln -s ~/Dropbox/Programming/clojure/.lein/profiles.clj ~/.lein/

Books

  • Clojure Programming: written by three of the heroes of Clojure, it contains everything you need to know about Clojure and its ecosystem.
  • Programming Clojure: written by another legendary Clojure developer, it’s the easiest path to learning Clojure.
  • The Joy of Clojure: the title speaks by itself. A must read!
  • ClojureScript Up and Running: at the moment, it’s the only published book on ClojureScript. The book is a bit outdated since ClojureScript is evolving quickly. It’s brief and useful, especially if you want to integrate with external JavaScript libraries.
  • SICP - Structure and Interpretation of Computer Programs: this is the best programming book I’ve read in my very long career. It uses Scheme/Racket (a Lisp dialect) rather than Clojure and is available online, in print, or in a lecture series.
  • On Lisp: if you want to learn about macros, this is the place to start. It uses Common Lisp (a Lisp dialect) rather than Clojure.


Published

27 March 2016

Category

technical