Clojure in production

2,526 views
Skip to first unread message

Plínio Balduino

unread,
Jun 10, 2013, 5:47:25 PM6/10/13
to clo...@googlegroups.com
Hi there

I'm writing a talk about Clojure in the real world and I would like to
know, if possible, which companies are using Clojure for production or
to make internal tools.

Thank you

Plínio Balduino

Dima Sabanin

unread,
Jun 10, 2013, 5:51:01 PM6/10/13
to clo...@googlegroups.com
Hi Plínio, 

We use Clojure heavily in beanstalkapp.com.

Best,
Dima


--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.





--
Best regards,
Dima Sabanin
http://twitter.com/dimasabanin

Softaddicts

unread,
Jun 10, 2013, 5:57:38 PM6/10/13
to clo...@googlegroups.com
Look at this:

http://dev.clojure.org/display/community/Clojure+Success+Stories

Luc
> > -- > -- > You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- > You received this message because you are subscribed to the Google Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> > > --
Softaddicts<lprefo...@softaddicts.ca> sent by ibisMail from my ipad!

Plínio Balduino

unread,
Jun 10, 2013, 6:17:43 PM6/10/13
to clo...@googlegroups.com

Thanks. I went there before ask here =)

Plínio

Ignacio Thayer

unread,
Jun 10, 2013, 7:48:36 PM6/10/13
to clo...@googlegroups.com
ReadyForZero.com uses clojure exclusively (~50K lines) on the backend for http and api requests.

Ignacio Thayer
Co-founder/CTO ReadyForZero.com

Joseph Smith

unread,
Jun 11, 2013, 1:06:33 AM6/11/13
to clo...@googlegroups.com, clo...@googlegroups.com
I work for Nanonation Inc (Nanonation.net) and we have a couple internal tools as well as a new product, Viewpoint, where the backend and web portal are both 100% Clojure.  

---
Joseph Smith
@solussd

--

Robert Stuttaford

unread,
Jun 11, 2013, 4:15:56 AM6/11/13
to clo...@googlegroups.com
We use Clojure full-stack at www.cognician.com. Clojure, ClojureScript, Datomic. Still under 20k loc. Loving it!

Simon Holgate

unread,
Jun 11, 2013, 5:36:49 AM6/11/13
to clo...@googlegroups.com

Bruce Durling

unread,
Jun 11, 2013, 5:38:37 AM6/11/13
to Clojure
Hey!

On Tue, Jun 11, 2013 at 10:36 AM, Simon Holgate <simon....@gmail.com> wrote:
> Bruce Durling's semi-irregular update for London Clojurians is here:

I'll have you know that I'm completely irregular. :-D

Oh, and we use clojure for all of our stuff at Mastodon C that isn't
html or javascript and I think the javascript's days are numbered.

cheers,
Bruce

--
@otfrom | CTO & co-founder @MastodonC | mastodonc.com
See recent coverage of us in the Economist http://econ.st/WeTd2i and
the Financial Times http://on.ft.com/T154BA

keeds

unread,
Jun 11, 2013, 7:27:52 AM6/11/13
to clo...@googlegroups.com
In the depths of ?Sunny? Suffolk... We use clojure and now clojurescript to build our internal systems with a very small team of developers (2). Cannot imagine getting the power, productivity or fun out of any other environment.

We are looking for another developer so if anyone knows anyone prepared to work in Needham Market with some clojure knowledge or transferable skills then let me know.
Remember this is not London so don't expect fantastic remuneration, but the opportunity to learn, develop and experiment is huge.

Andrew Keedle
Lead clojure developer (and IT Manager)
BTS Group


On Monday, 10 June 2013 22:47:25 UTC+1, Plinio Balduino wrote:

Sean Corfield

unread,
Jun 11, 2013, 2:08:47 PM6/11/13
to clo...@googlegroups.com
The latest data from World Singles llc (which is listed on that
Success Stories page):

