Clojure
There are 17 entries for the tag Clojure

I was honoured enough to do another lightning talk at SkillsMatter.  I’m afraid I had easily the least interesting talk of the evening, as you can see from the hastily prepared slides on Google Docs. Neale Swinnerton gave a great talk on Paredit.  I’m still trying to nail paredit, and this was a great help.  The slides are a thing of beauty, watch them in full screen mode.  Nick Rothwell gave a lightning talk that I wish had been longer, on teaching Clojure to artists.  He’s done some amazing and thankless work on embedding Clojure in MaxMSP. ...

Anyone learning Clojure like I am is recommended to read the source code to Jay Field’s Expectations library.  I was particularly interested to read his article on scenarios.  There’s some very interesting ideas there, but at the moment I wanted something a bit more basic.  “with-redefs” already provides the ability to replace one function with another, specifically for mocking purposes.  So really all I wanted was the ability to capture function invocations. So, here’s a working mechanism.  You use with-captures exactly the way you would use with-redefs, only you can call the “captures” function on the redefined function and...

I was interested to read Paul Ingles article on uSwitch’s handling of SSL.  Particularly interested because I remember writing the code he is replacing (It was about seven years ago, I believe...).  I thought makes a good case study in how your language choice affects your code.  To recap his article, uSwitch’s architecture offloaded SSL to hardware.  This meant that detecting whether you were running under SSL was impossible without a custom header.  Furthermore, the SSL/Non-SSL functionality was a bit more complex than a simple “redirect insecure pages”. However, after you’ve added the custom header to your...

TL;DR For all that people think of Clojure as a “hard” “propeller-head” language, it’s actually designed right from the start not for intellectual purity, but developer productivity. I thought I’d share my recent experiences of developing a commercial Clojure application.  It’s currently racking in about 800 lines of Clojure and 2000 lines of CoffeeScript.  I avoided ClojureScript for the simple reason that I had no experience in it, so I’m afraid I have no great insights there.  I guess it’s worth pointing out that although this is the first time I’ve really used Clojure in anger, I’ve been studying...

I did a lightning talk for the LCUG earlier this month.  The idea was to give an idea of the things you can do with closures and was principally aimed at Java programmers who are interested in Clojure.  These are the slides, these are the speaker’s notes and here’s the video taken by skillsmatter.  It come in at under six minutes.  I was the first “support act” for Sam Aaron, whose talk isn’t up since it was a dry run for his Clojure Conj talk.  However, you can also see Philip Potter talking about labrepl and Nick Rothwell talking about...

Creating long chains of transformation using the thrush operator looks attractive, but what if you need to see what it's doing? Consider the following code: (-> 1   inc   inc) Now it's obvious that this returns 3, and that the intermediate value was 2, but the following code proves it: (defn thread-println [v prefix]   (doto v (->> (str prefix) println))) (-> 1   inc   (thread-println "Intermediate value was")   inc) You'd need to write a second function for ->>, sadly. Technorati Tags: Clojure,Thrush Operator

I was recently at a dojo where a few people asked what on earth those -> and ->> symbols did, so I thought I'd have another go at trying to explain them.  You can find my C# heavy first go here. To start with, (-> a b c d) in clojure expands to (d (c (b a))).  You could describe this as reversing the arguments but I don't find that very helpful.  I find it easier to think about it imperatively: start with a do b to it ...

I was discussing today at work the problem of dealing with a variable length list of parameters in a typeless language.  If you explicitly declare the variable part of your parameters to be a list of strings, if someone only passes in one parameter, the compiler can check if it's a list of string or a single string and compile accordingly.  Without the type information (which ironically, includes C) you're out of luck.  It's got to assume you are dealing with a list. So, if you've got a list and you want the smallest item in Clojure (min...

I've been doing a bit of ZeroMQ work in Clojure at work, and I thought I'd share my thoughts on it.  It's worth understanding that what I was building was a globally distributed system, written for the JVM, involving long-running queries and peer-to-peer communication.  If your use case is different from this, you might have a radically different experience. The Good ZeroMQ basically gives you an interface at the C API level that looks very like a POSIX socket.  It then implements a packet protocol on top, so you never need to worry about receiving partial messages.  It's...

If there's one thing I've been thinking about all year, it's tool-based thinking.  I've spent my time getting out of Visual Studio, getting out of .NET and smelling the flowers.  Turns out Vim is a great editor, Coffeescript is a great language and Clojure... still has a lot to teach me.  One of the odd things with Clojure is that there's not many people writing about it.  I have a theory that this is basically because there's not much to say.  It's elegant and it works. It is however, insanely expressive, which can lead to some rather entertaining debate...

I've been coming to the opinion for some time now that static methods aren't the problem.  Global variables are the problem.  You may think that your code doesn't have many globals in it, but effectively, it's littered with immutable global variables: Static Methods are immutable globals Classes are immutable globals Namespaces are immutable globals If this all sounds a bit like I'm saying "Look at all these trees!  There must be a wood nearby!" you're right.  The point I'm making is that techniques such as dependency inversion are...

I can't tell if you're meant to do this kind of thing to vows.  I honestly can't.  It's either a demonstration of the power of the architecture, or it's a phenomenal hack that shouldn't be allowed out in broad daylight.  Either way, I'm probably thinking too LISP-ily for my own good. Let's say that you're trying to test the behaviour of a workflow.  Under certain conditions, certain things should happen.  The problem is, some of those certain conditions are pretty verbose.  In fact, if you've got three yes/no decisions to make, you're left having to set up eight different...

I'm still wrestling with getting something acceptable running Clojure under Windows, however you may find the following useful in your own travels: (->> (java.lang.System/getProperty "java.class.path") (re-seq #"[^;]+") (map println) dorun) Technorati Tags: Clojure

I recently had a go at Uncle Bob's latest challenge.  Part of the problem was, given s and n, find the smallest factor that divided n that was greater than or equal to s.  In C#, you could express this as follows: Enumerable.Range(s, n) .TakeWhile(x => x <= Math.Sqrt(n)) .Where(x => n % x == 0) .FirstOrDefault(); I think of this as results from the Range method being "piped" through the other methods.  I use similar programming techniques in Powershell, where I actually use a pipe symbol.  Now, it's worth bearing...

It's always the way that when you start learning a new technology you spend your entire time running into problems out of your comfort zone.  Getting Circumspec up and running was a particular challenge.  There's two big problems: Circumspec uses Clojure 1.2.0, which isn't finished. Worse, to lein repl, you need to compile Leiningen from trunk as well. It doesn't actually work on Windows. These are solvable problems.  But it's a bit of a nightmare.  First step, you're going to need my modified lein.ps1 script. ...

Over past few years, I've spent a lot of time thinking about dependency management, usually in the context of NHibernate and Castle Windsor.  The truth is that the problems these projects have are the problems any sufficiently complex open source project has.  So, having been playing with Clojure for several days I've got some thoughts about how the other half lives: For the most part, the JVM has been phenomenally stable for the last few years, so there's no analogue of the multiplicity of versions of .NET and Silverlight just isn't a problem for them.  Another way of saying...

It's a lot easier to do decent installation documentation on a clean computer.  Today I tried building Clojure and Compojure from scratch.  First you need to be able to run powershell scripts.  If you can't, do the following Close all powershell windows Start a powershell window as administrator set-executionpolicy Unrestricted (I'm assuming that if you have more sophisticated security requirements, you'll know enough to implement them yourself.) Building Clojure I'm going to assume that everything gets built into a directory I'm calling D:\OSS....