March 2012
2 posts
1 tag
Understanding Datomic?
In the Datomic unsession last night at ClojureWest Stu and Rich hosted a Q&A on Datomic. I appreciated their time and I now feel I have a better grasp of what they are doing with Datomic. In particular I felt enlightened by Stu’s question: “which provides faster data access, a fast local spinning drive or an SSD attached via a fat network pipe?” I hadn’t focused on...
Mar 17th
1 tag
Using Datomic in Clojure: Baby Steps
I ported over the first few steps of the in-memory Datomic tutorial to Clojure: https://gist.github.com/2060731 To run this code do something like: download the datomic zip follow the datomic README to install the datomic jar to your local maven repo (in the mvn incantation change “datomic.jar” to match the local file name from the datomic zip) setup a lein project something...
Mar 17th
February 2012
1 post
1 tag
Clojure Robot DSL
The code from my “Building a DSL in Clojure For Controlling a Lego MindStorm / Arduino Robot” talk at Lambda Lounge on February 2, 2012 is up on github. The talk had a few points: playing with Lego MindStorm and Arduino based robots is great fun they are very effective tools for teaching kids to program and to start to understand engineering a DSL built in Clojure can give kids the the...
Feb 4th
3 notes
January 2012
1 post
1 tag
Clojure: Creating a Custom Map Type
As presented at today’s St. Louis Clojure Cljub meeting.
Jan 26th
May 2011
1 post
1 tag
Clojure defrecord2 code update
I updated the defrecord2 code. It now includes the following: record zipper support record matchure support dissoc2 preserves record type universal record constructor defined record? predicate
May 8th
April 2011
1 post
1 tag
defrecord improvements - feedback
In the course of doing Clojure development I have made extensive use of records and have extended them in many was. So I was excited to see a proposal from the Clojure Core team for defrecord improvements. It looks like a good start, below are my thoughts and questions about the proposal. 1) Variety of forms One question that arises is how to understand the difference between the various forms....
Apr 7th
February 2011
1 post
1 tag
Clojure Protocol Adapters
Once you start using Clojure protocols to capture abstractions it is natural to want to define implementations of higher level protocols in terms of the lower level protocols. But, Clojure does not allow protocols to be extended to other protocols. At the Clojure Conj in 2010 Rich Hickey mentioned an approach to this problem in which a protocol is extended to Object as a “catch all”....
Feb 25th
November 2010
1 post
Implementation "inheritance" in Clojure
Clojure records and protocols eschew inheritance. For details see the “Datatypes and protocols are opinionated” section on the Clojure datatypes page. If you are used to Java style type inheritance you might be surprised that there is no explicit record/protocol mechanism for defining one type as a “sub-type” of another and inheriting the super-type’s...
Nov 4th
1 note
October 2010
4 posts
1 tag
Clojure dynamic variables and Java ThreadLocals
At Clojure Cljub we talked about dynamic variables being like Java ThreadLocals. Which led to the question of whether they were really ThreadLocals. After a cursory look at the Clojure 1.2 source, the answer appears to be: “yes”. Each binding is not itself a ThreadLocal, but the dynamic values of a Var appear to be rooted in a ThreadLocal named “dvals”. From...
Oct 30th
Create default xmodmap
From http://blacketernal.wordpress.com/set-up-key-mappings-with-xmodmap/ Run xmodmap -pke > default-modmap xmodmap -pm >> default-modmap Then edit the end of the default-modmap file to be formatted like this: add shift = Shift_L Shift_R add lock = Caps_Lock Then the resulting file can be loaded via: xmodmap default-modmap This is useful for restoring the default...
Oct 28th
1 tag
clojure-conj day 2 - notes
Aaron Bedra - Clojure in the field A couple of the main issues to address: Web frameworks - too many to pick from, need to coordinate these and need better docs Dependency management - Lein is a good start, but we need more. Also Clojars is too hard to search. Stuart Sierra - Macro Club slides clojure.test uses macros. This is confusing at times. For example, “thrown?” is not...
Oct 25th
1 note
1 tag
clojure-conj day 1 notes
My rough notes of the messages I heard during day 1 (October 22, 2010) of clojure-conj. Fogus - Roots of Clojure slides A list (some of it vaguely chronological) of the language environment in which Clojure was created: 1994 - Rich praised C++ strong typing Perl arose as a language that tied the web together Paul Graham sang the praises of Lisp Java was born. Took developers half way to...
Oct 25th
August 2010
2 posts
Enhanced Clojure records (part 2)
Following up on my efforts to enhance clojure records I put the second version of the code on github. Now record fields are printed in the same order they were defined. I also made it print nil values that are added to the record as long as they are not one of the “native” fields in the record.
Aug 15th
Ubuntu systray icons missing
I spent some time today tracking down an issue in which several systray icons disappeared from my Ubuntu system. The solution was to add the Notification Area item back to the panel. http://ubuntuforums.org/showthread.php?t=1072833
Aug 9th
July 2010
1 post
1 tag
Enhanced Clojure records
Clojure records are a mechanism for creating data abstractions. Records are instantiated with a list of the field values: Explicit nils are required to create a record without some field: Records are immutable, but new ones can be created by mutating an existing record Multiple fields can be set by merging a map into a record Notice that records print in a format that cannot be...
Jul 3rd
1 note
June 2010
1 post
1 tag
Wrapping Clojure in a Java API
How to wrap some Clojure code in a Java API? Googling on this leads first to a solution that involves invoking methods on clojure.lang.RT from Java. This might make sense for launching a Clojure program from Java, but it is strikes me as a crude tool for trying to build an API. Protocols and Datatypes Clojure protocols and datatypes create Java interfaces and classes behind the scenes so they...
Jun 12th
April 2010
1 post
“… “ns” and “in-ns” have special evaluation rules. ...”
– http://stuartsierra.com/ on http://groups.google.com/group/clojure
Apr 30th
March 2010
5 posts
1 tag
Clojure - repeated function application
In Clojure I was looking for a compact syntax to repeatedly apply the result of a function to a series of arguments. This led me to explore various mechanisms: ”->” threads a value through as the 2nd value in a series of expressions. (-> 20 (+ , 1) (* , 2) (/ , 21) (println ,)) ;; prints “2” (which is ((20+1)*2)/21) Clojure treats the “,” as whitespace, so...
Mar 21st
1 tag
Clojure - destructuring nested maps
I was writing a Clojure function that was passed a nested map like this: (def input {“results”   {“data”     [{“x” { “value” 100}       ”y” { “value” 105}}      {“x” { “value” 203}       ”y” { “value” 219}}      {“x” { “value” 345}       ”y”...
Mar 20th
1 tag
Out of the Tarpit : comments
This technomancy blog entry links to a video of Rich Hickey talking at a user conference. It includes the thought provoking quote (taken out of context) along the lines of “clojure is not bug-free, but it is not bad… considering it has no tests”. Rich makes the assertion that his time is better spent thinking about implementing his code correctly rather than writing tests around...
Mar 15th
1 tag
Clojure: recurse when needed
I have internalized the Clojure lesson of using the Clojure sequence library rather than recursing manually. However, I needed to process a result-set object and found that both of the following sequence based solutions failed. The result-set is a Java object with a .hasNext and .nextResult method to pull the results out. Failed take-while approach: (take-while (fn [_] (.hasNext result-set))...
Mar 12th
Hosting maven repo in git
I needed a maven repository for a project that was hosted in git. Since a maven repository is just a directory tree, I setup the maven repository as a directory in the git repository. A local maven repository can be referenced with a file:// URL. For leiningen use an entry like this in the project file: :repositories { “local-repo” “file://m2”} Replace “m2”...
Mar 9th
February 2010
1 post
1 tag
VimClojure Installation
VimClojure is a Vim plugin that provides features for editing Clojure files: * syntax highlighting * auto-completion of function names * integrated REPL * doc lookup * macro expansion The feature set is fairly basically but if you are proficient in vi it is possible to very quickly get into a nice flow bouncing back and forth between source files and the REPL. Setting up VimClojure is a bit...
Feb 26th