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 RAA27490; Wed, 25 Aug 2004 17:52:32 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA28447 for ; Wed, 25 Aug 2004 17:52:31 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from gatekeeper.elmer.external.excelhustler.com (gatekeeper.excelhustler.com [68.99.114.105]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i7PFqT2l029103 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=FAIL) for ; Wed, 25 Aug 2004 17:52:31 +0200 Received: from chatterbox.elmer.internal.excelhustler.com (unknown [192.168.0.12]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "chatterbox.elmer.internal.excelhustler.com", Issuer "excelhustler.com" (not verified)) by gatekeeper.elmer.external.excelhustler.com (Postfix) with ESMTP id 7AB2CEFA32; Wed, 25 Aug 2004 10:52:29 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by chatterbox.elmer.internal.excelhustler.com (Postfix) with ESMTP id 53740C006D; Wed, 25 Aug 2004 10:52:29 -0500 (CDT) Received: from chatterbox.elmer.internal.excelhustler.com ([192.168.0.12]) by localhost (chatterbox [192.168.0.12]) (amavisd-new, port 10025) with ESMTP id 12522-04; Wed, 25 Aug 2004 10:52:27 -0500 (CDT) Received: from wile.internal.excelhustler.com (wile.internal.excelhustler.com [192.168.1.34]) by chatterbox.elmer.internal.excelhustler.com (Postfix) with ESMTP id 60DB6EFA33; Wed, 25 Aug 2004 10:52:27 -0500 (CDT) Received: by wile.internal.excelhustler.com (Postfix, from userid 1000) id 5824B3701E; Wed, 25 Aug 2004 10:52:27 -0500 (CDT) From: John Goerzen To: caml-list@inria.fr Subject: Re: [Caml-list] Alternative Bytecodes for OCaml Date: Wed, 25 Aug 2004 10:52:26 -0500 User-Agent: KMail/1.7 Cc: Jason Smith , skaller@users.sourceforge.net References: <200408250926.28629.jgoerzen@complete.org> <1093446345.15255.565.camel@pelican.wigram> <00af01c48ab7$66986c50$b509b584@Praxis> In-Reply-To: <00af01c48ab7$66986c50$b509b584@Praxis> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200408251052.27094.jgoerzen@complete.org> X-Virus-Scanned: by amavisd-new-20030616-p7 (Debian) at excelhustler.com X-Miltered: at nez-perce with ID 412CB5BD.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 bytecodes:01 2004:99 python:01 python:01 interfacing:01 runtime:01 runnable:01 poof:99 model:01 compiles:01 java's:01 glue:01 seamlessly:01 glue:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wednesday 25 August 2004 10:22 am, Jason Smith wrote: > > > I come to OCaml from a Python background, and one of the most > > > interesting bits of technology for Python is Jython[1]. > > > > Curious though why you'd want to... interfacing to C > > I can understand. But why bother with the JVM or Java? > > Some possible reasons that suggest themselves: > > 1. You don't need to implement your own runtime environment, no more > fussing around with garbage collection etc.. > 2. You now can run python on every platform that supports a Java > Virtual Machine Yes, this is a key benefit, and would apply to both Python and OCaml. Let's say you've got an Python program and you'd like to make it easily runnable for as many people as possible. You know that most of them have a JVM available. So you could just distribute a .JAR file and poof -- instant app. Runs on OS X, Windows, Linux, BSD, etc. Now, s/Python/OCaml/ and perhaps s/JVM/.NET/. You get the idea. For OCaml developers, that means no compiling necessary for users. No new environment installation. An app can be, on Windows, double-click-and-run just like any other. > 3. More so with .NET then the JVM, because .NET specifically touts > this as a feature, but now u've got a standard type model from which > you can interface with any other language that compiles to it. And that is, in my mind, the key benefit. I am just learning about .NET, so let's talk about Java first. Java's type system is less rich than Python, but it is very strict and defined. There are a few basic types (ints, arrays, etc.) that map directly into Python with no problem. A few of the other types (Strings, etc.) map into Python with a little glue from Jython. Everything else is a class, which maps into Python with no problem at all. Since every class method carries type information with it, Jython knows what is supposed to go in and what is supposed to come out. In many cases, the whole process is completely transparent to the Python programmer as I demonstrated with my earlier message on the topic. That means that, by running my Python code in Jython, I instantly get access to all the libraries available for Java, in addition to all the pure-Python libraries already out there for Python (most of them fall under that category). I get all the features I like from Python, and can mix and match Java calls in with my code seamlessly. I can access JDBC, Swing, Soap, Enhydra, whatever. And I can still use my normal Python ftplib, os, sys, etc. The best part is: NO GLUE. That's the nasty part of interfacing to C. Output parameters, pointers, garbage collection, etc. It's a lot of work. There is no work to do that with Java. Say I want to be able to create a .ZIP file from my OCaml program. I could: 1) write a deflate algorithm and storage algorithm in OCaml; 2) develop an interface to some C library that does this (possibly taking almost as much time due to pointers, memory, and stuff); or 3) open java.util.zip.ZipFile and go to work. (One interesting side-effect: Java enforces private methods at the compiler, not the bytecode, level. Jython programs can actually access private Java class methods.) And you're right, with .NET this benefit grows even more. I can access not just Java stuff there, but also C#, some C++, Python, Perl, whatever else. It's a lot to draw on, and no glue. -- John ------------------- 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