Posts Tagged ‘languages’
Mastermind in Clojure and Java
Have you heard of mastermind? It’s a logic game in which one player repeatedly tries determine the secret code that another player set at the beginning. With each guess, the player is given information on how many correct pegs his guess contains, and how many are in the correct position. For more details on the rules, check the wikipedia article.
I built a Clojure implementation of Mastermind as a learning project. (Code and details of functionality at github.) My primary goals were to gain familiarity with the language, and to see what the functional programming paradigm feels like when working on a project that is larger than one big function. After I finished, I re-implemented (almost) all of the features in Java for a comparison. (Code also available at github.) Interested in the results? read on.
Why my code is rarely Groovy
I’ve spent over half a year using Groovy as my primary language, and it was a very good experience. The flexibility of Groovy is a joy to anyone coming from the rigid Kingdom of Nouns, and the Grails web framework is excellent, far preferable to the various combinations of Struts/Spring/Hibernate (and others) that I had used with Java. And for a Java developer, the benefits of using the familiar, rock-solid Java infrastructure — libraries, web application servers, and the JVM itself — are significant.
I often found myself wondering why Groovy doesn’t get more interest among Java developers. After all, everyone needs a scripting language for small tasks, why not use one that you practically know already? And just because your production code is Java doesn’t mean you can’t test with Groovy.
But then a funny thing happened.
Don’t forget Erlang
Everyone should learn to think functionally and recursively. But how? With which language? I think that one of the best options for functional programming is largely overlooked … Read the rest of this entry »
Written by Eric Wilson
September 5, 2012 at 6:25 am
Posted in commentary
Tagged with erlang, haskell, languages, lisp, recursion, scheme