Elements of comparison Java/Hotjava vs. Caml/MMM
Preliminary word: this comparison may not be fully objective.
I appreciate your comments
Java and HotJava are trademarks of Sun Microsystems, Inc.
HotJava is to Java what MMM is to Caml, that is:
- Java and Caml are the languages proposed for programming applets.
HotJava and MMM are browsers supporting their respective applets. Moreover,
both browsers are written in the same language as the applets they
support, presumably as a proof of adequacy of the language to GUIs, Web,...
Java applets are also supported by several other Web browsers. Caml applets
are supported by the Netscape Navigator 3.0 through the Calves
This documents briefly discusses the following topic:
- The languages Java and Caml
- Typing in the languages
- Security in the applet systems
- Libraries accessible through applet APIs
The languages: Java and Caml
- Object-oriented (class-based, C++ family). Extremely simplified language (only basic data types, objects and arrays). No functions (only methods), no record-like data types (only objects), no variants. No parameterized classes.
- Compiled to bytecode (hardware independent, OS independent). Just-in-time compilers also available.
- Garbage collection
- Caml (Objective Caml)
- Functional (not pure, there are imperative constructs such as mutable
objects, IO, loops), with object-oriented support (class-based). General
purpose language. All classical data types (records, variants). Polymorphism.
- Compiled to bytecode (hardware independent, OS independent). Native
compiler available, but not used for applets.
- Garbage collection
- Threads (at the bytecode level or native level when available). Threads
are not used in MMM.
Both languages are typed, meaning that no type error goes undetected.
- Not fully statically typed. Some type errors (exceptions) are detected
at run-time (famous inheritance vs. subtyping problem). For example, each
store to an array of objects requires run-time type checking.
- Explicitly typed.
- No polymorphism (in the ML sense), but notion of interface types.
- Informal description of the type system.
- Module system (module names mapped to filesystem paths)
- Statically typed. No type-errors at run-time (even for objects).
- Type inference.
- Formal type system, proof of soundness.
- Module system similar to that of SML. Higher-order parameterisation of modules.
Both languages make heavy use of typing to enforce security.
The main difference in that Java uses typing at the bytecode level whereas
Caml uses compile-time type-checking, complemented by cryptographic authentication.
- Java applets
- Java has a bytecode verification algorithm. This algorithm perform
various checks (e.g. validity of object field adressing, data conversion,
...) with the help of type information remaining in the bytecode
(e.g. different instructions for integer and pointer loading, field access
by name), and type information relative to class interfaces, attached to the
The bytecode verifier relies on two simple requirements on the abstract
machine instruction set, to be able to construct a "proof" of security by
induction on the code.
- A separate class name space is used for foreign code to avoid built-in class spoofing.
- No access to native methods by applets (?).
- Informal description of the verification algorithm. Source available
only by license.
- Code signing introduced in recent versions.
- Caml applets
- The instructions of the abstract machine do not contain type information.
But, on the other hand:
- the Caml compiler adds, in the bytecode for each compilation unit,
information about the modules it requires. This information is an MD5 digest
of the compiled version of the actual required signatures.
- link-time verifications consists in checking that digests of modules
required by the to-be-linked module, are equal to digests of modules
exported by the browser.
- No access to C primitives by applets.
- PGP-type cryptographic authentication is used to prove to the client
that the security-checks have been made by the applet provider.
Security checks rely entirely on typing.
- Publications available about the type and module systems. Source
Applets themselves are portable. The topic discussed here is the
portability of the runtime environment.
- Java runtime
Preliminary comment: a Java runtime is composed of a interpreter for the Java Virtual Machine and an implementation of native libraries (system calls,
AWT, ...). There exists several implementations of the JVM; the status of
native libraries is not clear.
From JavaSoft, the JDK is currently available for: Solaris, Windows 95/NT, MacOS (depending on JDK versions). The JDK is also available for Linux from Blackdown. OSF has announced projects for porting Java to major Unix platforms. Ports for major Unix platform are proposed by third-parties.
It should also be noted that Netscape Comm. has apparently ported the Java runtime to several Unix platforms, since Java is supported (or will be supported) by Mozilla on most platforms.
- Caml runtime
- The Objective Caml (bytecode runtime) is available for (or portable to) any Unix platform (that is: POSIX-compliant operating systeme and ANSI compliant C compiler). Examples: Digital Unix, SunOS, Solaris, FreeBSD, Linux, MkLinux, NextStep, IRIX, Ultrix, HPUX, AIX (see full list).
Ports to Windows and Mac OS are also available. Porting the
MMM browser would require some additionnal work, but is theoretically possible (because Tcl/Tk is now available on these platforms).
This section discusses the libraries available to the applet author.
- Java applets
- GUIs are programmed in the AWT toolkit.
- Basic interaction with the browser for WWW navigation (also new Content-type handlers ?).
- Network connections (restricted to the host site of the applet). No IO (depends on versions).
- No general purpose library.
- Caml applets
- GUIs are programmed using CamlTk, the Tcl/Tk interface for Caml.
- Access to navigation functions of the browser.
- Extensions of the browser (Content-Type handlers, link activation semantics, HTML display machine,...).
- User-checked IOs. Network access only through browser navigation and HTTP protocol.
- Simple capability system to write safe libraries with access right control
- camlyacc, camllex, standard implementations for common data structures
(lists, arrays, hash-tables, queues, sets, sorting, stack, random).
- Java, Hotjava, Netscape
- Hotjava is freely available, but supports only the obsolete Java alpha API. Netscape distribution policy varies according to the user status. The Java
specification is proprietary but freely available. The sources of the system are available under
license. A Java compiler is freely available.
- Objective Caml, MMM.
- All sources available freely. Both systems are freely usable, but derivative
work is subject to permission.