- Svelte
- Developer enjoys convenience
- Compiler abstracts away reactivity, noted inside
$
-labels
- Rust
- Developer enjoys memory safety
- Compiler enforces of ownership
- Idris
- Developer enjoys application correctness
- Compiler checks types, based on an expressive type system
- Second-oldest programming language in use, from 1958, by John McCarthy
- Today: Scheme, Common Lisp, Clojure, Emacs-Lisp
Note function application in paranthesed polish/prefix notation.
(+ 1 2) ;; 3
(list 1 2 3) ;; (1 2 3)
(def my-one 1)
(defn add1 [x] (+ 1 x))
Quote an expressions (with quote
or '
) to stop its evaluation.
(quote +) ;; +
'+ ;; +
(list '+ 1 2) ;; (+ 1 2)
(list 'list 1 2) ;; (list 1 2)
'(list 1 2) ;; (list 1 2)
'(list (+ 1 2) 3) ;; (list (+ 1 2) 3)
;; an expressions that evaluates to its own quotation:
(
(fn [x] (list x (list (quote quote) x)))
(quote (fn [x] (list x (list (quote quote) x)))))
Syntax-quote an expression (with `
) to allow explicitely marked parts of it (prefixed with ~~~) to be evaluated.
'(list (+ 1 2) 3) ;; (list (+ 1 2) 3)
`(list ~(+ 1 2) 3) ;; (list 3 3)
Evaluate (with eval
) a quoted expression.
(eval '(+ 1 2 3)) ;; 6
(eval (list '+ 1 2 3)) ;; 6
Write simple but powerful macros (with defmacro
) that will be expanded at compile-time.
(defmacro apply-thrice [f x] (quote (f x x x)))
(apply-thrice * 5) ;; evaluates to: 125
(defmacro definiere [f] `(defn ~f [x] (+ 1 x)))
(definiere plus1)
(definiere plusEins)
(plus1 5)
function definiere(funktionsName) {
function ${funktionsName}(x) {
return x + 1;
}
}
definiere("plus1");
definiere("plusEins");
plus1(3);
Clojure | A Lisp for the Java Virtual Machine (JVM) |
ClojureScript | Clojure transpiled to JavaScript |
- An experimental web-framework for Clojure(Script), featuring
- reactivity, including reactive loops
- multi-tier: macros for marking client- or server-side, including ability to arbitrarily nest
- Developer writes single source code, wherein server- and client-side code can be arbitrarily nested
- Compiler compiles/transpiles source code into server- and client-side code, including the networking in-between
- Presentation “UIs are streaming DAGs” by Dustin Getz, the author of Electric
- Official Interactive Tutorial on the Web