Hacker News new | past | comments | ask | show | jobs | submit login
ClojureScript Koans: Learn ClojureScript from inside your browser (clojurescriptkoans.com)
183 points by lazerwalker on Nov 22, 2013 | hide | past | favorite | 36 comments



There are some good criticisms here about some of the discontinuities in difficulty, but first and foremost I really want to congratulate OP for doing something to address the instant gratification problem in learning to program. You can open this site in your browser and immediately start interacting with code rather than trying to get your java environment/editor/etc. set up, and that's fantastic, we really need more tools like this.


I like this, but it seems too cryptic for a true novice to actually learn from, especially if they've never been exposed to Lisp syntax. Who is the intended audience?

I see that it's something of a port of the Clojure Koans, has there been much feedback on that as to whether people are able to truly learn the language this way? I'm intrigued by new methods of instruction, but this seems like it would be a very frustrating trial-and-error game to a beginner, as there is virtually zero actual teaching. We're supposed to be making programming more accessible, not less. It seems like this kind of thing ends up as a fun toy/experiment for people who already know most of it.

It is very nice though.


Creator here.

You're totally right it's not a good way to learn the language in isolation. A little context: this is the first project I've built in any Lisp, so learning Clojure/ClojureScript from scratch is still very fresh in my mind.

When I worked through the original Clojure Koans, I had a REPL open and made judicious use of online resources to figure out each answer. As an experienced programmer who was brand new to Lisp, treating the koans as a sort of 'open-book exam' was very effective for me. Perhaps explicitly suggesting that workflow on the home page would be a simple but worthwhile addition.


For what it's worth, my non-programmer coworkers were able to deduce many of the answers just from context. The gradual difficulty ramp is quite good, only bumpy in a few places (higher order functions is a bit of a sudden jump for those who aren't well-versed in functional thinking). I'm a relatively seasoned programmer, who is gradually becoming familiar with Clojure/script, and really enjoyed these exercises. Definitely not a teaching tool, but a fantastic assessment of what parts of the language come easily, what parts I need to review, and excellent practice reading the language.


Really fun! Reminds me of "little Schemer"* in the sense that there are no 'instructions' so you are encouraged to try various things out.

In my opinion this way of doing it is good. It works for me.

* http://mitpress.mit.edu/books/little-schemer


It would be very nice if each koan had docs included underneath (maybe hidden by a hint link?) talking about what the koan was trying to teach you. If you can do every single one it isn't that much fun, but if you can't do every single one then you need to go off and learn something and it would be really good to help nudge the user along to where they can learn more. Alternatively to a help box having the displayed code provide links to the appropriate clojure docs would be another route.


>I like this, but it seems too cryptic for a true novice to actually learn from, especially if they've never been exposed to Lisp syntax. Who is the intended audience?

Well, I am definitely learning from this. I always wanted to explore Clojure/ClojureScript and I read first chapter of SICP so I understand Lispy syntax, but I never followed through.

I love how this website doesn't try to appeal to novices, because I'm always frustrated reading beginner guide to languages, because they're easy too slow- or too fast-paced. This one strikes a nice balance, without being too pedagogical. It lets me make guesses. I like this approach a lot.


Worked beautifully for me, looks like I belong to the 'intended audience' category.

Background: Experienced functional, OOP, web dev. Know enough elisp to get by.

TY @lazerwalker


This goes from easy/novice up to advanced level in a short amount of time. I did some koans until I arrived at functions/9 which is:

(= 25 ( ___ (fn [n] (* n n))))

I found this one to be not so trivial, granted I'm still a novice clojure user, but I still think that it went up rather steeply here.

I think if they really want to introduce new people to ClojureScript, then the koans need a friendly help system and the ability to show the solution and have it explained to you.

It should also have a short introduction in Lisp that explains prefix notation / s-expressions. I think that would make things a lot easier.


(fn [f] (f 5))

I do love the format, but what I like a bit better about Clojure Koans is that you can see the previous ones for a bit of a reminder.

Maybe for each section, they could leave up the ones you'd successfully completed so you could refer to them.

Other than that minor nitpick, I love this.


Or the threading macro #(-> 5 %)


Or (fn [f] 25)


    (constantly 25)


also #(% 5)


I have to say that this one came out of left field. Would have been much better at the end.

Also, not sure what happened here: http://clojurescriptkoans.com/#runtime-polymorphism/4

I guess it ends here?


It doesn’t end there. On that page, you have to edit the code in the gray boxes at the bottom, not the big code at the top. (I recommend copying your answer to that page before you submit it; you can then adapt that answer for the problems on the next two pages.)


This was exactly the koan that I felt had the biggest discontinuity, and yeah, having the previous ones visible might help.


Spoiler: #(%1 5)


Very nice!

Would like to see it feature a ToC so one can easily move between the koan categories.


Thanks! (Creator here.)

I came this close to delaying the site launch so I could build in a table of contents, but figured it wasn't 100% essential to shipping. Given the great response I've gotten to the koans, I'll probably add one in very soon.


I'm working thru it in order. I didn't feel the need to jump around, but it would be nice to know how much longer I have to go, i.e. how many more screens.


This reminds me of http://4clojure.com with a simpler [nicer?] (but less featureful) UI.

I want to add a slightly off-topic remark, but 4clojure actually runs the tests in a sandbox on the server. This is compiling to ClojureScript, and I have to wonder if it's "good enough" or whether down the line some koans might run into problems being ClojureScript instead of the real Clojure on the JVM.


Indeed. I like the non visible UI. Almost Brett Victorian.


#5 in sequence comprehensions part doesn't seem to work for me. I've checked my solution in console clojure interpreter and it evaluates to true there.


Same here. After checking in a local ClojureScript REPL, I just changed the URL to sequence-comprehensions/6 and went on.


It worked for me with `[row column]`.


I was playing with this, but is a little long and I wanted to know if the end is near, so add a percentage bar also it would be useful to have an index of topics.



http://clojurescriptkoans.com/#higher-order-functions/10 got me good. Why is it one needs to use `(count a) (count b)` instead of just `a b` like worked when comparing string lengths in a previous ClojureScript Koan?


The `<` function only works on numbers but, unlike java, it will correctly coerce numbers with different representations.

    (< 1 ;; Long
       1.5 ;; Double
       2N ;; BigInt
       )
If you want java-style comparisons use `compare` instead.

EDIT: Ooops, this is cljs, not clojure. The correct answer is that string comparison is lexicographic in js:

    "is" < "length" < "word"


Awesome site!

Having done a few Clojure projects lately, I got most of these right immediately, but there were a few I messed up. It would be cool if you could go through these flashcard-style: one try for each koan in a category, then re-show the ones you got wrong, and repeat until you get them all right.


Anki, has Clojure flash-cards.


Really interesting way to learn. I made it into vectors and then got completely stuck on subslice. Maybe a hint text or something or a way to skip it or get the answer if I have not got it after a few tries.

I might be typical but once I hit that screen and could not go further I closed it.

Still really good work!


I chuckled when I realized you could just copy and paste the expression and it will pass the equality test. Obviously you don't learn anything this way, but I'll admit I used it once or twice when I got stumped.


Interesting... I would second adding some hints after n failed attempts. You could just expect the user to go off to google but it'd be a nice touch to get a small hint in-place.


Nice, but needs help / clues




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: