News for hackers. Stuff that matters.
Re:Direct Clojure to C Compiler - Based on ClojureScript by alberich on Monday July 09, 2012 @09:55AM (#4218170)
I wonder what would be the advantages of using Clojure without the JVM over, say, Common Lisp. To me, it seems the great advantage of Clojure is its ease of using the large number of java libraries out there. However, if you take those libraries out, wouldn't a mature Lisp implementation like SBCL be much better?
Re:Direct Clojure to C Compiler - Based on ClojureScript by pjmlp on Monday July 09, 2012 @10:02AM (#4218195)
There a few differences that might be worth still.

Clojure is a Lisp-1, and provides better data structures as Common Lisp as far as I am aware.

But the JVM benefit is a big one indeed.

Re:Direct Clojure to C Compiler - Based on ClojureScript by alberich on Monday July 09, 2012 @10:10AM (#4218226)
I thought that, besides the JVM itself, the advantages of Clojure would be its concurrency model - as CL standard doesn't define anything related to this - and its stronger functional approach.

I don't fully grasp the advantages of being a Lisp-1 or Lisp-2 :)

Re:Direct Clojure to C Compiler - Based on ClojureScript by pjmlp on Monday July 09, 2012 @10:21AM (#4218293)
> I don't fully grasp the advantages of being a Lisp-1 or Lisp-2 :)

It has to do with variable scoping. Lisp-1 only accepts lexical scoping, while Lisp-2 also allows for dynamic scoping.

http://www.nhplace.com/kent/Papers/Technical-Issues.html

Re:Direct Clojure to C Compiler - Based on ClojureScript by mahmud on Monday July 09, 2012 @10:48AM (#4218424)
Good grief.

No.

Lisp-N has to do with the number of name spaces in the language. Lisp-1s only have ONE environment; the variables range over all values of the language, integers, functions, vectors, symbols, strings. In Lisp-N, there are N namespaces for each "kind" of value.

Common Lisp is called a "Lisp-2" because it separates functions from other values. (it's closer to Lisp-5 or even Lisp-7, forgot which, because it allows that many kinds of "names" without collission.

Also above you said Clojure "probably" has better data structures than Common Lisp. That is unsubstantiated.

Re:Direct Clojure to C Compiler - Based on ClojureScript by yoklov on Monday July 09, 2012 @11:17AM (#4218560)
For what it's worth, Clojure has implementations of Phil Bagwell's HAMT-based hash-maps, vectors, and sets. These are absolutely amazing data structures, and offer functional updates, a list-like API (O(log_32(n)) for most operations, which ends up being less than seven operations in practice, which is similar enough to O(1) for most programmers).

I'm not much of a common lisp programmer (mostly sticking with scheme/racket and Clojure), but I don't think they've been ported to Common Lisp (yet), so the claim that Clojure has better data structures than Common Lisp, while somewhat a matter of preference, isn't entirely unsubstantiated.

Re:Direct Clojure to C Compiler - Based on ClojureScript by mahmud on Monday July 09, 2012 @11:26AM (#4218610)
Common Lisp has hash-tables, vectors, and sets .. had it, in an ANSI-specified document since 1984. The implementation details of these is, well, implementation dependent, be they HAMT or whatever.

The language provides a wealth of tools out of the box, but it's the job of the programmer to choose more appropriate tools for the problems at hand.

The following is the Common Lisp specification. 12+ implementations, half of them industrial strength, more than half commercial vendors, and everyone of them has to adhere to this spec:

http://www.franz.com/support/documentation/8.2/ansicl/ansicl...

Re:Direct Clojure to C Compiler - Based on ClojureScript by swannodette on Monday July 09, 2012 @12:03PM (#4218773)
But does Common Lisp allow multiple implementations of those data structures to exist in the same program actually allowing programmers to utilize the best tool for the job?
Re:Direct Clojure to C Compiler - Based on ClojureScript by mahmud on Monday July 09, 2012 @12:24PM (#4218905)
Are you seriously asking me if a programming language allows for the implementation of data-structures?

If you mean can users extend the core CL data-types, no, but you have a wealth of tools to do that yourself; use generic functions to implement whatever interface you wish, then provide for specific implementations.

Re:Direct Clojure to C Compiler - Based on ClojureScript by swannodette on Monday July 09, 2012 @01:03PM (#4219084)
but you have a wealth of tools to do that yourself

That's the problem. With Clojure you don't have to invent interfaces and then convince other libraries to use them. All the data structures are built upon well considered language level protocols that anyone can implement preventing pointless API proliferation.

Re:Direct Clojure to C Compiler - Based on ClojureScript by mahmud on Monday July 09, 2012 @08:30PM (#4221346)
Clojure has the benefit of hindsight; it is one of the newest programming languages and it is not constrained by a published standard, nor does it need to cater to tens of vendors or any existant code-bases (Nearly every user of Clojure is on github ;-)
Re:Direct Clojure to C Compiler - Based on ClojureScript by honr on Saturday July 14, 2012 @12:10AM (#4243102)
I think wise people prefer programming in good languages that enjoy the benefit of hindsight. Common Lisp does not have the luxury of hindsight, and can hardly change its specification to reflect modern theoretical and practical PL results.

Personally, I slightly prefer Clojure over SBCL.

Re:Direct Clojure to C Compiler - Based on ClojureScript by jules on Monday July 09, 2012 @11:49AM (#4218706)
Note that CL's data structures are mutable, whereas Clojure's are persistent.
Re:Direct Clojure to C Compiler - Based on ClojureScript by swah on Monday July 09, 2012 @03:40PM (#4219999)
Google search saver: immutable = persistent
Re:Direct Clojure to C Compiler - Based on ClojureScript by postfuturist on Monday July 09, 2012 @11:28AM (#4218619)
yoklov, for some reason I can't reply directly. There are a few common lisp libraries of persistent, immutable data structures that perform well. This one is implemented most closely to Clojure's: https://github.com/ks/X.FDATATYPES . This one has been around for a long time and is quite stable: http://common-lisp.net/project/fset/Site/index.html .
Re:Direct Clojure to C Compiler - Based on ClojureScript by pjmlp on Monday July 09, 2012 @12:00PM (#4218755)
> Also above you said Clojure "probably" has better data structures than Common Lisp. That is unsubstantiated.

It is my understanding that Common Lisp lacks the vector and hash maps that Clojure has.

Sorry if I got it wrong. I am more a ML guy than Lisp.

Re:Direct Clojure to C Compiler - Based on ClojureScript by aidenn0 on Monday July 09, 2012 @03:08PM (#4219834)
Re:Direct Clojure to C Compiler - Based on ClojureScript by pjmlp on Monday July 09, 2012 @04:35PM (#4220253)
I was wrong it seems.

From the documentation I have not seen the simplified syntax Clojure uses for vectors, hashes and sets.

I imagine that the syntax is Clojure specific.

Re:Direct Clojure to C Compiler - Based on ClojureScript by mahmud on Monday July 09, 2012 @12:28PM (#4218924)
Your understanding continues to be wrong.
Re:Direct Clojure to C Compiler - Based on ClojureScript by spacemanaki on Monday July 09, 2012 @10:50AM (#4218432)
edited bc mahmud said it better, but

Also, Clojure supports (optional) dynamically scoped variables.

Re:Direct Clojure to C Compiler - Based on ClojureScript by amouat on Monday July 09, 2012 @10:01AM (#4218191)
There are still some nice things such as destructuring and vectors & maps as base types. The syntax of Clojure is generally a bit cleaner and more concise, though I'm sure some lispers will disagree.
Re:Direct Clojure to C Compiler - Based on ClojureScript by FrojoS on Monday July 09, 2012 @10:03AM (#4218197)
Prototype on the JVM but compile to C for production or performance critical tests? Ideally, no refactoring required at all.

I guess it also helps to work with a dialect with more momentum. E.g. its easier to find support, on- and offline.

Since I haven't really used Closure or any other Lisp for more than a tutorial, I might be very wrong, though.

Re:Direct Clojure to C Compiler - Based on ClojureScript by Raphael_Amiard on Monday July 09, 2012 @10:15AM (#4218259)
Clojure -> C will very probably be slower than Clojure -> JVM, at least if the compiler is naive.