5 ms·
Ask HN: Whats the best way to start web development on lisp?
Whats the best way to start web development on lisp?
- die_sekte 16y agoWell, Clojure has Compojure & Ring (like Sinatra & Rack on Ruby). Pretty well made, but without batteries, and the documentation sucks massively (I've resorted to reading the source). Also, pretty much everything is still in beta and APIs change frequently. For CL, Scheme, Arc, ..., I have no idea.
- brehaut 16y agoI recently rebuilt my site[1] in Clojure. Ring at the bottom layer (basically a given). Beyond that I'm using Moustache[2] for routing, Enlive[3] for templating and Clutch[3] to talk to CouchDB. I had previously tried with Compojure and Hiccup. 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 http://brehaut.net [2]: http://github.com/cgrand/moustache http://github.com/cgrand/moustache [3]: http://github.com/cgrand/enlive http://github.com/cgrand/enlive [4]: http://github.com/ashafa/clutch http://github.com/ashafa/clutch [5]: http://github.com/swannodette/enlive-tutorial/ http://github.com/swannodette/enlive-tutorial/ [6]: http://github.com/technomancy/leiningen http://github.com/technomancy/leiningen [7]: http://www.assembla.com/spaces/clojure/tickets/444?comment=9542151#comment:9542151 http://www.assembla.com/spaces/clojure/tickets/444?comment=9...
- ynniv 16y agorun it from an ssh, background it and disown it Ack! GNU screen will change your life. [ http://www.emacswiki.org/emacs/GnuScreen http://www.emacswiki.org/emacs/GnuScreen ]
- nakkiel 16y agoYou mean SAVE his life.
- sandGorgon 16y agohow do you handle schema changes ? Another clojure web framework - Conjure - has rails like migrations. What do you do ?
- brehaut 16y agoFirst up, i'm using CouchDB, so my data is pretty fluid. Everything is organized as a set of 'fragments' which have a variety shapes; its duck-typed data basically. I havent looked at clojure's SQL stuff at all so i cant answer there. 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 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? [1]: http://clojure.org/multimethods http://clojure.org/multimethods
- mcantor 16y agoVery interested to see what the experts have to say about this. I gave it a shot a few weeks ago, but I could barely get to hello world. As a Ruby/Python programmer, I seem to be spoiled by having de facto interpreters (MRI and CPython, respectively) with rich standard libraries, all of which are doused with a great quantity of Google juice. 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.
- duncan_bayne 16y agoI can't help but get the feeling I'm being trolled here, but: the C in CLISP actually stands for Common, not the C language.
- enduser 16y agoSee the Racket docs for getting a simple web app set up: http://docs.racket-lang.org/more/ http://docs.racket-lang.org/more/
- JoelMcCracken 16y agoI think this depends a lot on what you're looking for. I love lisp, but I wouldn't bet a startup on it. Ruby/Rails is simply too complete to use something else. Bliss could come from a combination of the two, however.
- projectileboy 16y agoI disagree; Clojure on Google App Engine is a pretty solid platform for web development,and by now there's a lot of online help to get you started. 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.
- JoelMcCracken 16y agoYeah, its just the whole "there are lots of gems" argument, and ruby is a pretty nice language anyway.
- metamemetics 16y agoI visited pg's arcforum today http://arclanguage.org/item?id=12563 http://arclanguage.org/item?id=12563 and got this info by "fallintothis": http://github.com/nex3/arc/blob/master/help/arc.arc 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 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://files.arcfn.com/doc/ + http://www.arcfn.com/2009/06/whats-new-in-arc3.html http://www.arcfn.com/2009/06/whats-new-in-arc3.html; see also http://arclanguage.org/item?id=12228 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 ]
- ananthrk 16y agoCheck out http://postabon.posterous.com/a-simple-lisp-webapp-for-beginners http://postabon.posterous.com/a-simple-lisp-webapp-for-begin...
- mhd 16y agoFor Common Lisp, the web server of choice would probably be Hunchentoot[1]. If you're using it directly, that would be similar to some of the more lightweight frameworks from other languages (Sinatra, Flask etc.). If you're looking for a bigger framework, Weblocks[2] could be of interest. Haven't worked with it myself, though. It does use Parenscript[3], which is a pretty neat way of writing JavaScript without dropping down to C syntax. 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/ http://weitz.de/hunchentoot/ [2]: http://common-lisp.net/project/cl-weblocks/ http://common-lisp.net/project/cl-weblocks/ [3]: http://common-lisp.net/project/parenscript/ http://common-lisp.net/project/parenscript/
- klutometis 16y agoFor Scheme, I find that fcgi[1] does the trick: not only is it supported by Apache, lighttpd, etc., but you get state-preservation between requests; which is touted, for instance, as one of the benefits of continuation-based servers[2]. 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 http://wiki.call-cc.org/eggref/4/fastcgi [2]: http://en.wikipedia.org/wiki/Continuation#Continuations_in_Web_development http://en.wikipedia.org/wiki/Continuation#Continuations_in_W... [3]: http://wiki.call-cc.org/eggref/4/spiffy http://wiki.call-cc.org/eggref/4/spiffy
- mahmud 16y agoFor Common Lisp, Hunchentoot is pretty sweet. You can use RESTAS framework http://restas.lisper.ru/en/ http://restas.lisper.ru/en/ Example: http://restas.lisper.ru/en/tutorial/hello-world.html http://restas.lisper.ru/en/tutorial/hello-world.html It's extremely well documented too.
- sedachv 16y agoRESTAS is actually one of the CL frameworks that I can sort of recommend because it doesn't try to do too much, and it doesn't have any continuation brain damage in it. I don't like web frameworks, here's what I currently recommend: http://news.ycombinator.com/item?id=1778708 http://news.ycombinator.com/item?id=1778708 The RESTAS documentation just got translated from Russian, I'm actually supposed to proofread it this weekend.
- mahmud 16y agoThat's weird, I could have sworn I wrote that ;-) Concur 100%; hunchentoot + postmodern. No continuation crap there.
- mark_l_watson 16y agoIf I am using SBCL, then Hunchentoot. If I am using Franz, then I would use Portable AllegroServe and WebActions, both of which are installed and ready to use.