By arungupta on Jun 21, 2010
Uber Conf Day 4 (Day 3, 2, and 1) started with yet another 10 miler with fellow attendees in 1 hr 18 mins and 7:49 pace. It was slightly slower than the day before - guess physical exhaustion was setting in ;-) Here are the mile splits:
Thanks to Andy for showing how to turn on the Auto-Lap feature in Garmin 305 ... really handy!
I gave a talk on how GlassFish provides a great execution environment for deploying OSGi, Java EE, and hybrid applications easily. The slides are given below:
The remainder of the day was spent in Clojure track by Stuart Halloway. Next are some basic notes for getting started with Clojure:
Why Clojure ?
- Power (hosted on jvm)
- Robustness (functional)
- Concurrency (identity, state, time)
- Abstraction (OO done right)
- Focus (lisp)
Together, these features add up to simplicity. Simplicity means
- absence of incidental complexity
- sufficient to meet your design constraints
Simplicity does not mean
- Familiarity has nothing to do with simplicity
- its not superficial, goes to the bone (e.g. only simpler syntax is just a sugar wrapper, look for the supported idioms)
- does not mean easy, its very hard to be simple
Lot of code in Clojure is not about "set" something, its about invoke a function on it.
How to get started ?
~/tools/clojure/clojure-1.1.0 >java -cp clojure.jar clojure.main Clojure 1.1.0 user=> (print "Hello World") Hello Worldnil user=> \^D
~/tools/clojure/jun7 >java -cp clojure.jar clojure.main Clojure 1.2.0-master-SNAPSHOT user=> (print "Hello World") Hello Worldnil user=> \^D
Notice, the first fragment shows how to run REPL using the latest stable release and the second fragment shows the same using the cutting edge build. "Ctrl+D" exits the REPL shell. Stuart mentioned that the Clojure community stays on the cutting edge build most of the times.
Alternatively, you can also clone "labrepl" from "http://github.com/relevance/labrepl" which is an environment for exploring the Clojure language. It also provides complete instructions for getting started with NetBeans/Enclojure, Eclipse/Counterclockwise, Maven, Max/Linux command line, Windows command line, IDEA/La Clojure, and Emacs.
Configuring Clojure in NetBeans using the Enclojure plugin with NetBeans 6.9 gives the following error:
but works easily with NetBeans 6.8. The IDE seem to support REPL, Java/Clojure integration, syntax highlighting, brace/paren/bracket matching, code navigation, debugger and lots of interesting features.
Here is a typical REPL getting started session with NetBeans and Enclojure:
Here are some equivalent syntax with Java:
|new||new Widget("foo")||(Widget. "foo")|
|Access static members||Math.PI||Math/PI|
|Access instance members||rnd.nextInt()||(.nextInt rnd)|
|Chaining access||person.getAddress().getZipCode()||(.. person getAddress getZipCode)|
- "defn" is a symbol so no new syntax for adding a method.
- \^ introduces metadata for the next symbol, "greet" in this case. You can put metadata anywhere.
- "clojure.core" is the core of Clojure's implementation
- "javadoc" knows the default JDK javadocs, can make a local copy and/or extend it
- "show" is Java reflection
- "dir", "show", "source" are promoted from community version to the bleeding edge build.
- Source is not always exposed
- [1 2 3] Call the function 1 with arguments 2 & 3.
- '(1 2 3) don't evaluate it and print as is, just tick it.
- Idiomatically Clojure requires less parentheses than Java
Every single function in Clojure is Runnable and Callable
Java interop is simple, wrapper-free (raw), performant, complete
A subsequent blog will show how to deploy a simple Clojure JAR file and a simple web app using Compojure on GlassFish.
And finally, here are my top-10 reasons (in no particular order) that I'd like to attend UberConf next year:
- Long 90 minute sessions
- Lots of hands-on workshops
- Fun Run as part of the formal agenda
- Beautiful location (Westin Westminster) with lots of running trails
- Great food (breakfast + lunch + dinner)
- Small attendance so intimate discussions with speakers
- Great set of speakers
- Rarely see session hopping
- Pure technology, no product pitching
- Swags are nice - bracelet-style USB stick with all the presos, 2 different tee-shirts, fancy folder and some additional goodies for speakers
See ya next year, hopefully!
Check out the complete set of pictures at: