
Cloture: Clojure in Common Lisp - ruricolist
https://github.com/ruricolist/cloture
======
slyrus
I have long desired being able to run clojure code directly in my Common Lisp
environment. Interop between clojure code and CL code would be much more
interesting to me than the clojure/java interop. Yes, there's ABCL which does
the CL/Java interop (and of course vanilla clojure has that built in), but I'm
a big fan of the idea.

And ruricolist has written (and maintained/forked) some nice libraries. In
particular his FXML is the modern successor to cxml and plays nice with xpath,
etc...

~~~
pankajdoharey
Actually the first version of clojure was written in Common lisp and it could
simultaneously output to JVM as well as CLR.

~~~
saityi
TIL. Pretty neat to check out:

[https://github.com/clojure/clojure/blob/89fc0caa43811c7dfcb4...](https://github.com/clojure/clojure/blob/89fc0caa43811c7dfcb47a29aa59e78d295e6a1c/src/lisp/clojure.lisp)

------
stereolambda
Maybe this could lead, in a roundabout way, to saner ways of dealing with hash
tables and non-list sequences in general in Common Lisp. Currently these need
clunky, verbose code for many use cases. Writing your own functions/macros is
of course possible, but it feels disorganized without ensuring an overarching
system of conventions. AFAIK a uniform way of handling sequences was one of
the early selling points of Clojure, according to Rich Hickey himself.
Sequences which are immutable, which I don't care much for (as I cherish the
out-of-your-way CL philosophy), but it's a compromise.

Alternatively I could spend some time assessing rutils or some other
fundamental extension library... I'd like, one day, for one of those to gain a
good tutorial and a bigger mindshare in the community.

~~~
ScottBurson
Have you looked at FSet?
[https://github.com/slburson/fset](https://github.com/slburson/fset)

~~~
stereolambda
Looks promising, thanks for the tip!

------
classified
I propose naming it "Clôture", for clarity.

------
Scarbutt
I can understand escaping from Java enterprise hell to Clojure but devs using
a CL runtime will just write CL?

~~~
zelcon
ABCL exists and is easier to use java libs from than Clojure

~~~
lvh
It does not seem easier to me to use Java libs from ABCL than Clojure.

Some Java:

    
    
      public class Main {
        public int addTwoNumbers(int a, int b) {
          return a + b;
        }
      }
    

Calling it from ABCL:

    
    
      (defun void-function (param)
        (let* ((class (jclass "Main"))
               (intclass (jclass "int"))
               (method (jmethod class "addTwoNumbers" intclass intclass))
               (result (jcall method param 2 4)))
          (format "calling addTwoNumbers(2, 4): ~a~%" result)))
    

Calling it from Clojure:

    
    
      (defn f []
        (prn "calling addTwoNumbers(2, 4): " (.addTwoNumbers (Main.) 2 4)))
    

Note that the Clojure version creates the object, and the ABCL version doesn't
do that for you; you still need to instantiate a Main yourself.

~~~
fmakunbound
Something like:

    
    
        (require :jss)
    
        (defun f() 
          (format t "calling addTwoNumbers(2, 4): ~A" (#"addTwoNumbers" 'Main 2 4))

~~~
lvh
Thanks! I didn't know about :jss and will happily concede that's equivalent to
the Clojure version.

------
lbj
> "Beside the obvious: cloture is a parliamentary procedure to end debate on a
> subject, and I would like to end certain debates. Yes, Common Lisp is
> “modern.” Yes, Clojure is a Lisp."

Im interested to see how well this will fare. Personally, Im a little
depressed that Clojure-in-Clojure has been postponed for nearly a decade. It
would have made changing compiler targets much easier.

------
e12e
> Clojure namespaces are just packages. But of course Clojure is case
> sensitive, so you will need to use pipe characters to call, for example,
> |clojure.core|:|cons|.

Is this an implementation detail or a common lisp idiom to work with case
(in)sensitivity?

~~~
globular-toast
The statement you quoted is a bit misleading. Common Lisp is case sensitive
just like Clojure, but unlike Clojure all of the standard library is spelt
with upper case and the reader automatically concerts symbol names to upper
case, unless you quote them, like in the given example.

~~~
mikelevins
You can also use the standard accessor readtable-case to tell your Lisp
whether you want it to convert case or not.

------
globular-toast
Can't wait to have a go with this. Common Lisp is a joy to work with but I
would actually prefer to use Clojure because I like functional programming.
But while I tried to get into Clojure I just hate having to run the JVM and
having Java interop is worthless to me. So being able to use the Clojure
functionality in a more familiar environment might be perfect.

------
cellularmitosis
Don't some Common Lisp implementations support heap snapshots? Might improve
Clojure startup time.

~~~
lvh
They do, and, thanks to GraalVM’s Substrate compiler, the same technique is
also available for Clojure directly on the JVM. I imagine you’re going to pay
some cost in both cases, perhaps in different places. (I imagine with Cloture
it might be at development time, but once your program works the compiler
won’t break it—-with Graal you don’t notice a thing during development but the
compiler breaks plenty of programs.)

~~~
lispm
These are different things.

[https://github.com/oracle/graal/blob/master/substratevm/LIMI...](https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md)

Where SBCL just adds some compiled code, writes a memory dump out in a second.
Then this can be run as a new SBCL with added code - it still includes the
compiler, and all other stuff. One can also then add more code and write
another image... The new image is just like the other one, just with more code
and otherwise the usual feature set.

This includes the whole SBCL and my code, not just a static application with
limited dynamic features.

Many Common Lisp systems have a way to write a snapshot of the developed
environment, which then starts in subsecond.

Additionally some Common Lisps have ways to do application or shared library
delivery, which can remove dynamic features, remove parts of the development
tools, remove unused code/data, etc. This may be similar like doing heap
dumps, but with added optimization phases.

------
voldacar
Cloture and Clojure, not to be confused with Clozure

~~~
hellofunk
Or Google Closure compiler.

~~~
vvern
Which is a key enabling technology of Clojurescript (cljs).

------
ScottBurson
Glad you've found FSet useful! I'm curious what the difference is in map
equality semantics.

