7 ms·
Learn Clojure with Clojure Koans
- bernatfp 14y agoI've done them as an introduction to the Clojure language and it's been great. Now I'm into 4clojure to keep on practising the syntax and to get my mind to think _the functional way_ Any other resource to be suggested?
- skyraider 14y agoI did a few Project Euler (http://projecteuler.net http://projecteuler.net) problems in Clojure after doing the koans. I found it really helpful to implement solutions in some imperative or multi-paradigm language, and then go back and do the solutions again in Clojure. Each problem made me curious about the best way to solve it in Clojure, which led to lots of learning.
- arkx 14y agoI've had fun solving the Rosalind collection of introductory bioinformatics problems: http://rosalind.info/problems/list-view/ http://rosalind.info/problems/list-view/
- tom_b 14y agoI was playing with the Rosalind problems using clojure. It was great fun, although I did evil things with the clojure combinatorics library and in one memorable session, datomic datalog. I need to revisit them, but the thornier (for me) problems kept distracting me from other work.
- zephjc 14y agoYou can also do them online at http://www.4clojure.com/ http://www.4clojure.com/
- pivo 14y agoSince this is for new Clojure users I think the install instructions should include how to install the koans with Leiningen. The instructions say to install Leiningen but once you've got that working you won't know how to use it to install the koans.
- eccp 14y agoI don't agree, I'd advise not to try Leiningen until you're comfortable enough with the parenthesis, the REPL and finish the koans themselves. This is 'getting your feet wet on Clojure', koans style. No need to introduce yet another tool when you're not dealing with the issues which Leinengen solves: managing library dependencies and configuration. I remember I did: the koans first, then tried several exercises on the 4clojure website, then learned about Leinengen and only then I moved into 'projects'.
- pivo 14y agoOk, but the site's first suggestion is to use Leiningen to install the koans. It links to a generic Leiningen installation page, but then doesn't tell you how to use it to install the koans. Unless they expect the new user to spend significant time learning about that tool before moving on to their koans, I think it'd really be much better to have a short how-to for that.
- vemv 14y agoIf you have lein, you can run `lein repl` which provides awesome tab-completions, documentation, and source for any given function. Pretty handy for beginners I'd say!
- cgag 14y agoA whole lot of people who try to get started with Clojure without lein never actually get to a repl or runnable project.
- nelsonweiss 14y agoPolitely, I'd advise the opposite. Learn Leiningen- not only because it makes Clojure simple and pleasurable to use, but because it'd be a fantastic tool no matter what language it was part of. Project skeletons (new new), command line scripting (via lein exec), deployment, the wonderful 'lein ring server', custom plugins... and for those who just want to get their feet wet, 'lein repl' brings the ocean to you.
- 14y ago
- sirclueless 14y agoI don't know if this is just their test runner or whether it is a problem in Clojure proper, but it's really frustrating to see "Assertion failed" with zero description of the runtime error. I have to fire up a REPL and reverse engineer the expected value, instead of just observing what the expression evaluates to as in the ruby koans. As an example: "But watch out if you try to pop nothing" (= __ (try (pop '()) (catch IllegalStateException e "No dice!"))) That code causes an error that looks like this: Problem in /home/clueless/clojure-koans/src/koans/02_lists.clj --------------------- Assertion failed! But watch out if you try to pop nothing (= __ (try (pop (quote ())) (catch IllegalStateException e "No dice!"))) That's just a transliteration of the Clojure expression from my source code. It's not even as good as a line number, because it's not greppable. If I were actually to encounter this in a failing test, you had better believe I would want to know what the right-hand-side actually evaluated to in context, not just what the compiled expression looks like.
- martinced 14y agoThis is some kind of a sad example you put here on HN... This is basically the worst part of Clojure (and only on the JVM at that): catching a Java exception. I know that's not your point but --and I'm a huge Clojure fan-- seeing a Java idiosynchrasy like that one makes me want to give up Clojure : (
- sirclueless 14y agoIn this case it's a Java wart, yes, but the same thing happens with other parts of the language. Another example: "Conjoining an element to a list can be done in the reverse order" (= __ (conj '(:a :b :c :d :e) 0)) Well OK, so is `conj` just `cons` with reversed argument order, or does it append to the other end of the list? My Lisp intuition tells me that the first is more likely, but the test failure doesn't show you anything, you have to use trial and error or fire up a REPL.
- cicero 14y agoThere's more to conj. It does a cons for lists, but works differently for other types of collections. You might find it helpful to lookup things in ClojureDocs. http://clojuredocs.org/clojure_core/clojure.core/conj http://clojuredocs.org/clojure_core/clojure.core/conj
- vemv 14y agoAs for koans + tdd as the means for learning a lang, ymmv. I for one prefer an undisciplined, bootstrappy approach: - find a function / aspect of Clojure that calls my attention - read the doc / try to understand the rationale - give it a sample use case, try to connect it with previous lessons - recur!
- Cymen 14y agoAs a somewhat recent practicer of tdd, I find that the koans + tdd approach is more rounded: I'm forced to learn/use a function/aspect that I might have glossed over. And occasionally a particularly nice usage of syntax jumps out and gets adopted.
- apinstein 14y agoDoes anyone know how to run these in Light Table? I really love the idea of that and was hoping to try it to learn Clojure, but I have absolutely no idea how to run the koans from inside Light Table.
- myko 14y agoI did 'lein koan run' in my terminal and opened the first file up in LightTable, then made my first edit and hit save - the terminal updated automatically as I saved my changes.
- Sandman 14y agoExercises on http://www.4clojure.com http://www.4clojure.com seem like a much easier way to get your feet wet with Clojure. It's good when new users can try a language out right in their browsers, without having to install any additional software.
- cicero 14y agoI agree that 4clojure.com seems an easier way to get started. However, if you're already setup with Clojure on your machine, using clojurekoans.com has the advantage of allowing you to work in your editor of choice.
- deleted 14y ago[deleted]
- Posibyte 14y agoThis is the first time I've seen something like this, but it's greatly broadened my knowledge of Clojure over the past few hours. I've always had trouble trying to find out where to begin. Lisps are foreign to me, and functional programming was and is still a mostly foreign concept. However, things like this that are so simple and understandable make such great introductions. Kudos to the authors, and you have a thumbs up from me.
- dschiptsov 14y agoHas nothing to do neither with oriental philosophy nor programming.)
- willismichael 14y agoThe most maddening part of your comment is the unbalanced paren at the end.
- sathish316 14y agoThere is an online version of Clojure koans built using Noir available here: http://clojurekoans.herokuapp.com http://clojurekoans.herokuapp.com