Clojure source 76 files 13178 total loc, 1064 fns, 554 of which are
private, 152 vars, 2 macros, 17 atoms
Clojure tests 37 files 3016 total loc
Clojure WebDriver tests 11 files 371 total loc

We're on Clojure 1.5.1 in production now. We started with 1.3.0 Alpha
7 (or 8?) and have upgraded pretty much immediately as each final
build has become available (we skipped 1.5.0 due to the memory leak
that was identified - and fixed in 1.5.1).

We generally do multi-version testing so we can easily migrate to each
version as it is released.

Sean
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Chris Wilson

unread,
Jun 11, 2013, 3:24:41 PM6/11/13
to clojure
Hi,

At Planspot.com we're migrating some old code to Clojure and writing most
new backend code in it.  So far that is some API components for recording
and serving statistical data and the backend of a contact aggregation,
enrichment and management system.

Cheers,

Chris

Softaddicts

unread,
Jun 11, 2013, 3:45:40 PM6/11/13
to clo...@googlegroups.com
Ok, my turn to let some testosterone out :)))))

Presently migrating to 1.5.1 from 1.3

Around 8500 slocs with another 3000 slocs of custom DSL definitions.
Less than 1000 lines of unit tests, increasing slowly.

132 namespaces
166 atoms/refs
226 vars
170 private fns
585 public fns
46 macros

Some yet unqualified slocs of ClojureScript.

Luc P.

Eric MacAdie

unread,
Jun 11, 2013, 9:19:50 PM6/11/13
to clo...@googlegroups.com
OT, but, personally, I look forward to a world free of Javascript.

On Tue, Jun 11, 2013 at 4:38 AM, Bruce Durling <b...@otfrom.com> wrote:
Hey!

Plínio Balduino

unread,
Jun 11, 2013, 11:14:21 PM6/11/13
to clo...@googlegroups.com

Come on. JavaScript is an awesome and misunderstood language =)

Thank you all for your help. I have lots of examples to show where we're using Clojure.

Plínio


--

Jason Wolfe

unread,
Jun 12, 2013, 1:39:40 AM6/12/13
to clo...@googlegroups.com
Hi Plínio,

At Prismatic (getprismatic.com), our entire backend (web crawling, machine learning, topic modeling, real-time ranking, API, web-servers, ...) is written in Clojure, and our frontend is moving towards 100% ClojureScript -- you can check out our blog at http://blog.getprismatic.com/ for details, or here's a talk from awhile ago on the subject:


Happy to answer any questions about our use of Clojure if you're interested. 

Cheers,
Jason


On Monday, June 10, 2013 2:47:25 PM UTC-7, Plinio Balduino wrote:

Mikera

unread,
Jun 12, 2013, 3:45:23 AM6/12/13
to clo...@googlegroups.com
Hi Plínio,

At Nuroko, we're using Clojure to develop our machine learning toolkit (using neural networks). The code is a mix of Clojure and Java.

Some of our tools have public source code here: https://github.com/nuroko

  Mike.



On Monday, 10 June 2013 22:47:25 UTC+1, Plinio Balduino wrote:

Marshall Bockrath-Vandegrift

unread,
Jun 12, 2013, 8:46:41 AM6/12/13
to clo...@googlegroups.com
Plínio Balduino <pbal...@gmail.com> writes:

> I'm writing a talk about Clojure in the real world and I would like to
> know, if possible, which companies are using Clojure for production or
> to make internal tools.

At Damballa we’re using Clojure and Cascalog to do all of our
Hadoop-based backend data processing. As we’ve moved more of our
infrastructure to Hadoop- and JVM-based technologies (such as HBase),
our use of Clojure has expanded to encompass most new server-side
development.

We have a small amount of Clojure code released as open source, with
more to come in the future:

https://github.com/damballa

And obligatory company Web site:

https://www.damballa.com/

-Marshall

Lynn Grogan

unread,
Jun 12, 2013, 4:12:05 PM6/12/13
to clo...@googlegroups.com
Plínio,
The newest episode of the Relevance podcast is all about Clojure (and Datomic) in production at Roomkey.com
You can find the episode & show notes here: http://is.gd/RAvhqG 

