Clojure/ClojureScript: One Language to Rule the Web
by Stuart Sierra
JavaOne 2012
San Francisco, CA
September 28, 2012
Table of Contents
Clojure/ClojureScript
What is Clojure?
Namespace declaration and function definition:
(ns javaone.examples) (defn average [& nums] (/ (reduce + nums) (count nums)))
Function invocation:
(average 4 11) ;;=> 15/2 (average 3.0 72 9.6 33) ;;=> 29.4
Compare with Java notitle
(ns javaone.examples) (defn average [& nums] (/ (reduce + nums) (count nums)))
Compare to Java:
package javaone.examples; public class Averages { public static double average(double[] nums) { double total = 0.0; for (double num : nums) { total += num; } return total / nums.length; } }
What is ClojureScript?