4 ms·
To me, right now, I think the core difference between Clojure and other Lisps is Clojure gets rid of memory management. Yes, other Lisps have automatic dealloca
by brudgers 13y ago
To me, right now, I think the core difference between Clojure and other Lisps is Clojure gets rid of memory management. Yes, other Lisps have automatic deallocation, but the fundamental constructor, `cons`, is a raw memory allocation. It`s `malloc`for linked rather than sequential memory.
Although Clojure still has a `cons` it has been replaced by `seq` as the fundamental abstraction. Clojure takes advantage of being fully managed code and in a sense is as much a Lisp as C# is a C [if we were inclined to think of C as a genre, else Algol?].
It seems this, combined with a formally incorporating a DSL of the kind a experienced Lisper (such as Hickey) might create for writing programs gives Clojure it's syntax: e.g. [x y] is syntactically like a quoted list and writing a macro is the sort of thing hubris drives lazy impatient Lispers to do. In special forms [x y] is like a different more complex macro, but again the sort of thing people would write for themselves. In other Lisps the ad hoc nature of such macros however makes other people's code notoriously hard to follow.
- eudox 13y ago>`cons`, is a raw memory allocation. It`s `malloc`for linked rather than sequential memory. >Clojure takes advantage of being fully managed code >writing a macro is the sort of thing hubris drives lazy impatient Lispers to do The ignorance of Clojure programmers is really incredible.
- brudgers 13y agoIt's a literary allusion. http://c2.com/cgi/wiki?LazinessImpatienceHubris http://c2.com/cgi/wiki?LazinessImpatienceHubris
- ScottBurson 13y agoOkay, that covers eudox's third point, but the first two are still valid. Your claim that Clojure does something fundamentally different from Lisp when it comes to memory allocation is misinformed and, frankly, bizarre. And I have no idea what your point about managed code is -- Lisp code runs in a Lisp environment the same way that JVM or CLR code does.
- lispm 13y agoClojure constructs don't allocate memory - okay... > Although Clojure still has a `cons` it has been replaced by `seq` as the fundamental abstraction. Common Lisp has lists and sequences as abstractions. But it does not take away the low-level operations.
- brudgers 13y agoSorry for not writing more clearly. Because Clojure does not need to allocate memory, it can use `seq` as its fundamental constructor. A `seq` is anything that implements `first` and `next`, it's a higher level abstraction than `cons` because it frees up `()` and `nil` from `car` and `cdr` [or `first` and `rest`]. At a higher level the abstraction facilitates differentiating a breadth first search tree from a depth first search tree as types of data structures (though I'm not necessarily advocating the idea). Sure it could be done in a traditional Lisp but the best case sausage factory is probably less sanitary. I'm not making a case that Clojure is better than other Lisps - getting rid of `cons` and relying on the JVM has makes typing more critical in an environment that retains a degree of type opacity typical of dynamic type systems.
- lispm 13y ago> A `seq` is anything that implements `first` and `next`, it's a higher level abstraction than `cons` because it frees up `()` and `nil` from `car` and `cdr` [or `first` and `rest`]. See SERIES in Common Lisp. http://series.sourceforge.net http://series.sourceforge.net > At a higher level the abstraction facilitates differentiating a breadth first search tree from a depth first search tree as types of data structures Typically used as CLOS libraries in Common Lisp. > getting rid of `cons` That's caused because Clojure is implemented in something else and doesn't go very deep. Common Lisp goes deeper because it is it's own implementation language. Much of the implementations are written in Common Lisp itself (compiler, parts of the runtime, ...). On something like the MIT Lisp Machine even the garbage collector was written in Lisp. Lisp is reflective building material + machineries + some pre-build stuff. Clojure is more like pre-built stuff on top of some other infrastructure.
- 13y ago
- wes-exp 13y ago`cons`, is a raw memory allocation. It`s `malloc`for linked rather than sequential memory Yeah, cons is like malloc, except that the object it creates is automatically memory managed / garbage collected. There is no corresponding "free" call. Actually, that means cons is not like malloc. Clojure takes advantage of being fully managed code Do you realize that Lisp uses automatic memory management (just like the JVM or CLR)?
- brudgers 13y agoLisp's are high level languages. The JVM and CLR are virtual machines that interpret and compile bytecode. Some Lisps utilize virtual machines, Clojure being an example of one which does not use it's own, CMULisp and Racket are examples of Lisps which use their own VM, and ClozureCL and SBCL are Lisps which compile directly to native code. How Chicken Scheme fits into the whole virtual machine model...well it's just too fine an ontological line for me to call. Why are there no Fortran machines or Algol Machines or C machines? The `cons` cell is a raw memory structure, just one step removed from assembly and originally accessed directly in machine code with `car` and `cdr`. It's associated symbol is literally a pointer directly to a memory location. It's so close to assembly language that thirty years ago implementing it directly in hardware was considered practical.
- wes-exp 13y agoThe `cons` cell is a raw memory structure It's associated symbol is literally a pointer directly to a memory location A cons is not "raw memory"; it is a typed data structure, and in Common Lisp it is even considered an OOP object of the cons class. It is equivalent to having a data structure called "pair" that can hold two things. All memory-allocated data structures ultimately have an address of some kind, so this whole discussion about pointers is utterly meaningless. For that matter, arrays, strings, and basically every known memory data structure is "raw" too. After all, they have an address. The fact that cons/car/cdr can be implemented cheaply in hardware stems from the fixed and small size of cons. That doesn't make it somehow inferior. By the way, the Java stuff is implemented in hardware too, does that make Java inferior? http://en.wikipedia.org/wiki/Java_processor http://en.wikipedia.org/wiki/Java_processor