140 points · by raju · 16y ago · 60 comments
Assuming you're trying to advocate Clojure, I'd recommend changing your tutorial to make things look easy (as opposed to highlighting gotchas). I recommend doing math examples first. Show how it makes a good calculator, but avoid discussion of ratios. That's (unnecessarily) confusing.. just like everything in the hello world example starting from the nil output on.
By the time I got to the sequence page, I just hit next to see if there was anything else of interest. I'd already gotten the strong impression this new language would just make my life harder. Worst of all though was when I flubbed up and typed (/4 3) rather than (/ 4 3).
Also, I'm trying to get Michael Fogus (author of Joy of Clojure) to write the tutorial. If he decides to do so, I can almost promise you quality. ;)
I'm not entirely certain I'm qualified to write a Clojure tutorial anyway, which is why I hope Michael is interested.
http://tryclj.licenser.net/ and http://www.try-clojure.org/ both point to the same IP. And both domains are registered to Heinz Gies - who I assume is the original author of TryClojure.
The console works fine on my FF 3.6.3.
Grats on a nice web-based repl though :)
Clojure is really appealing otherwise, though, as lisps go.
Edit (2x): I had a statement here of my particular problem at the moment, but then it changed, so I deleted it.
I gave up on that route and installed elpa on emacs, which I then used to install slime, swank, and clojure. Works great!
1) Add lein-swank to the dev-dependencies of the project I'm working on (i.e., add this - :dev-dependencies [[leiningen/lein-swank "1.1.0"]] - to your project.clj file
2) lein deps
3) lein swank
4) M-x slime-connect in emacs, then accept the default host/port
edit: Blogged it http://increasinglyfunctional.com/2010/05/18/my-swank-clojur...
http://www.assembla.com/wiki/show/clojure/Getting_Started_wi...
The Assembla wiki is a recent attempt at fixing problem of finding up-to-date 'getting started' documentation for Clojure.
(map if [true false true] [1 1 1] [2 2 2])
not that I can think of any reason why you'd want to do that (specifically) but Picolisp, Factor, REBOL and I'm sure a couple other languages implement if as a normal function. To take an example from some edition of programming clojure:
(defmacro unless [expr form] (list 'if expr nil form))
in factor:
: unless ( ? quote -- ) swap [ drop ] [ call ] if ; inline
no macro needed to futz with if's.
Does it have any advantages or is it just one of those things that "that's just how it's always been"?
(if x big_expensive_expression y)
than (funcall (if x (lambda () big_expensive_expression) (lambda () y))) someBoolean ifTrue: [ 'it was true' ] ifFalse: [ 'it was false' ]
Brackets introduce lambdas. I don't find this syntax clunky, and while I've never wanted to map ifTrue:/ifFalse: before, it's nice to be able to write your own special-form-like operators this way. (if (zero? x)
0
#(dec x))
To me, this seems a rather counter-intuitive step with very little benefit. People rarely need to use "if" as a function, so having "if" as a macro optimizes for the common case.What kind of precautions against newbie messes are there ?
And I'd hate to cause a melt-down :)
(Not knocking it. A lot of things don't work quite right on touch-only platforms. Try Haskell doesn't work either IIRC. Just a matter of testing and debugging I'm sure.)
Having REPL inline with the tutorial is great...wish someone would build something similar for Haskell.
Please hook this up to ymacs!
Also, the highlighting in the tutorials makes the code difficult to read.