Paul Graham: Lisp in Web-Based Applications (2001)
lib.store.yahoo.net
lib.store.yahoo.net
On many projects this isn't as much of a problem, but I think it's dangerous to assume that one can easily use 'any language' when developing web-based software.
Use (something like) Clojure (or a dot net equivalent)and you can have the best of both - a lisp and lots of libraries. The (minor) price is some grunginess at the interface of the lisp and the libraries, but this is paid only once.
I'm not saying you should write everything yourself, just the bits that matter :)
But I agree. It's a matter of deciding when it matters, and when it doesn't.
In these cases it's to your advantage to use the mainstream tools because there are so many resources available to you.
I thought GPL libs could be used n a web based project? PG's article says (emphasis mine)
"One of the reasons to use Lisp in writing Web-based applications .. "
(Also, what is with all the anti-GPL FUD on this site? Have any of you guys read the license, or do you just like to bash it because you don't like Free Software?)
"When you're writing software that is only going to run on your own servers, you can use whatever language you want."
If you're not distributing software then the GPL doesn't apply. A web-based start up can use as many GPL-based libraries as they want.
Libraries tend to be generic, so you can often do better for your specific problem if you are willing to pay the opportunity cost.
Sometimes it is quicker to write the exact thing you need rather than struggling with something that wants you to think it is the solution to your problem.
Another case in point was the Aha! moment someone described when realized that the Lisp Postgress interface was not going against the library but against the wire protocol itself. Just as easy.
See, for example, my comment in this thread: http://news.ycombinator.com/item?id=595513
PS: Which is something to think about, if you are spending as much money on HW as Google it might be a good idea to use C or other fast but hard to write language for some of your core functions.
I think this argument in some ways hinges on how far from the tree you're falling. If you're doing essentially a variation on a common theme, you'll be the fastest by picking a language where the bulk of the work is already done for you in a variety of reusable modules. It'd have to be a really poor language for its badness to outweigh having most of the work done for you up front.
If, however, you're starting from scratch on something relatively novel, e.g. where Viaweb was in 1996 (and not so much in 2001), then it's true, you should write in the language that fits the bill rather than following the course of momentum.
One proviso I would add there though is that Lisp is in the position of being fairly mature and non-traditional, unlike many flavor-of-the-weeks. There are many pains to be found in using tools which haven't stabilized yet, even if they do have a gee-whiz-bang factor.
As to your postscript, Google does also extensively use C++; I think that's still fairly common in high-performance stuff at the lower levels.
Macros for generating HTML: http://arcfn.com/doc/html.html
Closures Simulate Subroutines: http://arcfn.com/doc/srv.html
(define (whitepage . content)
`(html (body ,@content)))
(define (para)
`(p))
(define (link prose url)
`(a ((href ,url)) ,prose))
(define (prbold text)
`(strong ,text))
So the example from the Arc link (whitepage "Hello world!" (para) (link "Click here" "http://news.ycombinator.com")
"for" (prbold "more stuff"))
yields (html
(body
"Hello world!"
(p)
(a ((href "http://news.ycombinator.com")) "Click here")
"for"
(strong "more stuff")))
which is a valid expression that PLT's web server will render as a web page.Okay...I'll leave my "Are we getting anything" question there, but it probably shouldn't be answered. Or at least not here. It's essentially the pure-functional versus side-effect debate. To be fair, you get benefits from both, and both have downsides that the others are better at.
When looking at PG's approach in ACL, it's worth remembering that he came up with it more than 10 years ago, and consider it in that context. The surrounding ecosystem for web development was a lot more primitive back then (which serves to highlight how impressive his idea is/was).
(= a 1)
(whitepage (= b (+ a 1)) (pr b))
And you obtain: <html><body bgcolor=#ffffff alink=#0000be>2</body></html> (mac uvar (u k) `((profs* ,u) ',k))
(def user-age (u) (hours-since (uvar u created)))
Without a macro you'd have to call uvar like: (uvar u 'k). For this example I'd favor 'k because it makes the behavior clearer.(Did you mean uvar instead of upvar?)
If you are using macros you may start sending the html parts before the whole page is constructed.
The latter approach is advantageous if a page needs some heavy computations to generate it: with macros the user will start seeing at least something right away; plus, the browser will load CSS faster if you send that part before the computations.
On the other hand if there was an error in the middle of page generation you will not be able to handle it gracefully since you've already send half of the page to the user.
Not necessarily... even using functions, you can create a 'lazy node' in the page graph to delay completion of calculation until the final renderer actually starts rendering the node.
I guess the only advantage of using macros is that you can make page generation code without consing relatively easily. I'm not sure how necessary it is for web servers, but it may matter for extremely high-traffic sites.
Just about every language NOW has a good FFI to C. Subtract several years for when that essay was written, then subtract ten years for when the statement is set in, and you'll encounter a different world.
Today there's no great reason not to write your desktop app in PyQT or Clojure or on top of XULRunner. (Although I'd point out that surprisingly few people have noticed this!) ViaWeb was born into a different world. I didn't do much desktop programming in the 1996 timeframe, but you did not have many choices, especially if you were a student that couldn't drop ~$1000 2009-dollars into a programming language environment. (Now my new supercomputer-laptop costs less than that and superior environments are free. Vive la progress!) A couple that weren't C and, as it turns out, all doomed to be unsupported within a few years anyhow, like Delphi. I talk about 1996 because it's when I got into the game; the essay is a talk given in 2001 which means "ten years ago" is 1991.
Another reason is documentation. You'll have an easier time finding documentation/examples for the main language of the OS.
Another reason: having dependencies that aren't available on the target OS does impose additional development costs (if you don't want to give the user the burden of installing those dependencies). And if the distribution is over the Internet, it also means a bigger download size and extra harddisk space. These things may or may not matter, but imagine a simple feedreader that requires a 30MB download and 200MB of free disk space.
The main language of the OS doesn't necessarily have to be C/C++. It's the language that's best supported and encouraged by the company/community that maintains the OS (although it's currently not possible to write system drivers in C# on Windows, work is being done to lift some device drivers in user mode, which would make a good fit for .NET)
Big companies outsource their R&D like this too, letting startups detect problems and solve them. Then the big corp. buys that startup (or copies it), and absorbs the solution into the platform, so the platform is constantly improving. It's a great thing for users.
And before you down-vote this... well, I suppose I deserve it. Carry on.