Tag: code

The joyful Clojure example code convention

I started reading The Joy of Clojure, seems like a great book and I like its example code convention. I’m documenting it here because I’ll adopt it on my blog and I want to be able to link to it. I’ll call it the joyful Clojure example code convention.

A simple piece of Clojure code looks like this:

(* 2 10)

If you run it on the REPL it looks like this:

user> (* 2 10)
20

The first example, it’s just the code, with no return value, the second one, shows the return value, but when you have several lines it becomes cumbersome to copy and paste:

user> (* 2 10)
20
user> (* 2 11)
22
user> (* 2 12)
24

The Joy of Clojure code convention solves both problems by removing the prompt and leaving return values in comments:

(* 2 10)
;=> 20
(* 2 11)
;=> 22
(* 2 12)
;=> 24

Now you can copy and paste and still have the results.

If the snippet prints something, it will also be displayed but without the arrow, like this:

(println "Hello world")
; Hello world
;=> nil

Music for coding

Back to the FutureI’ve been looking for ages for the perfect music for coding. I’ve asked around and tried new age, Mozart, Bach, and other academic music. I’ve tried instrumental soothing music and instrumental electronic music. Nothing worked until I started to expand my original coding music: Indiana Jones and the Last Crusade.

Yes, I used to code to the music of Indiana Jones and the Last Crusade and I loved it. I started to try others and I’ve found I like coding to these albums:

I’m looking for more. There’s a clear pattern: instrumental and fast. It has to be of movies I’ve seen. When I listened repeatedly to Indiana Jones and the Last Crusade when I was a teenager I would recreate the whole movie in my head. I don’t do that anymore but the music still carries some subconscious meaning. I’ve tried with music of movies that I haven’t seen and it doesn’t work. And some don’t work and I don’t know why. These songs work as isolated songs, but not the whole album:

All by Vangelis of course. Star Wars music kind of works, but only some songs. I still have to sit down and select them (6 albums, lot of work). I remember other music like Apollo 13 also worked, but I don’t have it anymore.

What do I mean by work? It seems that music speeds me up. It makes me work faster, concentrate more and enjoy myself more. It makes me not want to stop, like watching a good movie. What do you listen to? Any other movies with great coding music?

Reviewed by Daniel Magliola. Thank you!