Ask HN: Whats the best way to start web development on lisp? Whats the best way to start web development on lisp? |
Ask HN: Whats the best way to start web development on lisp? Whats the best way to start web development on lisp? |
Common Lisp has pretty good support regarding books, libraries and developer mindshare in the Lisp community (which generally is quite fractured, albeit not on a Forth level). They can be pretty harsh at times, though.
Personally, I'd recommend going with some simple examples. Getting to grips with the language, the environment (probably Emacs+Slime) and a somewhat novel web framework at once can be pretty daunting. So taking baby steps on the result level, i.e. making stuff that could've been done with CGIs, won't heap yet another helping of novelties on your plate.
[1]: http://weitz.de/hunchentoot/
For CL, Scheme, Arc, ..., I have no idea.
The hardest parts were learning enlive and moustache. Enlive is incredibly powerful and very clever, but can be a bit overwhelming for clojure noobs. You definitely want to check out David Nolen's tutorial[5] for it. Aside from that, #clojure and the ring google group are full of wisdom.
Deployment wise, I build the site with a basic leiningen[6] uberjar and run it from an ssh, background it and disown it. yeah, thats terrible, but im lazy and nobody visits my site anyhow ;) Caveat here: Clojure 1.2 has a small bug with interned keywords[7] that will knock my site over in a couple of days if i forget to start it up with the default JVM profile. the -server profile fixes the trigger issues
Aside from that, I have an nginx gateway server that handles serving my media, nowww redirection and proxies all dynamic requests through to the jvm. the site itself hosts a jetty HTTP server via ring to handle all the requests.
The 'hardest' part of getting started with clojure vs say Python+Django or Ruby+Rails is that there is a lack of 'get you going' magic / tools like scaffolds or djangos admin. Once you get past that though, it is a very enjoyable platform inspite of the API changes.
[1]: http://brehaut.net
[2]: http://github.com/cgrand/moustache
[3]: http://github.com/cgrand/enlive
[4]: http://github.com/ashafa/clutch
[5]: http://github.com/swannodette/enlive-tutorial/
[6]: http://github.com/technomancy/leiningen
[7]: http://www.assembla.com/spaces/clojure/tickets/444?comment=9...
Ack! GNU screen will change your life.
Another clojure web framework - Conjure - has rails like migrations.
What do you do ?
http://github.com/nex3/arc/blob/master/help/arc.arc is from Anarki, a community-maintained branch of "vanilla" Arc. They wrote such a help function, but there are also other extensions and differences that are reflected in said help.
If you're new to Lisp, http://ycombinator.com/arc/tut.txt isn't a bad start. But there are countless Lisp tutorials out there.
As for online documentation: http://files.arcfn.com/doc/ + http://www.arcfn.com/2009/06/whats-new-in-arc3.html; see also http://arclanguage.org/item?id=12228, wherein I technically have another suggestion for learning Arc without the web ;).
[ Haven't dug in very far yet but Arc tutorial appears to be web development oriented, and you could look at the HN source code ]
I was startled to find that "C lisp"--that is, the lisp interpeter written in C, which you get when doing sudo aptitude install clisp on the latest Ubuntu distribution--is actually not the "standard" lisp interpreter. I still have no idea which is, if any.
Still, it seemed like a few of the web frameworks out there should have worked anyway, so I tried to soldier on for a while. Unfortunately, it was in vain: my dependency-fu simply wasn't strong enough. I also couldn't find a lisp equivalent to rack and wsgi, which is something of a non-starter imho.
I'm sure I am making some foolish assumptions, facilitated by the vast chasm that represents my experience with lisp and its ilk. I also have only managed to devote a few hours to it so far, so please, no one take this post as gospel--I'm just sharing what little I have found in case someone else finds it useful.
I've shied away from Scheme-based servers[3] hosted behind e.g. forward-proxies, because it seems to violate Occam's razor; but that's a personal bias.
[1]: http://wiki.call-cc.org/eggref/4/fastcgi
[2]: http://en.wikipedia.org/wiki/Continuation#Continuations_in_W...
You can use RESTAS framework http://restas.lisper.ru/en/
Example:
http://restas.lisper.ru/en/tutorial/hello-world.html
It's extremely well documented too.
I don't like web frameworks, here's what I currently recommend: http://news.ycombinator.com/item?id=1778708
The RESTAS documentation just got translated from Russian, I'm actually supposed to proofread it this weekend.
Concur 100%; hunchentoot + postmodern. No continuation crap there.
Bliss could come from a combination of the two, however.
But your first sentence says it all - depends on what you're looking for. If you're outside of the cloud (by choice or necessity) Ruby/Rails, Python/Django, or even Groovy/Grails are all tough to beat.
Clisp is one implementation of the Common Lisp language. Other Common Lisp implementations include SBCL and AllegroCL. Since no one party controls the Common Lisp language, none is standard.
Scheme is another Lisp language. It also isn't controlled by anyone, so it's just a sea of implementations. BUT — the closely related Racket language is centrally controlled and does have a standard implementation. In fact, that's pretty much the whole reason Racket diverged from Scheme — so that it could be the standard Racket instead of Scheme with a bunch of modifications.
The other popular Lisp these days is Clojure. Like Racket, it does have a central "creator," Rich Hickey, whose implementation is considered official.
At least there are more blogs about Clojure; and Racket is mature and well supported. (I also think Clojure code looks better than all the other lisps. Don't know why, yet.)
Working with these fragments is real simple. Clutch deserializes the JSON from various couch views into native clojure data structures (maps, vecs, etc). From there i just use multimethods[1] to work out how to handle each fragment at various points (url generation, various aspects of the templating etc). I should note that cgrand created a great little macro for me to make working with enlive and multis easier, http://gist.github.com/432752
The hardest part about migrating the nominal schema is changing the JS for the views. Clutch does support running a clojure view server for couch which i think would actually alleviate a lot of my pain points but I wasn't on the ball when i got started. I store all my views in little JS files in the project and have some shamefully rough clojure scripts to update the views in the DB.
Migrating existing data (which i've only had to do once) is a simple case of writing a map (and or filter) function and running it over all the content and doing a bulk update with couch.
I havent had to do much migration though because i largely ported over my established python/django project.
hopefully that answers your question?
In a traditional DB, one needs to manage addition and deletion of columns, during the development of a project. And one needs to be able to synchronize these database schema changes with the rest of the team. And it is nice to have these as incremental (yes there is the obvious waste of creating a column in one migration and dropping it in the other) Migrations also allow you to do stuff like add indexes etc to your tables and is not just a one-to-one mapping of your objects to the DB.
Which is why migrations (Rails and Django's South) are so extremely helpful during development.
One of the things I that was for something like Linq (Scala has something called squeryl) and you could have your database created from your objects - not optimal, but enough to start with.
FWIW, ease of managing incremental schema is why Drupal (using drush and "Drupal Features" ) is one of the better PHP frameworks.
Another option is to download Franz Allegro CL Express - http://www.franz.com/downloads/clp/survey and Franz' own emacs package - http://www.franz.com/emacs/ They also have nice tutorials up there.
Or Lispworks personal edition - http://www.lispworks.com/downloads/index.html
I just set up slime into my emacs (which I use all the time anyways) and hooked up Clozure CL to it - http://www.clozure.com/clozurecl.html
On the other hand you could try Scheme, particularly Racket (ex PLT Scheme) - http://racket-lang.org/ (IDE is really nice, but sometimes confusing for newbies.. for example "Which Scheme? And why?")
Maybe your best bet would be to start either with Lispbox and some Lisp book (like the one linked on Lispbox page, it's free) - or Racket Scheme and its IDE (DrScheme) and try following SICP from here http://ocw.mit.edu/courses/electrical-engineering-and-comput... and especially here: http://academicearth.org/courses/the-structure-and-interpret... I'd recommend Racket+SICP at first, both because of less hassle with tools instead of language at first and for my personal bias toward Scheme. Just found some pointers for SICP and DrScheme here - http://stackoverflow.com/questions/939582/which-language-in-...
CLISP is not really written in C proper; but files with *.d suffix are C with heavy pre-processor use that make them look like Pascal. It also uses "var" keyword to declare new variables, along with shell-style # line comments. It also uses German for variables and comments. Things have been changing heavily as of late, and there is more push toward C style and English usage, but here is what it look(s|ed) like.
http://clisp.cvs.sourceforge.net/viewvc/clisp/clisp/src/intc...
The code is beautiful and readable, but very unidiomatic.
Your lack of class is why having a reasonable discussion on this site is impossible.