Grails, SpringSource And Clojure Thursday, July 30, 2009

I recently developed a Grails plugin which provides support for easily accessing Clojure code in a Grails app. The details of how the plugin works are covered at http://grails.org/plugin/clojure. That page includes a link to a brief video demonstration which is available at http://s3.amazonaws.com/jeffscreencasts/grails_clojure_demo.mov. Check it out.

Shortly after publishing the plugin I posted something about it on Twitter. Not too long after that a couple of other SpringSource folks tweeted about Clojure (here and here). I got a couple of questions (in jest I am sure) about SpringSource and Clojure. "Is SpringSource Moving To Clojure?". Of course not. SpringSource is not moving to Clojure. SpringSource is all about helping folks build serious applications for the JVM and most of that is done in Java. This is not news. I work on Groovy and Grails. Much of what I do is in Groovy. This too is not news. Making it easy for folks to use languages like Scala and Clojure while taking advantage of all the great stuff that Grails has to offer, that is appealing to me and that is why I developed the Clojure plugin.

Clojure is a really interesting language. There are others. The fact that 3 folks from SpringSource have expressed some kind of interest in Clojure shouldn't be all that surprising. There are probably even more folks at SpringSource who have some kind of interest in Clojure but for entertainment, lets focus on the 3 mentioned...

I am honestly not sure how many technologists work for SpringSource but for the sake of having a number to work with, lets say there are 50. Lets also say that Clojure is interesting enough that 15% of JVM developers are interested in learning more about it. I can't back that number up with any research, lets just go with it. If 15% of JVM developers are interested in the language and you take a random group of 50 JVM developers (the 50 in question are certainly not 50 random developers, these are the edge cutters which probably makes them more likely to be interested in keeping an eye on what is new, but work with the idea that they are random)... Do the math. No, really... Do the math. Do the math to figure out the likelihood that 3 of the 50 would be interested in Clojure. I challenge you to do the math in Clojure and post your solution in a comment here. Do it in Scala, Do it in Groovy. Pick a JVM language and do the math.

The simplest solution is probably not very interesting. Prefer a solution that shows off something interesting in your language of choice.

Hmmm... are you more likely to need to refer to the Clojure book, or the high school math book? ;)

Now, you have one more reason to tinker with a new language.

Enjoy.

24 comments:

Keith Cochran said...

I'm not the best at probability, so I used the coin toss computation from Wolfram Alpha to get this particular example working. I also had to use the clojure contrib library for the math power function. Finally, I "borrowed" the factorial code from the clojure.org site and came up with this:

(ns grails
(:use clojure.contrib.math))

(def factorial
(fn [n]
(loop [cnt n acc 1]
(if (zero? cnt)
acc
(recur (dec cnt) (* acc cnt))))))

(defn probability
"The probability of A given B tries"
[a b]
(/ (factorial b) (* (factorial a) (factorial (- b a)) (Math/pow 2 b))))


-Keith

Keith Cochran said...

Forgot to include the result:

Probability of only 3 developers in 50 interested in Clojure:

1 in 1.74E-11. That assumes that 47 are completely uninterested. A very low probability indeed!

Weiqi Gao said...

My answer got too long to fit here. So I posted it as a blog entry here.

Christophe Grand said...

Doing Math is hard, let's compute:

;; probability that at least m out of n devs are interested in Clojure
;; when the probability of being interested in Clojure is p
(def prob
(memoize
(fn [p n m]
(cond
(pos? n)
(+ (* p (prob p (dec n) (dec m)))
(* (- 1 p) (prob p (dec n) m)))
(pos? m) 0
:else 1))))

(prob 0.15 50 3)
;; 0.9858114833989171

Unknown said...

We can use a binomial distribution to model this. We want to know the probability that at least 3 developers (or more than two) from a sample of 50 are interested in Clojure, and the probability that a developer is interested in Clojure is 0.15. We can use the cdf-binomial function in Incanter (a Clojure library) to calculate that probability. I'll set the :lower-tail option to false to get the probability that more than two developers are interested (the default would tells us the probability that at most two are interested).

(use 'incanter.stats)
(cdf-binomial 2 :size 50 :prob 0.15 :lower-tail false)

Which returns 0.986, so the likelihood of getting at least three developers that are interested in Clojure from the sample of 50 is over 98% (given an assumption that 15% are interested).

David

Anonymous said...

you have a nice site.thanks for sharing this site. various kinds of ebooks are available here

http://feboook.blogspot.com

Anonymous said...

Nice article as for me. I'd like to read a bit more about that topic. Thank you for posting this information.
Sexy Lady
Call girls

Anonymous said...

Cool story you got here. I'd like to read something more concerning this topic. The only thing I would like to see on that blog is a few pics of some gizmos.
Katherine Watcerson
Cell jammer

Webmaster said...

I appreciate the information. Java is one of the consistent player from the development industry which has been providing the wider scope for developers to come out with different solutions.

generic propecia said...

Hello people want to express my satisfaction with this blog very creative and I really like the views of the focus very good indeed Thank you for the helpful information. I hope you keep up the good work on making your blog a success!

Volker from Germany said...

Hallo,
Ich haben eben Eure Internetseite besucht und nutzen sogleich die Gelegenheit,euch auch einen Gruß aus Deutschland in Eurem Gästebuch zu hinterlassen. P.S. Kommt uns doch auch mal besuchen

Reinhard Sakowski said...

Viele Gruesse aus dem schoenen Fischerdorf Greetsiel.

send flowers to germany said...

I suggest this site to my friends so it could be useful & informative for them also. Great effort.

Cheap Viagra said...

Greetings Jeff Brown and readers!
I have been researching on the net in order to find some affairs which are surely going to help me n my way to finish a High School proyect. Anyway, What I meant is that this column made my day.

Anonymous said...

http://away-panic.co.cc/
http://bo-oks.info/
http://cbengine.info/
http://top-ebooks.co.cc/
http://onlineebooks.co.cc

iPhone Developers said...

We want to know the probability that at least 3 developers (or more than two) from a sample of 50 are interested in Clojure, and the probability that a developer is interested in Clojure is 0.15. We can use the cdf-binomial function in Incanter (a Clojure library) to calculate that probability.

Admin said...

thanks for sharing this site.

Suman Kira said...

You developed a great plugin.

hotel louisville said...

Oh, so evocative! I'll get me staff doing the work. Thanks a lot for sharing this stuff.

Prank Calls said...

Nice blog and nice post! The topic here I found is really effective.

Show Plates said...

I really appreciate the way you are sharing your experiences.
http://www.squidoo.com/show-plates-uk

Tina Fey said...

Very value able post, it keep me onto reading your whole story.

oracle fusion financials training in kukatpally said...

Thanks for the statistics. i discovered your blog very interesting,our java online training supplier won the high commonplace name through international for its coaching for more information please check the site

Oracle Fusion said...

Nice effort, very informative, this will help me to complete my task. Thanks for share This is just the kind of information that I had been looking for few days.
Oracle Fusion HCM Technical Training