News for hackers. Stuff that matters.
Re:Clojure from the ground up: Macros by juliangamble on Friday November 29, 2013 @09:24PM (#6822011)
One of the most powerful uses of Clojure's macro system has been in the core.async library. This has enabled the construction of a library with operators similar to Go's Communicating Sequential Processes [Hoare 1978].

What is different about Clojure's implementation is that no changes to the compiler were required - 'deep walking macros' (http://blog.fogus.me/2013/07/17/an-introduction-to-deep-code...) were used - that actually restructure the code.

The benefit of this in the library is that when a process is blocked, the wait is converted to data and the thread is freed up and returned to the pool. You can have multiple processes talking to each other with a thread-pool size of one. (And still reason about the code in a neat way).

The benefit of this comes in the JavaScript environment, (via ClojureScript) where you can compile code that you would ordinarily coordinate with threads using CSP. (With Go-lang style operators)

You can see an example of this on David Nolen's pages here: * 10,000 processes http://swannodette.github.io/2013/08/02/100000-processes/ * 100,000 updates http://swannodette.github.io/2013/08/02/100000-dom-updates/

This is the power of macros in Clojure - things that would require a compiler extension in another language, are a library in Clojure.

Re:Clojure from the ground up: Macros by gnaritas on Friday November 29, 2013 @10:40PM (#6822162)
That last sentence should more aptly be "This is the power of macros in a Lisp - things that would require a compiler extension in another language, are a library in a Lisp." as all the other Lisp's have the same advantage; Clojure is not special in this regard.
Re:Clojure from the ground up: Macros by cbp on Friday November 29, 2013 @10:47PM (#6822180)
Clojure has other advantages which other lisps and go don't have such as immutable values and a prevalence of expressions (as opposed to statements), both of which give core.async certain features that go's implementation lacks.
Re:Clojure from the ground up: Macros by brudgers on Friday November 29, 2013 @11:55PM (#6822343)
Statements are pretty rare in any of the Lisps since the basic syntactic form is the s-expression.

I believe immutable values are a result of programming style. A person can choose to use Clojure's Vars, Refs, Agents, and Atoms [1] even though Clojure tends to encourage a functional programming style. Clojure inherits the functional programming tradition from the larger Lisp family (as does Racket).

That said, Rich Hickey has a great of describing how to avoid unnecessary mutation - usually you want the next value so just make a new one rather than changing the existing one.

[1] http://clojure.org/vars

Re:Clojure from the ground up: Macros by carterschonwald on Friday November 29, 2013 @11:05PM (#6822240)
False.

Please go read up on modern scheme. particularly racket lang.

In many respects, Clojure is Racket, but on the JVM rather than native.

Re:Clojure from the ground up: Macros by rsanders on Friday November 29, 2013 @11:25PM (#6822286)
Racket is one other good example but he was responding to the "all other lisps" claim. Racket pretty unusual in many regards, so I think the Dwightian "False" was unnecessary here. Or anywhere, really.
Re:Clojure from the ground up: Macros by brudgers on Friday November 29, 2013 @11:59PM (#6822349)
Racket is a Scheme: Racket is still a dialect of Lisp and a descendant of Scheme. The tools developed by PLT will continue to support R5RS, R6RS, the old mzscheme environment, Typed Scheme, and more. At the same time, instead of having to say “PLT's main variant of Scheme,” programmers can now simply say “Racket” to refer to the specific descendant of Scheme that powers PLT's languages and libraries.

http://racket-lang.org/new-name.html

Re:Clojure from the ground up: Macros by rsanders on Saturday November 30, 2013 @06:29PM (#6825169)
Indeed. Now name all the other Lisps and Schemes in wide use that are based on immutable data structures.
Re:Clojure from the ground up: Macros by chongli on Saturday November 30, 2013 @12:11AM (#6822372)
Clojure is a more opinionated language. It has a BDFL who has really stamped his mark on it. This is very much reflected in the standard library and the built-in syntax for the standard collections. Sure, nothing is stopping Racket from doing everything Clojure does, however defaults do matter. Once a language reaches critical mass, it becomes very difficult to change without breaking everything.
Re:Clojure from the ground up: Macros by carterschonwald on Saturday November 30, 2013 @04:46PM (#6824759)
If you think Racket doesn't have a defacto unofficial BDFL, youve not met the core team, let alone Matthias Felleisen. Brilliant, nice, and loudly communicative folks all!

Racket has one of the most thoughtful, opininonated, and caring core dev groups of any language, bar none. Any implication otherwise comes from ignorance. :)

Re:Clojure from the ground up: Macros by billsix on Friday November 29, 2013 @11:34PM (#6822304)