Cheers! Lynn

Jose A. Ortega Ruiz

unread,
Jun 12, 2013, 4:30:52 PM6/12/13
to clo...@googlegroups.com

Hi Plinio,

On Mon, Jun 10 2013, Plínio Balduino wrote:

> Hi there
>
> I'm writing a talk about Clojure in the real world and I would like to
> know, if possible, which companies are using Clojure for production or
> to make internal tools.

At BigML, our backend is written almost fully (99%) in Clojure. We've
released a couple of libraries it uses as open source:

https://github.com/bigmlcom/histogram
https://github.com/bigmlcom/sampling
https://github.com/bigmlcom/io

Cheers,
jao
--
Where is the Life we have lost in living? Where is the wisdom we have
lost in knowledge? Where is the knowledge we have lost in information?
-T.S. Eliot, poet (1888-1965)

Rogier Peters

unread,
Jun 13, 2013, 3:41:06 AM6/13/13
to clo...@googlegroups.com
Really inspiring thread and a welcome stick to beat the "functional == academic" nay-sayers with!


--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


rod naph

unread,
Jun 13, 2013, 4:40:34 AM6/13/13
to clo...@googlegroups.com
I work at boxuk.com, we have some internal apps, and a few small production services in Clojure.

j...@duktion.de

unread,
Jun 13, 2013, 4:45:46 AM6/13/13
to clo...@googlegroups.com

Hi Plínio,

at gateprotect, we use clojure in our firewall product for model
representation and doing all the hard/logic work.

Some stats:
~ 370 namespaces
~ 25000 sloc

A great part of that is written in our model DSL.

Cheers,
Jan

http://www.gateprotect.com

We are hiring! http://www.gateprotect.com/en-GB/company/jobs.html


Stas Krichevsky

unread,
Jun 13, 2013, 5:29:26 AM6/13/13
to clo...@googlegroups.com
Hi Plínio,

We use Clojure for many of our backend services at kontera.com

/stask

Jay Fields

unread,
Jun 13, 2013, 10:03:06 AM6/13/13
to clo...@googlegroups.com
On Monday, June 10, 2013 5:47:25 PM UTC-4, Plinio Balduino wrote:
Hi there

I'm writing a talk about Clojure in the real world and I would like to
know, if possible, which companies are using Clojure for production or
to make internal tools.

I've previously written about adopting Clojure at DRW (drw.com): http://blog.jayfields.com/2012/01/lessons-learned-while-introducing-new.html 

dgrnbrg

unread,
Jun 13, 2013, 2:45:42 PM6/13/13
to clo...@googlegroups.com
We are using Clojure at Two Sigma to monitor, schedule, and optimize our cluster.



On Monday, June 10, 2013 5:47:25 PM UTC-4, Plinio Balduino wrote:

Leon Barrett

unread,
Jun 13, 2013, 4:07:01 PM6/13/13
to clo...@googlegroups.com
At The Climate Corporation (formerly Weatherbill), we do much, though not all, of our development in Clojure.

Karsten Schmidt

unread,
Jun 13, 2013, 5:00:31 PM6/13/13
to clo...@googlegroups.com
Just for completeness' sake, my two pence:
https://groups.google.com/d/msg/clojure/Z995K48BZGA/IDSAEm-PKFkJ

Deepak Giridharagopal

unread,
Jun 13, 2013, 5:07:07 PM6/13/13
to clo...@googlegroups.com
On Monday, June 10, 2013 3:47:25 PM UTC-6, Plinio Balduino wrote:
Hi there

I'm writing a talk about Clojure in the real world and I would like to
know, if possible, which companies are using Clojure for production or
to make internal tools.

