

Show HN: Clojure by Example - kimh
http://kimh.github.io/clojure-by-example/#hello,-world!!

======
jonnybgood
Would be awesome if interactive like the interactive SICP[0]

[0] [http://xuanji.appspot.com/isicp](http://xuanji.appspot.com/isicp)

~~~
fierycatnet
Woah. I've been wanting to finish SICP book along with MIT lectures and this
site looks like another great addition. This gives me a boost in motivation to
finish the book.

If someone ever comes up for something like this for Clojure then it would be
incredibly awesome.

------
lewisl9029
For those who prefer learning in a more passive manner, I've found these sets
of screencasts on the Clojure Koans quite useful too.

[http://www.clojurescreencasts.com/koans-
walkthrough/01.html](http://www.clojurescreencasts.com/koans-
walkthrough/01.html)

------
nerd_stuff
This is a great project!

I believe there's a lack of clarity in the let form explanation:

    
    
      =>(let [object "light"]
      =>  (let [object "darkness"])
      =>  (println (str "God said let there be " object)))
      God said let there be light
      nil
    

'object' is overwritten but only within the second let form:

    
    
      =>(let [object "light"]
      =>  (let [object "darkness"]
      =>    (println (str "God said let there be " object))))
      God said let there be darkness
      nil
    

or even:

    
    
      =>(let [object "light"]
      =>  (println (str "God said let there be " object))
      =>  (let [object "darkness"]
      =>    (println (str "God said let there be " object))))
      God said let there be light
      God said let there be darkness
      nil
    

The reason for this is the let form uses lexical scoping. In other words it
creates a new frame which includes the bindings declared in the square
brackets. When 'object' is evaluated its binding is looked for in the current
frame, then the frame that called that frame and all the way out into the
global namespace stopping when a binding is found.

See also: [http://stackoverflow.com/questions/1774417/scoping-rules-
in-...](http://stackoverflow.com/questions/1774417/scoping-rules-in-clojure)

~~~
fnordsensei
This would be better for illustrating that object is not overweritten, I
think:

    
    
      =>(let [object "light"]
      =>  (let [object "darkness"]
      =>    (println (str "God said let there be " object)))
      =>  (println (str "God said let there be " object)))
      God said let there be darkness
      God said let there be light
      nil

~~~
kimh
Thanks for this. I added your example with slightly different form!

------
kimh
If the site looks cool and slick to you, then you should give a star to
[https://github.com/tripit/slate](https://github.com/tripit/slate) which I
used to create the site.

I found Slate is very easy to use and customize!!

------
hoprocker
Lovely. A nice addition would be a floating REPL to try things out as you go
along, maybe at the bottom of the screen with a dash of transparency.

(I know I know, there are plenty of other ways to access a Clojure REPL!)

------
TickleSteve
Clojure has always been slightly disappointing for me...

The principles behind its design are all sound and Rich Hickey deserves credit
for putting in the hard thought behind it.

... but.... the reality seems to be of a really under performing language. The
forums are consistently full of people with 'why is this slow?' to which the
solution is always 'Give it more hints' or 'do it in a more Java like way'.

Unfortunately the Clojure stack seems not to have much mechanical sympathy
(despite its best intentions). It seems the natural/idiomatic way to use
Clojure results in far too much dynamic behavior to be performant. Clojure may
scale well, but its inherent bad performance (without lots of work) is a major
downside.

I forget who said this, but it seems very appropriate to Clojurists... "Show
me you can use one machine well before you get another..."

~~~
codeshaman
I aggree. I love the language and concepts, but at some point, after two
months of learning it, I've got fed up with the slugishness of the whole thing
and gave up because I have no idea what to do with it.

I also found it a very difficult language to learn. I felt like I was taking
baby steps every day, although I was giving it all I could. I felt stupid and
frustrated to the point that I'm actually considering quitting the profession,
because, well, I'm not good enough for this.

Contrast that with Objective-C which I learned last year - it took me a couple
of weeks to become profficient and start writing real world, commercial apps
which I can sell. Maybe 15 years of daily C++ programming has had something to
do with it, but still.

I struggle to imagine a practical project which I could use clojure for.

Front end, user-facing apps, utilities, system tools - forget it - an app
takes 15 seconds to load and uses gigabytes of RAM.

Backend - maybe, but there are a lot of other languages and frameworks out
there which are really powerful and have huge communities.

So I don't know, I really love clojure, but the JVM just doesn't cut it for
me. I want a C++ version of Clojure, which I was thinking about starting every
single day I was learning it.

~~~
dasmoth
[https://github.com/pixie-lang/pixie](https://github.com/pixie-lang/pixie)
could be worth a look.

That said, "add more type hints" hasn't generally been my experience of
Clojure. If anything, it tends to be an indication that you've already gone a
bit far down the path of "doing things the Java way".

~~~
TickleSteve
If you read the forum threads on performance issues, what they generally come
down to is type-hints & using Java types. The problem is that _idiomatic_
clojure doesn't perform well (it may scale well but you throw away a bucket-
load of performance by using it anyway). The way to get truly good performing
Clojure is to write Java...

Pixie does look promising and is more my type of thing (coming from a low-
level background) but I haven't managed to have time to look at it properly
yet tho.

------
mayneack
This is super helpful. Reminds me of bropages:
[http://bropages.org/](http://bropages.org/)

------
elwell
Looks cool. Code indentation error/confusion at
[http://kimh.github.io/clojure-by-
example/#future](http://kimh.github.io/clojure-by-example/#future) though.

------
melipone
Remind me of the little schemer. How about a "The little clojurist" book?

------
josebaezmedina
It reminds me to
[http://learnxinyminutes.com/docs/clojure/](http://learnxinyminutes.com/docs/clojure/)
but prettier.

------
thomas11
[http://www.4clojure.com/](http://www.4clojure.com/) should also be mentioned
here. I had a lot of fun there.

------
hajims
This should be posted over to r/clojure

~~~
icey
That's a great idea; just posted it over there and added it to the sidebar.

------
elangoc
I love it!

The target audience is people with prior programming experience. It's
important to know the target audience, either as a writer or reviewer.

The tutorial webpage is simple and effective with a gradual progression in
concept difficulty.

I hope we have more things like this! Thanks!

------
fierycatnet
Cool, thanks! Looks like a nice reference.

------
dvliman
this is exactly how intro to programming language should be (for people who
already know other languages)

------
pvdebbe
Great execution, but the indentation is wonky at times, making it difficult to
see the idea.

------
abc_lisper
Good job Man! Bookmarked.

------
maelito
Very pleasant to read

