
Clojure: 1, Common Lisp: 0 - mqt
http://briancarper.net/2009/01/19/clojure-1-common-lisp-0/
======
tlrobinson
Being on top of the JVM is also one of the really nice things about Rhino
(Mozilla's JVM based JavaScript interpreter: <http://www.mozilla.org/rhino/>).
You have access to a zillion Java libraries. Taking two of their examples:

MySQL:

    
    
        var conn = java.sql.DriverManager.getConnection("jdbc:mysql://"+host+"/"+db+"?user="+user+"&password="+password),
            statement = conn.createStatement(),
            resultset = statement.executeQuery("SELECT * FROM test");
            // do stuff!
    
    

Jetty also works from Rhino:

    
    
        var server = new Packages.org.mortbay.jetty.Server(8080);
    
        server.setHandler(new Packages.org.mortbay.jetty.handler.AbstractHandler({
            handle: function(target, request, response, dispatch){
                // do stuff!
                request.setHandled(true);
            }
        }));
        server.start();
    

Obviously these could be wrapped up in more JavaScripty libraries, but all the
hard work is done for you.

~~~
Avshalom
for more javascripty DB/server stuff <http://dev.helma.org/> is (though
relatively unknown) the premier (kinda) server side javascript
library/framework,

~~~
tlrobinson
There's a lot of monolithic server side JavaScript packages like Helma, but I
want something more modular. Also, Helma is written in mostly Java I believe,
rather than JavaScript, which is ok if you don't want to hack on Helma itself
(or if you know and like Java), but I'd rather have an all (or at least
mostly) JavaScript solution.