Puppet Labs (http://puppetlabs.com) uses Clojure in some of our internal tools, commercial projects, and open source stuff. I gave a talk on PuppetDB (https://github.com/puppetlabs/puppetdb) at Clojure/West a few months ago. It's currently in production at ~10k installations across the planet.
 

Thank you

Plínio Balduino

Stuart

unread,
Jun 13, 2013, 8:15:54 PM6/13/13
to clo...@googlegroups.com
We use Clojure across several APIs and for data analysis at SmartBIM in Atlanta, and we're hiring! Send me an email at stuart.hinson at the company's domain if you're local and interested

Travis Vachon

unread,
Jun 13, 2013, 8:38:26 PM6/13/13
to clo...@googlegroups.com
We've used Clojure at Copious (http://copious.com) to build our
activity feed (http://www.youtube.com/watch?v=0l7Va3-wXeI) and a
number of backend services.

We're definitely looking to use it even more in the future: it's the
cat's pajamas.

Zhemin Lin

unread,
Jun 13, 2013, 10:53:10 PM6/13/13
to clo...@googlegroups.com
We use Clojure in some backend services in Trend Micro.

Korny Sietsma

unread,
Jun 14, 2013, 12:14:09 AM6/14/13
to clo...@googlegroups.com
We're building a few clojure projects at IOOF (a large Australian superannuation firm) - the biggest is a transformation and routing system for communicating with other superannuation companies, written in clojure for the back end, and angular.js for the UI.

(It's technically in "production" but the actual go-live is in a few weeks.)

I talked about this at the local Yow Lambda Jam conference a few weeks ago - the slides should be up at http://www.yowconference.com.au/lambdajam/Program.html soon.  (they are actually there now, but seem to be corrupted...)

- Korny


On 14 June 2013 12:53, Zhemin Lin <lin.z...@gmail.com> wrote:
We use Clojure in some backend services in Trend Micro.
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.





--
Kornelis Sietsma  korny at my surname dot com http://korny.info
.fnord { display: none !important; }

Giacomo Cosenza

unread,
Jun 17, 2013, 9:49:51 AM6/17/13
to clo...@googlegroups.com
Hi Plinio,
we released today in production a clj/cljs application which implements an animated/interactive bubble chart on client side by getting tha data (in edn format) from the the server.

The client has been implemented by using clojurescript and the following main libs:
- domina
- c2
- d3

The server has been implemented by using clojure and the following libs:
- compojure
- korma
- necessary-evil
- timbre
- clj-logging-config

The edn format is exchanged between the server and client by using shoreleave-remote-ring and shoreleave-remote.

We're very happy with both clojure and clojurescript. In a couple of week we're going to release the bubble-chart component on github.

Mimmo



On Jun 10, 2013, at 11:47 PM, Plínio Balduino wrote:

> Hi there
>
> I'm writing a talk about Clojure in the real world and I would like to
> know, if possible, which companies are using Clojure for production or
> to make internal tools.
>
> Thank you
>
> Plínio Balduino

Robert Levy

unread,
Jun 17, 2013, 10:32:53 AM6/17/13
to clo...@googlegroups.com
Hi Plinio,

We use Clojure for nearly everything we do at Runa (we also have a little bit of Ruby and JS in our stack). For more info, see http://www.workatruna.com/clojure.html.

Rob

Alexander Kehayias

unread,
Jun 18, 2013, 9:54:13 AM6/18/13
to clo...@googlegroups.com
We're using Clojure at Shareablee, http://www.shareablee.com, a funded startup in the competitive social analytics space. Currently it powers data collection, an API proxy for maximizing data extraction from external APIs, and MapReduce jobs (via cascalog).

AK

Hussein B.

unread,
Jun 18, 2013, 10:12:00 AM6/18/13
to clo...@googlegroups.com
According to their "Jobs" page, Doo is using Clojure to implement their backend and web application:

Dave Ray

unread,
Jun 18, 2013, 11:32:40 AM6/18/13
to clo...@googlegroups.com
My team at Netflix is using Clojure for all new development these days.

Dave

Dennis Roberts

unread,
Jun 18, 2013, 12:44:13 PM6/18/13
to clo...@googlegroups.com
Hi Plínio,

We're using clojure for most of our back-end services at iPlant (http://www.iplantcollaborative.org). You can find our source code at https://github.com/organizations/iPlantCollaborativeOpenSource.

Dennis

Igor Hercowitz

unread,
Jun 18, 2013, 12:44:23 PM6/18/13
to clo...@googlegroups.com
Hi Plinio,

We're using clojure to develop our back-end.

We're using Rest, Compojure and Cheshire.
To test we're using Midje and Kibit to validate the code.

Unfortunately we have use some Java Legacy code... :)

Regards 
IHF

Plinio Balduino

unread,
Jun 18, 2013, 12:59:08 PM6/18/13
to clo...@googlegroups.com
Hi there

It's good too see brazilians working with the language. Igor, I'm waiting for your post about 'how Clojure saved the project'.

The Netflix case would be awesome to present. daveray, could you tell me more about it? It can be in pvt or even here if our fellows don't mind.

I would like to publicly thank you all for help me with this. The presentation was a success and soon I'll publish the slides.

For those out there who call Clojure a 'niche language', take that. :)

Regards

(balduino/plinio)

Moocar

unread,
Jun 18, 2013, 10:32:31 PM6/18/13
to clo...@googlegroups.com
We're using Clojure at Walmart mobile for some of our services. We've been in production for six months.


On Monday, June 10, 2013 2:47:25 PM UTC-7, Plinio Balduino wrote:

Russell Whitaker

unread,
Jun 19, 2013, 12:04:08 AM6/19/13
to clo...@googlegroups.com, clo...@googlegroups.com
But... is it also the bee's knees?

Russell Whitaker
Sent from my iPhone

Sean Corfield

unread,
Jun 19, 2013, 1:35:57 AM6/19/13
to clo...@googlegroups.com
It's the dog's b*ll*cks! :)

(since we're doing cultural slang, let's get some Britishness in there!)

Sean
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Nikita Prokopov

unread,
Jun 19, 2013, 2:46:56 AM6/19/13
to clo...@googlegroups.com
We're using Clojure for a year in one of our backend project (real-time social feeds aggregation & processing) at AboutEcho.com (Novosibirsk & Ulyanovsk, Russia). 1.5.1 + a little bit of ClojureScript for internal dashboard.

Florian Over

unread,
Jun 19, 2013, 3:40:57 AM6/19/13
to clo...@googlegroups.com
Hi,
we at doo.net are using clojure and clojurescript for all our backend and web development.
We are also still in need for clojure developers. :)

Florian


2013/6/19 Nikita Prokopov <prok...@gmail.com>
We're using Clojure for a year in one of our backend project (real-time social feeds aggregation & processing) at AboutEcho.com (Novosibirsk & Ulyanovsk, Russia). 1.5.1 + a little bit of ClojureScript for internal dashboard.

Hussein B.

unread,
Jun 19, 2013, 4:03:38 AM6/19/13
to clo...@googlegroups.com, floria...@googlemail.com
I mentioned that! :D

Phillip Lord

unread,
Jun 19, 2013, 4:46:45 AM6/19/13
to clo...@googlegroups.com



So, I was thinking that ' and ` were basically the same, unless a ~ was
involved somewhere. But I have discovered this.



(ns john)

