caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Goerzen <jgoerzen@complete.org>
To: caml-list@inria.fr
Cc: Jason Smith <jns28@student.canterbury.ac.nz>,
	skaller@users.sourceforge.net
Subject: Re: [Caml-list] Alternative Bytecodes for OCaml
Date: Wed, 25 Aug 2004 10:52:26 -0500	[thread overview]
Message-ID: <200408251052.27094.jgoerzen@complete.org> (raw)
In-Reply-To: <00af01c48ab7$66986c50$b509b584@Praxis>

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


  reply	other threads:[~2004-08-25 15:52 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-25 14:26 John Goerzen
2004-08-25 14:38 ` Richard Jones
2004-08-25 14:50   ` John Goerzen
2004-08-25 15:02     ` John Goerzen
2004-08-26  9:05       ` Raphael Montelatici
2004-08-26 13:20         ` John Goerzen
2004-08-26 13:30           ` John Goerzen
2004-08-25 14:55   ` Lars Nilsson
2004-08-25 15:06     ` Jason Smith
2004-08-25 16:14       ` John Goerzen
2004-08-28  3:49     ` John Goerzen
2004-08-25 15:05 ` skaller
2004-08-25 15:21   ` Lars Nilsson
2004-08-25 15:22   ` Jason Smith
2004-08-25 15:52     ` John Goerzen [this message]
2004-08-25 16:26       ` Jason Smith
2004-08-25 16:40         ` Jason Smith
2004-08-25 16:49       ` Ville-Pertti Keinonen
2004-08-25 17:01         ` Jason Smith
2004-08-25 17:17         ` John Goerzen
2004-08-25 20:00       ` skaller
2004-08-25 15:23   ` Brian Hurt
2004-08-25 15:24     ` Christophe TROESTLER
2004-08-27 14:26     ` Daniel Ortmann
2004-08-27 14:44       ` skaller
2004-08-27 14:59       ` Brian Hurt
2004-08-25 15:35   ` John Goerzen
2004-08-25 16:00   ` Richard Jones
2004-08-25 15:40 ` Nicolas Cannasse
2004-08-27 17:55   ` John Goerzen
2004-08-27 18:37     ` skaller
2004-08-27 18:49       ` John Goerzen
2004-08-27 20:39         ` skaller
2004-08-27 20:56           ` John Goerzen
2004-08-27 22:05             ` Richard Jones
2004-08-27 23:15               ` John Goerzen
2004-08-31 11:10                 ` Keith Wansbrough
2004-08-28  0:25             ` skaller
2004-08-28  9:35               ` Marcin 'Qrczak' Kowalczyk
2004-08-28  9:50                 ` Marcin 'Qrczak' Kowalczyk
2004-08-28 10:41                   ` skaller
2004-08-28 11:37                     ` Marcin 'Qrczak' Kowalczyk
2004-08-25 17:37 ` Basile Starynkevitch [local]
2004-08-25 18:00   ` Richard Jones
2004-08-25 22:10 ` Yamagata Yoriyuki
2004-08-26  0:09   ` John Goerzen
2004-08-26  4:26     ` [Caml-list] bytecode and native code at once Brandon J. Van Every
2004-08-26  9:55       ` skaller
2004-08-26 15:52         ` [Caml-list] " mikel
2004-08-26 17:09           ` Paul Snively
2004-08-26 17:31             ` mikel evins
2004-08-26 18:04               ` Paul Snively
2004-08-26 18:28                 ` mikel evins
2004-08-26 21:15             ` skaller
2004-08-27  8:52           ` Keith Wansbrough
2004-08-27 15:39             ` David Brown
2004-08-27 15:48               ` mikel evins
2004-08-26 21:42     ` [Caml-list] Alternative Bytecodes for OCaml Michal Moskal
2004-08-27  9:38       ` Nicolas Cannasse
2004-08-27 13:09         ` John Goerzen
2004-08-27 13:44           ` Brian Hurt
2004-08-27 13:58           ` skaller
2004-08-27 20:48           ` Nicolas Cannasse
2004-08-27 21:03             ` Benjamin Geer
2004-08-30 16:40             ` John Goerzen
2004-08-27 19:49         ` Blair Zajac
2004-08-27 22:18           ` Richard Jones
2004-08-27 23:38             ` Yamagata Yoriyuki
2004-08-28 16:40               ` Basile Starynkevitch [local]
2004-08-28 17:03                 ` [Caml-list] (GC issues) " Nicolas Cannasse
2004-08-28 20:45                   ` [Caml-list] " Basile Starynkevitch [local]
2004-08-29  2:31                     ` skaller
2004-08-29  5:04                       ` Brandon J. Van Every
2004-08-29 12:58                         ` John Goerzen
2004-08-29 15:06                           ` Brian Hurt
2004-08-29 15:22                             ` Radu-Mihail Obada
2004-08-29 10:12                     ` Nicolas Cannasse
2004-08-30 12:23                       ` Basile Starynkevitch [local]
2004-08-30 13:17                         ` Nicolas Cannasse
2004-08-26 16:04 ` [Caml-list] " =?unknown-8bit?Q?=A3ukasz?= Dobrek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200408251052.27094.jgoerzen@complete.org \
    --to=jgoerzen@complete.org \
    --cc=caml-list@inria.fr \
    --cc=jns28@student.canterbury.ac.nz \
    --cc=skaller@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).