Try Clojure
try-clojure.org
try-clojure.org
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...
Here's what I had to do: - Download the lein script and put it in my PATH
- Download package.el and put it in my .emacs load-path
- lein self-install
- make a project directory, and 'lein new projname .' inside it
- modify the resulting project.clj to add :dev-dependencies [[leiningen/lein-swank "1.1.0"] [swank-clojure "1.2.1"]]
- lein deps in said directory
- Install package.el, and then install slime, clojure-mode, slime-repl, and swank-clojure with it (and fight with it and get confused about why it didn't know about slime-repl until I installed it several times but then noticed it when I restarted Aquamacs)
- lein swank in said directory
- M-x slime-connect from Aquamacs
Am I doin it rong?
2. Ran "M-x package-list-packages"
3. Installed clojure-mode, slime, slime-repl, and swank-clojure.
Then I rebooted emacs and "M-x slime" just works for me (aquamacs).
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.Deleted comment
if cnd:
return do_big_stuff
else:
return do_other_big_stuff
has different semantics than a hypothetical "if" function call: def a():
return do_big_stuff
def b():
return do_other_big_stuff
return if(cnd,a(),b())
Note here, both "do_big_stuff" and "do_other_big_stuff" are evaluated, regardless of the value of "cond".A short-circuiting if (only possible if "if" is a special form) will ONLY evaluate a() (and thus "do_big_stuff") if "cond" returns a truth-value.
Now, Factor's "if" works like this (in python):
return if(cnd,a,b)()
That's fine- and it still has the short-circuiting semantics, but there's still a question of taste here.In which case I agree it's a matter of taste. I guess I just like the taste of Factor/REBOL always passing blocks to if, having to say t [ 0 ] [ 3 ] if instead of simply say t 0 3 if is the trade off I suppose[1].
I'm guessing it works for picolisp because it's purely interpreted? because it certainly doesn't seem to be passing lambdas to 'if'. Can anyone confirm/deny?
[1]well actually the word ? does that but to make it work for both you need to do:
: myif ( ? true false -- ) ? dup quotation? [ call ] [ ] if ; inline
(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.