(println '(paul))
(println `(paul))


;;=>
(paul)
(john/paul)

With the ' paul is not namespace qualified, while with the ` paul is.


Turns out to be a bit of a pain, actually, although I have worked around
it. But mostly I am surprised. Is this expected?

Phil

Jim

unread,
Jun 19, 2013, 6:32:12 AM6/19/13
to clo...@googlegroups.com
On 19/06/13 09:46, Phillip Lord wrote:
> With the ' paul is not namespace qualified, while with the ` paul is.
>
>
> Turns out to be a bit of a pain, actually, although I have worked around
> it. But mostly I am surprised. Is this expected?

Yes, this is very much expected! :)

How else would you be able to write macros without ` ?
Vars needs to resolve to something eventually...

Jim

Stuart Sierra

unread,
Jun 19, 2013, 9:42:21 AM6/19/13
to clo...@googlegroups.com
Hi Plínio,

At Relevance, we use Clojure on many consulting projects for clients ranging from small startups to Fortune-500 companies.

Datomic, a database, is written primarily in Clojure.

http://thinkrelevance.com/
http://datomic.com/
http://clojure.com/

Good luck with your talk.

Thanks,
-S



On Monday, June 10, 2013 5:47:25 PM UTC-4, Plinio Balduino wrote:
Hi there

I'm writing a talk about Clojure in the real world and I would like to
know, if possible, which companies are using Clojure for production or
to make internal tools.

Thank you

Plínio Balduino

Leon Barrett

unread,
Jun 19, 2013, 12:40:05 PM6/19/13
to clo...@googlegroups.com
Yes, it's expected, and if you need unqualified names you need to carefully unquote and requote, e.g.

(defmacro def-a-fn [body]
  `(defn ~'a-fn  ;; you can only define unqualified names, I think
     [] ~@body))


--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/a4Dp8gdHev8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+unsubscribe@googlegroups.com.

Colin Fleming

unread,
Jun 19, 2013, 6:04:29 PM6/19/13
to clo...@googlegroups.com
Thank you for this, you just fixed a bug for me :-)

I was trying to do some tricky type hinting with definline using amolloy's great answer on StackOverflow. Notice that he uses `BufferedImage and not 'BufferedImage. I stupidly figured that this was just a typo due to force of habit or similar and switched to using quote, and discovered that I had problems when BufferedImage wasn't imported when the inlined version of the function was called. Turns out that ` expands an imported class name to the fully qualified name, whereas ' does not.

(import java.awt.image.BufferedImage)
=> #=java.awt.image.BufferedImage
`BufferedImage
=> java.awt.image.BufferedImage
'BufferedImage
=> BufferedImage

Mea culpa. I'm not sure I would ever have made this connection, very timely - thank you.

Cheers,
Colin


--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.

Wei Hsu

unread,
Jun 19, 2013, 10:58:04 PM6/19/13
to clo...@googlegroups.com

Hi Plinio, 
I used Clojure at Airtime last year to do load testing and deploy infrastructure. More recently, I'm using Clojure to build Bitcoin-related projects backed by bitcoinj, including this bitcoin scratcher game for fun.

Phillip Lord

unread,
Jun 20, 2013, 3:49:21 AM6/20/13
to clo...@googlegroups.com
Jim <jimpi...@gmail.com> writes:
> On 19/06/13 09:46, Phillip Lord wrote:
>> With the ' paul is not namespace qualified, while with the ` paul is.
>>
>>
>> Turns out to be a bit of a pain, actually, although I have worked around
>> it. But mostly I am surprised. Is this expected?
>
> Yes, this is very much expected! :)
>
> How else would you be able to write macros without ` ?

Well, that doesn't answer the question. The backtick is useful in
writing macros (although the situation this caused me grief, actually, I
wasn't). So is quote. But then I do not understand why the behaviour is
different between the two.

> Vars needs to resolve to something eventually...

There are no vars involved here. `paul expands to a namespace qualified
symbol irrespective of the existence of a var.

Phil

Ambrose Bonnaire-Sergeant

unread,
Jun 20, 2013, 4:49:33 AM6/20/13
to clojure
Hi Phil,

It's a good question.

Syntax quote is designed for generating code/syntax that is deterministic and avoids accidental local name capture.

1. Automatic namespace qualification helps avoid accidental local name capture in macros.

user=> `(let [a# 1 
              b# a] 
          a#)
(clojure.core/let [a__48963__auto__ 1 
                   b__48964__auto__ user/a] 
   a__48963__auto__)

The binding for b# shows a common mistake. By namespace qualifying "a" to "user/a",
we don't allow the possibility of accidentally capturing locals.

eg. "a" is not captured in the body
(let [a 'evil]
  (clojure.core/let [a__48963__auto__ 1 
                     b__48964__auto__ user/a] 
     a__48963__auto__))

2. Automatic namespace qualification helps make code deterministic with respect to the namespace
of the consumer of a macro.

Syntax quote resolves vars in the namespace the *macro* is defined in. This avoids odd situations where
different vars are invoked depending on which namespace we use the macro.


Bottom line: syntax quote is designed for macros by default. All the good properties of syntax quote can be avoided using
combinations of quote, syntax quote and splice.

eg. `~'a
;=> a