Anyway, I started working on part of a solution for this: Jack
(<http://github.com/tlrobinson/jack>), which is like Rack
(<http://rack.rubyforge.org>) but for JavaScript.

If you don't know, Rack/Jack are like bridges between webservers and
Ruby/JavaScript web apps/frameworks, so framework/app devs don't need to worry
about what server they're using, they just write to the Rack API. It also
includes "middleware" which lets you pre and post process requests, which
allows for neat things like intercepting some requests and serving static
files, or gzipping responses, etc (in a server agnostic way)

Right now it only works with Rhino+Jetty but ideally it will work with a
number of JavaScript interpreters and webservers.

It also includes a Sinatra-like routing framework (called Roundabout), which
lets you define routes like

    
    
        GET("/user/{username}", function() {
            var user = this.wildcards["username"];
            // do stuff!
            return resulting_html;
        }
    

Jack and Roundabout, combined with your other frameworks of choice, like
ActiveRecord.js (<http://activerecordjs.org/>) make a pretty good solution, I
think.

------
mcxx
This guy is just rambling about CL and writing about his inability. I never
had problems with SBCL on any machine, runs on my VPS, with threading, like a
charm. Also, noone forced him to learn and use Emacs. There are Vim modes or
CUPS for Eclipse. Destructive functions are the language's feature. If not
sure, just use non-destructive. It's also not CL's fault he doesn't understand
macros and can't use CL-WHO.

I like Clojure, but I like CL better. One guy's incompetence learning CL
doesn't mean Clojure wins.

~~~
jimbokun
"I never had problems with SBCL on any machine"

I did, and so did this author.

So who's anecdote wins?

~~~
habibur
Reddit was initially built on CMUCL on FreeBSD. Here is what Steve Huffman
said on why they switched to python one weekend.

 _"The biggest trouble that plagued us was that we could never quite get Lisp
reddit stable enough to sleep at night. There were weird threading issues that
would bring the site to its knees a couple times a day and required constant
monitoring."_

You can read more of it in this blog entry.

[http://www.findinglisp.com/blog/2005/12/reddit-and-lisp-
psyc...](http://www.findinglisp.com/blog/2005/12/reddit-and-lisp-
psychosis.html)

Edit: Corrected :-)

~~~
jesnell
Reddit wasn't built on SBCL, which you would know if you had read the blog
entry you linked to.

~~~
critic
I used CMUCL a bit, and SBCL almost never. Does SBCL really deliver on what it
set out to do? Is it better, faster, more portable? As far as I know, the
Windows port never matured. Which of the two do people recommend using?

~~~
jesnell
SBCL set out to make a version of CMUCL that was easier to build and maintain.
I'm pretty sure that was delivered.

But of course that's not of much interest to the average user. I think SBCL is
in general faster, is developed more actively, has more features that are
relevant in the modern world (eg. lose a Motif interface, gain native
threads), and currently runs on more platforms than CMUCL does.

My impression is that most people using CMUCL are ones who started using it 10
years ago and are comfortable with it, new users would tend to go with SBCL.
But I'm biased, so it's quite possible that there are real and substantial
reasons to prefer CMUCL.

------
jwilliams
This might be a good experiment, but the examples seem a bit flimsy to me.

For example - Whilst it may well be better from his experience, Timestamp has
always been an anomaly in Java (it doesn't necessarily play nicely with
Date)....

Equally I've never found browsing the filesystem that superb in Java - in fact
the whole FileFilter, FilenameFilter thing can be quite clunky to use... It's
one area where I've never felt more than a smidgen away from C (even moreso
now with the NIO library).

So - maybe better, certainly not perfect - Either way they didn't on the
weight of it seem killer arguments.

------
vikram
I'm going to make a different kind of statement here. Something that I've
learnt from my CL experience.

When I think about solving a problem by writing new software, I ask myself, is
a run of a mill problem like a website which serves data, or making use of a
bunch of libraries to do something. Then use rails/django, I use
django/python.

If I don't know what the solution will look like and I don't think I'm going
to need existing libraries. I'll use CL everytime.

Horses for courses. Nails and hammmers.

------
jncraton
His shiny new Clojure powered site is down for me...

"The server is temporarily unable to service your request due to maintenance
downtime or capacity problems. Please try again later."

<http://origamigallery.net/>

~~~
weavejester
Curiously, the server appears to be Apache rather than Jetty.

~~~
twism
It is common to have Apache as your static web server to serve images/css/js
files and use modules such as mod_rewrite or mod_jk to route to your dynamic
context. It seems like his dynamic content server is down (could be the jetty
server he was referring to), hence the 503 error code.

------
dimitar
Would the same Clojure advantages apply to Armed Bear CL which also runs on
the JVM?

~~~
jefffoster
Not in my opinion.

Using Java libraries from Clojure is very simple e.g. (.substring "abcd" 2 3)
==> "c".

Armed Bear on the other hand requires a lot more scaffolding code to make a
Java call (you have to get the class, find the method and then call it).

------
habibur
In Lisp one has the freedom to code in Structured Programming, OOP, AOP, FP,
meta programming, or create his own DSL.

Does the same stand true for Clojure?

I am thinking about switching. Only risk is that if it doesn't work, I can't
port the code anywhere else, because it's so different from CL.

~~~
weavejester
Clojure is a Lisp, so you get all the usual things like first class functions
and macros. Clojure leans toward FP philosophically, so all the built in data
structures are immutable. Concurrency support is generally very good, and it
has some useful syntax sugar for vectors and maps.

I prefer Clojure over all the other Lisps I've tried, but YMMV.

~~~
habibur
Good. Only thing missing in Clojure seems OOP. But I can live without that.

Hope Clojure doesn't push the FP thing too far. Pure functional languages are
evil. In broad sense, pure anything in evil. Look what Java turned into trying
to be a pure (or too much of an) object oriented language.

It’s multi paradigm that wins. Giving programmers freedom on how he wants to
code any specific set of problem.

~~~
ericlavigne
Clojure supports OOP in the same style as Common Lisp.

<http://clojure.org/multimethods>

The integration with Java is almost seamless, so of course you can also use
Java-style OOP if you're feeling masochistic :-P

Clojure is definitely not pushing FP too hard. It was designed to be
especially supportive of FP, but it is definitely a multi-paradigm language.

~~~
11ren
Another Java-style construct: Clojure has a _do_ form, which enables you to
consecutively execute the following expressions in the list.

It seems to me a way to sneak statements into the language. Or does lisp have
something like that as well?

~~~
radu_floricica
It's pretty realist, it even has a doseq especially for side-effects
iterations. It's not that it forces you to be FP (it can't, you can always run
java methods), it's that it makes the advantages obvious and lets you decide.

It is my first contact with FP, but what I find incredibly cool is the way the
data structures are transparently persistent. If it's true this is a rarity in
functional languages, I can't imagine using another one.

~~~
11ren
I'm curious, what do you mean by "transparently persistent"? Do you mean that
you can serialize anything (and so persist it as a file or what have you)?

~~~
sctb
Persistent in this case means that if FOO has value '((2 3) 4) and someone
does (CONS 1 FOO) => '(1 (2 3) 4); the value of FOO does not change, but the
new list shares its structure.

~~~
reeses
If you do a cons cell diagram for this it will make perfect sense.

------
sunkencity
In a trivial setup it's pretty easy to get the jvm up and running, but making
a good cached deploy of apache httpd fronting tomcat and a database server
isn't very easy. It's not very easy to set up a server with rails either
(easier these days but still a pain if you're a noob). I'm not sure how easy
something deploys is critical for the value of a platform. Developers should
understand how stuff are deployed but it's not necessary that they know how to
do it correctly, nor should every developer deploy their own applications. (I
mean, it doesn't hurt if they know how to do it, but it's better that
developers spend their main time developing not minding the server farms).

------
rw
Someone please compare Clojure to PLT Scheme.

~~~
hapless
PLT scheme is primarily used for education. Pedagogy is (or at least was) the
project's central goal.

Clojure is a general purpose project. It is not specifically competing for
that space.

I'm sure that the average student can get up and running with DrScheme/PLT
faster than with Clojure, but I doubt anyone is going to write an angry
article about that.

~~~
apgwoz
See, that's the common misconception with PLT. While it was built for
education, it's really a nice full featured system for any use. Just use
something other than the "Beginning Student" language.

~~~
WeYu
I have to agree. I know CL quite well, and decided to have a look at scheme
last week. I wrote a small (but useful) program with PLT and was rather
impressed by the amount of library code available. Distributing the program as
a small stand-alone executable to a friend was also incredibly simple. Also, I
particularly liked the module system and wish CL had something similar.

------
critic
In one of the video lectures the author of Clojure seemed to claim that
Clojure is as fast as Java. IME though that's not quite the case.

~~~
Zak
Clojure can be as fast as Java on benchmark-type code using type hints, Java
interop and unchecked math. Idiomatic Clojure code will be slower on
benchmarks. Operations on persistent data structures are slower than mutation.
Reflection takes time.

Back in the real world, Clojure actually does pretty well for itself. As an
example, it seems to be fairly common to generate collections of various types
and then only use part of them. In Clojure, most of the time those collections
would be lazy, saving computations every time the whole thing isn't needed.
Also, using clojure.parallel, many operations can be parallelized trivially. I
got a 50% speedup running a genetic algorithm on a dual-core machine just by
changing a sort to psort.

Of course, hand-optimized Java may still be faster, but Clojure makes it
easier.

------
newt0311
From: <http://news.ycombinator.com/item?id=395951>

"Yes it [Common Lisp] does [look bloated]. It has at least 4 different ways to
loop, 4 different types of arguments to functions, 5 or 6 different lets
(functions, macros, let* , normal let, ...), 3 or 4 different kinds of
variables (with no unifying underlying theme), and at least 3 different flow
models (the nested lists, tagbodies, loops with returns, etc...). That is
exactly the same problem with C++. Instead of finding unifying abstractions
which give the same functionality with 1 idea, they have chosen to add in
multiple specific quick fixes to the language. They have chosen to amend the
language with a thousand small changes, each suited to its own little use
case, and have ended up with a monster of a standard that takes up 15
megabytes in 2300 files with 110,000 hyperlinks. Thats 15 mega bytes mostly of
text.

Scheme is a lot better but its going the way of CL, slowly but surely."

Thats exactly what we are seeing here.

