Skip to content

Latest commit

 

History

History
347 lines (238 loc) · 8.9 KB

getting-started-with-clojure.org

File metadata and controls

347 lines (238 loc) · 8.9 KB

Getting Started with Clojure

Leiningen for everything

Leiningen allows you to:

  • Create projects
  • Manage dependencies (uses mvn local cache)
  • Package projects into libraries
  • Generate Maven POM files (if you must)
  • Deploy your libraries on Clojars
  • Run the REPL

Leiningen Requirements

Must have the Java JDK (not just the JRE)

  • this is a requirement for any Clojure development

Leiningen Demo

Time for some live hacking…

Leiningen core commands

  • Create a new project

lein new project-name

  • Check dependencies and download any required

lein deps

  • Run a REPL

lein repl

  • Find out more

lein help

Demo code - project.clj

A basic Leiningen project definition

(defproject whats-my-salary "0.1.0-SNAPSHOT"
  :description "Calculate salary after tax for perminant employees"
  :url "http://blog.jr0cket.co.uk"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.4.0"]]
  :main whats-my-salary.core )

Demo code - more stuff..

Colourful code

(defn show-me-the-colours [colour]
   ( str "The colour of money is" colour))

Emacs for Clojure

Emacs is a powerful tool for your developer life, its a nice editor too…

  • development environments for lots of languages
  • manage tasks, take effective notes and create presentations

Emacs Live

Creates an amazing environment for Clojure development

  • keeping () under control with ParEdit
  • starting / connecting to a REPL
  • evaluating code in-line (C-x C-e) or all the code (C-c C-k)
  • syntax highlighting & auto-complete
  • gloriously colourful themes

Roll your own Emacs setup

Add the following Emacs packages

clojure-mode clojure-test-mode rainbow-delimiters ac-slime

Look at my basic setup on clojuremadesimple.co.uk

Learning Lisp with Emacs

Configuring Emacs is via a Lisp language called ELisp

  • practice your core Clojure skills by tweaking Emacs
  • lots of examples of Lisp code on Github

Light Table

A project to create a great experience for Clojure Development

  • instarepl
  • start / connect to multiple REPL’s
  • written in Clojurescript & a few lines of Clojure
  • run browser & graphics in a window
  • also supports Clojurescript, JavaScript & Python
  • still beta, not officially release as yet
  • join light-table-discussion Google group to keep up with changes

Installing Light Table

LightTable.com - binaries for Linux (32bit & 64bit), MacOSX & Windows

Documentation

Built in documentation

docs.lighttable.com

Chris Granger’s blog - major announcements & a few guides

Java IDE’s

Eclipse & Counterclockwise

code.google.com/p/counterclockwise

A great combo if you are used to Eclipse

  • uses Leiningen underneath
  • provides a REPL window
  • usual syntax highlighting and other IDE stuff

Netbeans & Enclojure

Sadly the Enclojure plugin for Netbeans is depreciated

The Enclojure code is available on Github, if you want to kickstart the project.

Intelij & LaClojure

Getting started with La Clojure

Clojars.org - clojure libraries galore

Clojars.org

  • search for libraries
  • gives you dependencie definitions

A few notable Clojar projects

  • Midje - TDD testing framework
  • clj-time - date/time library, wrapper around joda time
  • compojure - used to help build webapps with Ring
  • drawbridge - connect to your REPL and your webapp
  • brevis - artifical life generator
  • Incanter - statistical programming & data visualization

Learning Clojure

(false? (afraid brackets))
  • Join in the fun at London Clojurians
  • Learn Clojure on the Internet
  • Read some Clojure books

4Clojure

An increasingly difficult set of changenges to help you understand Clojure

./images/clojure-4clojure-home.png

4Clojure - simple example

./images/clojure-4clojure-example-list-elementry.png

4Clojure - more complexe example

./images/clojure-4clojure-example-forthewin.png

Books

Blogs, Documentation, etc.

Planet Clojure - blog aggregator

blog.jr0cket.co.uk - Clojure, Emacs & Git articles

clojure.org - official documentation

clojuredocs.org - community docs & examples

Clojure Cheatsheet - quick syntax & function reference

Thank you

Get Leiningen

Use Emacs, LightTable or your favourite IDE

Have fun in the REPL and love writing Clojure

ps. This presentation was brought to you via Emacs & Revealjs

Reveal.js is 2-D

Org-Reveal knows how to drill down into a subject.

Press the “Down” key on the page or the down arrow

Fragments in Reveal.js

  • Create
  • Fragment
  • At Ease
#+ATTR_REVEAL: :frag
   * Create
   * Fragment
   * At Ease

Reveal.js Can Alert

Change slide style to wake up the sleepy audience.

So do Org-Reveal.

** Reveal.js Can Alert
   :PROPERTIES:
   :reveal_data_state: alert
   :END:

Display Math

Write equations in Org. Present equations in HTML5.

$limx → ∞ exp(-x) = 0$

$\lim_{x \to \infty} \exp(-x) = 0$

The Org Source

Get Org source text for this presentation here.

Get Reveal.js and Org-reveal

./images/org-reveal.png