Thanks,
Ambrose

Jim - FooBar();

unread,
Jun 20, 2013, 6:47:39 AM6/20/13
to clo...@googlegroups.com
On 20/06/13 08:49, Phillip Lord wrote:
Well, that doesn't answer the question. The backtick is useful in
writing macros (although the situation this caused me grief, actually, I
wasn't). So is quote. But then I do not understand why the behaviour is
different between the two.

I thought the question was whether this is expected or not that's why I answered accordingly...What I wanted to get across is that ` is critical for generating code (macro-writing) whereas ' has nothing to do with macros really. It's just a way of saying 'skip evaluation of this symbol - just pass it along'. However, whenever you do `(map ~f ~coll) what you really mean is (clojure.core/map some-fn some-coll) and that is exactly what the macro will expand to. Say, you had overwritten 'core.map' with your own version in that namespace...then the macro would expand to  (some-namespace/map some-fn some-coll) . If you swap ` for ' then what you get is a list with a bunch of non-qualified symbols in. Not very useful is it?

Ambrose went a bit further and explained local-name capturing & gensym. Even though automatic namespace qualification helps with that, it seems to be that this is not the primary reason for it. Being able to generate code dynamically without having to qualify every single symbol sounds more important to me...after all, avoiding local name capturing can be considered the programmer's responsibility...ok, the language helps with gensym etc but it should always be in the back of your head when writing macros. Even with gensym and syntax-quote there is still a way to achieve name capturing and I think 'the joy of Clojure' demonstrates an 'arguably useful'  example of this...

to sum up the behaviour is different because ` & ' are used to achieve different tasks. It often helps me to think of ` as resolving the symbol whereas ' doesn't do anything to it.

hope this is clearer now...

this is nice video http://www.infoq.com/presentations/Clojure-Macros  that explains the compilation process of Clojure and how macros make it harder to grasp.

Jim

Phillip Lord

unread,
Jun 20, 2013, 8:50:18 AM6/20/13
to clo...@googlegroups.com
Ambrose Bonnaire-Sergeant <abonnair...@gmail.com> writes:
> It's a good question.
>
> Syntax quote is designed for generating code/syntax that is deterministic
> and avoids accidental local name capture.
>
> 1. Automatic namespace qualification helps avoid accidental local name
> capture in macros.
>
> user=> `(let [a# 1
> b# a]
> a#)
> (clojure.core/let [a__48963__auto__ 1
> b__48964__auto__ user/a]
> a__48963__auto__)
>
> The binding for b# shows a common mistake. By namespace qualifying "a" to
> "user/a",
> we don't allow the possibility of accidentally capturing locals.
>
> eg. "a" is not captured in the body
> (let [a 'evil]
> (clojure.core/let [a__48963__auto__ 1
> b__48964__auto__ user/a]
> a__48963__auto__))
>


Ah, yes, this makes sense. So, rewriting the macro without the backtick
looks exactly the same, but can capture locals.

(defmacro remap3 [f & c]
`(map ~f ~@c))

