From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA19427; Sun, 3 Oct 2004 22:45:16 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA18269 for ; Sun, 3 Oct 2004 22:45:15 +0200 (MET DST) Received: from annexia.force9.co.uk (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i93KjFE3015369 for ; Sun, 3 Oct 2004 22:45:15 +0200 Received: from rich by annexia.force9.co.uk with local (Exim 3.36 #1 (Debian)) id 1CEDEI-0000rV-00 for ; Sun, 03 Oct 2004 21:45:14 +0100 Date: Sun, 3 Oct 2004 21:45:14 +0100 Cc: caml-list@inria.fr Subject: Re: [Caml-list] Ocaml server pages? Message-ID: <20041003204514.GA2983@annexia.org> References: <8EA10FF1-13C1-11D9-B79D-000A95C0AA8E@cs.umass.edu> <20041001160452.GA16873@annexia.org> <001b01c4a7e0$fbaf7770$ef01a8c0@warp> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="FCuugMFkClbJLl1L" Content-Disposition: inline In-Reply-To: <001b01c4a7e0$fbaf7770$ef01a8c0@warp> User-Agent: Mutt/1.5.5.1+cvs20040105i From: Richard Jones X-Miltered: at concorde with ID 416064DB.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 cannasse:01 api:01 dynlink:01 shortcoming:01 gerd's:01 netcgi:01 perl's:01 ocamlnet:01 ocamlnet:01 jserv:01 jserv:01 forking:01 templating:01 X-Attachments: type="application/pgp-signature" name="signature.asc" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk --FCuugMFkClbJLl1L Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 01, 2004 at 08:03:39PM +0200, Nicolas Cannasse wrote: > > Note that there are at least 4 different ways to do web stuff with > > OCaml, all with their own pros and cons. At some point I intend to > > write up a summary, but in the meantime, here are the three (other) > > packages in no particular order. You can go to their web pages and > > read about them: >=20 > Could you quickly sum up theses differences for this list readers ? > I'm recently interested in high level server side languages. > Any hint to show me what's "best" is apprecied. I'm not going to claim that any of the four approaches is best, but I will try to summarise them as far as my understanding goes. Please don't flame me too much for this; and do also note that I am the author of mod_caml. ** mod_caml mod_caml sits inside the Apache process, and its strengths and limitations derive from this fact. Because it's inside the process, it has full access to the Apache API, which means that you can, for example, make subrequests, or write an authentication handler, or write a more sane URL mapping system than mod_rewrite, or [coming soon, with Apache 2.0] use OCaml code to post-process the output of some other CGI script written in another language. It's completely tied to Apache. You have no other webserver choice once you've decided to use mod_caml. Apache preforks itself, so there are actually several instances of your code running, in separate processes, all working on separate HTTP requests. Because it uses Dynlink to load code, you can only use bytecode. (I would argue that most web applications are heavily IO bound, so this isn't a problem. But I can certainly imagine some compute-intensive application, or part of an application, where the lack of native compilation would be a serious shortcoming). It doesn't use Gerd's Netcgi module, but instead uses its own which is basically a reimplementation of Perl's Cgi.pm in OCaml. This is good news for ex-Perl refugees like me, of course. mod_caml itself is independent of ocamlnet, but I personally use quite a lot of ocamlnet functions. The 2.0 release of COCANWIKI will depend on ocamlnet for URL parsing, generating and parsing MIME emails, and maybe other stuff. It comes with a template library to enforce correct separation of code and HTML. You can see this in action by grabbing the COCANWIKI 1.0 distribution from http://sandbox.merjis.com/ and comparing the scripts/ and templates/ directories. ** ocamlnet & asxcaml ocamlnet runs outside the web server, using either FastCGI or JSERV to communicate with the web server. (Or you can run your scripts as ordinary CGI external programs, but I wouldn't recommend that for serious use). Your program is linked together into a single binary which, when started, is a FastCGI or JSERV server, and processes requests either sequentially or by forking a new process for each request. The webserver then acts as a proxy between the browser and your program. There are two important consequences of this: (1) You can use native code. (2) Your whole program is compiled together a single unit. There's no templating or database access, but you could easily add these by using mod_caml's templating system or CamlTemplate, and ocamldbi respectively. AS/XCaml is built on top of ocamlnet, and I'm not going to claim to fully understand it or even to have used it. However the big feature is the statically typed SQL implementation. This is a big improvement over ocamldbi (which can throw type errors at runtime if your database returns a field with an unexpected type). The reason I didn't do this for ocamldbi was because it would involve fully parsing every variant of SQL and/or limiting the complexity of SQL queries permitted. AS/XCaml uses an XML file to describe your database schema, and from this (I'm guessing) derives the schema and queries. In concept this is very similar to PDL [http://www.redhat.com/docs/manuals/waf/rhea-dg-waf-en-6.1/s1-pers-pdl.html= ]. ** mod_ocaml This is another Apache module. It's similar in concept to JSP or PHP. You actually embed OCaml code into your webpage. The webpage is then compiled (with ocamlc) and run on the fly. Your OCaml code prints HTML. Having worked in a professional web applications outfit for a few years, I can't in all conscience recommend embedding code into web pages which designers might try to edit. Rich. --=20 Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment Learning Objective CAML for C, C++, Perl and Java programmers: http://www.merjis.com/richj/computers/ocaml/tutorial/ --FCuugMFkClbJLl1L Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFBYGTa4le1M6q9pzoRAmhfAJoD9Ycy42xvjzEWQ2ucSxf597f9NwCgqHdI 1AXLnbxQgfPxj07Xz1nWdj4= =N4ci -----END PGP SIGNATURE----- --FCuugMFkClbJLl1L-- ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners