Clojure: 1, Common Lisp: 0
briancarper.net
briancarper.net
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.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.I like Clojure, but I like CL better. One guy's incompetence learning CL doesn't mean Clojure wins.
CL is the perfect language for those who consider that development is not a social activity, and luckily for you, there are a couple of niches where this remains a sustainable delusion. For now. Meanwhile, Clojure carries on the Lisp heritage in the branch of software development that's not going to get extinct soon.
Create a simple working installer for the major OS's that includes a useful IDE, Database connectivity to least one major database and a fully functional web server. Once this is working get some people to write a standard library for date / time functions, file IO, formatting output etc.
Never underestimate how difficult it is for a new user to setup a working environment.
http://www.newartisans.com/blog/ready-lisp.html
It's Aquamacs combined with SBCL, some documentation, and some should-be-standard CL libraries. Double click and it immediately takes you into a REPL. Aquamacs recognizes most of the usual Mac key bindings, making the Emacs curve not quite so steep.
I've tried SBCL with the Eclipse plugin and it's been a huge PITA. IIRC, I couldn't get libraries to install when I finally gave up. It may have improved since, but I'm not sure. Of course the fact that many cool-sounding CL libraries had defunct websites and inaccessible CVS repos didn't exactly encourage me...
I'm just learning and my conclusion (by elimination :-)) is that for Windows the best is to use Emacs + SLIME + SBCL. There is an installation guide here: http://robert.zubek.net/blog/2008/04/09/sbcl-emacs-windows-v...
In the comments there are instructions to get ASDF working, that I haven't tried yet.
I've tried to avoid Emacs, but it seems impossible. Lisp in a Box has a lot of problems, ABLE has still too many bugs and Corman lacks GUI programming without which I can't justify the price. CUSP also has too many bugs. So I'm surrendering and looking at Emacs.
For the web server part, just use good old CGIs.
I started by writing a domain-specific crawler which extracted certain information from a bunch of sites. But the sites I was crawling changed their design mid way. So I then ended up writing a program in CL, to which I describe the data that the site has. E.g. Name-of-city is "Edinburgh", Address is '15 Market Place, ED12', First-Movie-name is 'Bend it like Beckham', First-showing-date is '15 Jan', First-showing-time is '14:20'. The program then produces a function which when give a page from this website extracts this information in the form of an alist so that it can be pushed into the database.
Funnily enough the my site which shows this data runs on django.
I did, and so did this author.
So who's anecdote wins?
"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...
Edit: Corrected :-)
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.
I was subscribed to SBCL list some months ago. I could see that Windows port was quickly progressing. "Never matured" suggest a project that was tried and later abandoned. It seems more of an ongoing effort. Versions are still being created regularly. I would try in a few months.
It's not necessarily a fault of SBCL, as much as it is a function of Java's popularity. But to say they equally share deployment problems seems a bit misguided to me.
However, it seems I've been living in a cave. Besides the Reddit case, I haven't heard (or at least can't remember) about problems running a CL environment. Can people who had this problem please reply - what disto, what implementation, what was the issue?
http://groups.google.com/group/comp.lang.lisp/msg/0450136edf...
The use case was a final class project, where the instructor needed to be able to run the final version of the program just by executing a script in an unpacked tar file. Couldn't get SBCL to run with the limited time I spent on it. Got CMUCL to run, but not in a way that could be deployed in a self installing manner. Punted and used Java (was easier to work with team members that way, too).
Clojure would have been perfect.
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.
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.
"The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later."
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).
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.
I prefer Clojure over all the other Lisps I've tried, but YMMV.
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.
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.
It seems to me a way to sneak statements into the language. Or does lisp have something like that as well?
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.
Let's say you have a map, and you change a value in it. Being a functional programming language, and the map being an immutable structure, you end up with two maps: the old and the new. Now, the cool part is every data-structure in clojure is designed _not_ to do this by copying the whole thing. You'll have two maps who share everything except the changed value. Same with collections, sets, trees etc. The work under the hood must be impressive...
Another nice thing (for me at least, coming from imperative programming) is there is a better difference between a variable and a value. A variable is a placeholder, and a value is ... well, a value. In clojure you treat them separately. A better explanation: http://clojure.org/state
I'm just surprised that (it seems) you can do statement-based code in lisp. I thought it all had to be expressions. This feels like cheating. BTW: I can see that progn/do syntactically produce expressions, but the value of all but the last one are thrown away - similar to python in that respect. This seems against the spirit of expressions.
This is a common misconception. You are thinking of pure functional programming, not Lisp. Certainly a lot of Lisp programmers, myself included, prefer functional programming. Scheme, especially, leans toward functional programming. Haskell, not Lisp, is rightly known for embracing functional to the exclusion of all other paradigms.
What really stands out about Lisp is support for ALL paradigms, even those that haven't yet been invented. Lisp is an extensible language, that can be changed to fit your needs. Features that would require language extensions in other programming languages can be implemented as ordinary libraries in Lisp. Lisp was the language that allowed experimentation with new paradigms like functional programming, object-oriented programming, and logic programming long before more specialized languages (Haskell, Smalltalk, Prolog) were created to provide specific support for these paradigms.
Of course you can do statement-based code, like in any language that supports I/O(Haskell included).
That's a hard fact and it isn't what functional programming is about.
Package p = java.lang;
Class x = p.String;
x y = "Hello";
Method z = y.substring;
w = z(0, 5);Of course, primitives are not objects, but autoboxing helps.
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.
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.
"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.