(defmacro remap4 [f & c]
(list* 'map f c))

(let [map (fn [f & c]
(println "evil")
(apply f c))]
(remap3 identity (range 1 10)))

(let [map (fn [f & c]
(println "evil")
(apply f c))]
(remap4 identity (range 1 10)))


Only the latter is evil.


> 2. Automatic namespace qualification helps make code deterministic with
> respect to the namespace of the consumer of a macro.
>
> Syntax quote resolves vars in the namespace the *macro* is defined in.
> This avoids odd situations where different vars are invoked depending
> on which namespace we use the macro.


Yeah, this was what was confusing me, and was breaking my code. I was
using it to generate code, but not in a macro; my code generates a set
of (specific) Java objects from clojure, and I wanted to be able to
reverse the process -- render clojure forms from Java objects; this
was failing because the symbols were always being qualified in the
namespace of the renderer. In essence, I'm using ` for it's syntactic
convienience, rather than in a macro.


> Bottom line: syntax quote is designed for macros by default. All the good
> properties of syntax quote can be avoided using
> combinations of quote, syntax quote and splice.
>
> eg. `~'a
> ;=> a


I have converted my code to use this!

Thanks for the explanation. I was confused.

Phil

Phillip Lord

unread,
Jun 20, 2013, 8:35:43 AM6/20/13
to clo...@googlegroups.com

Oh yeah, how sneaky. In one case, you get a class, in the other, you get
a symbol. Backtick is doing quite a bit more than letting you unquote
and splice.

Colin Fleming <colin.ma...@gmail.com> writes:
> Thank you for this, you just fixed a bug for me :-)
>
> I was trying to do some tricky type hinting with definline using amolloy's
> great answer <http://stackoverflow.com/a/11920022> on StackOverflow. Notice
> --

--
Phillip Lord, Phone: +44 (0) 191 222 7827
Lecturer in Bioinformatics, Email: philli...@newcastle.ac.uk
School of Computing Science, http://homepages.cs.ncl.ac.uk/phillip.lord
Room 914 Claremont Tower, skype: russet_apples
Newcastle University, twitter: phillord
NE1 7RU

Phillip Lord

unread,
Jun 20, 2013, 8:57:40 AM6/20/13
to clo...@googlegroups.com
"Jim - FooBar();" <jimpi...@gmail.com> writes:
> On 20/06/13 08:49, Phillip Lord wrote:
>> Well, that doesn't answer the question. The backtick is useful in
>> writing macros (although the situation this caused me grief, actually, I
>> wasn't). So is quote. But then I do not understand why the behaviour is
>> different between the two.
>
> However, whenever you do `(map ~f ~coll) what you really mean is
> (clojure.core/map some-fn some-coll) and that is exactly what the
> macro will expand to.

In my case, when I really meant was "(map somefn somecoll)" hence the
confusion.


> If you swap ` for ' then what you get is a list with a bunch of
> non-qualified symbols in. Not very useful is it?


It does depend on what you are doing. I was generating data that could
be evaluated as code at some point.


> Ambrose went a bit further and explained local-name capturing & gensym. Even
> though automatic namespace qualification helps with that, it seems to be that
> this is not the primary reason for it. Being able to generate code dynamically
> without having to qualify every single symbol sounds more important to
> me...


You can do this either way.

(defmacro remap3 [f & c]
`(map ~f ~@c))

(defmacro remap4 [f & c]
(list* 'map f c))

I haven't qualified map in either case, both still work. But, as Ambrose
explanation shows, the former definition is better, because in the
former it is clearer what environment the qualitification takes place.

> hope this is clearer now...

It is! Both the reasoning behind the problem and how to avoid it was
causing me grief.

Phil

Ambrose Bonnaire-Sergeant

unread,
Jun 20, 2013, 9:08:14 AM6/20/13
to clojure
On Thu, Jun 20, 2013 at 8:50 PM, Phillip Lord <philli...@newcastle.ac.uk> wrote:
Thanks for the explanation. I was confused.

Cheers, glad it helped.

Ambrose 

Michał Marczyk

unread,
Jun 20, 2013, 10:14:51 AM6/20/13
to clo...@googlegroups.com
On 20 June 2013 14:35, Phillip Lord <philli...@newcastle.ac.uk> wrote:
> Oh yeah, how sneaky. In one case, you get a class, in the other, you get
> a symbol. Backtick is doing quite a bit more than letting you unquote
> and splice.

You get a symbol in both cases, though with a different name:

(import java.awt.image.BufferedImage)

(class `BufferedImage)
;= clojure.lang.Symbol

Cheers,
Michał
Reply all
Reply to author
Forward
0 new messages