Re: "Real" Templates for Java?
From: Daniel Bonniot (Daniel.Bonniot_at_inria.fr)
Date: 07/22/04
- Next message: Markus Schaber: "Re: Java HTML Parser"
- Previous message: Markus Schaber: "Re: Caching a large file - 2nd post"
- In reply to: Markus Schaber: ""Real" Templates for Java?"
- Next in thread: Markus Schaber: "Re: "Real" Templates for Java?"
- Reply: Markus Schaber: "Re: "Real" Templates for Java?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 22 Jul 2004 14:36:34 +0200
> Does anybody know a tool for java that does "real" templates
First, your requirements are incompatible with the definition of
Java-the-language, so I'm assuming what you are looking for is a
Java-like language that supports those features, while compiling to Java
bytecodes and generally assuring compatibility with Java code.
One close match for your requirements seems to be PolyJ
(http://www.pmg.lcs.mit.edu/polyj/). They offer more power than Java
1.5. Note however that they use an homogeneous translation, so you won't
avoid the casts nor the boxing/unboxing for primitive types.
A big set back is that development seems to have died in July 2000,
while there are still important bugs and missing features
(http://www.pmg.lcs.mit.edu/polyj/bugs.html), including no inner classes
and no full support of JDK 1.1.
Another project (with which I'm involved) to look at is the Nice
language (http://nice.sf.net).
Regarding your requirements:
> - Avoiding of runtime typechecks / casts altogether.
The translation is homogeneous, so the runtime checks are still there. I
don't know of any tool that does the expansion. That should be done in
the future, especially for primitive types, where it really makes a
difference.
> - Availability of the actual type parameters inside the template
> instances (so you can e. G. do a
> T[] blubb = new T[100];
> which impossible with Generics.
new T[...] is possible in Nice.
> - Signature-Based templating (we write a template that accepts all
> objects that have a foobar() method, and only when using the template,
> you have to ensure that your Class/Interface parameter you use for
> instantiation has this foobar() method. This allows to use the same
> template (in different places) for different types that have no common
> parent providing the foobar() method.
Nice uses type constraints, since we believe it allows for better design
and documentation. Still, it can handle using the same generic code with
different types developed independently. That's possible because you can
define "abstract interfaces", and make existing classes (imported from a
package you don't control) implement those interfaces.
I refer you to the relevant part of the user manual for a detailed
motivating example:
http://nice.sourceforge.net/manual.html#abstractInterfaces
> - Runs in java 1.4 VMs, as it will take some time for 1.5 to get stable
> enough.
It does.
> - Possibility of templating primitive types (currently, this is not so
> important for us, as the number of primitive types is rather limited and
> won't expand in the near future :-).
You can use primitive types as type parameters. However, you must be
aware that in the current implementation this will possibly cause
boxing/unboxing.
> Hints to both "preprocessor" and direct byte-code creating tools are
> welcome, but we prefer open source tools (or at least tools which come
> together with their source code and the license allows us to modify them
> and fix bugs).
Nice compiles directly to java bytecode. It is actively maintained and
developed, and it is available under the GPL. It has many other
improvements, like anonymous functions/closures, multimethods, tuples,
optional parameters to methods, and method contracts (as in Design by
contract)... All this is designed to be as seamlessly inter operable
with Java as possible. Find out more at http://nice.sf.net/ and feel
free to ask further questions about it.
Cheers,
Daniel
- Next message: Markus Schaber: "Re: Java HTML Parser"
- Previous message: Markus Schaber: "Re: Caching a large file - 2nd post"
- In reply to: Markus Schaber: ""Real" Templates for Java?"
- Next in thread: Markus Schaber: "Re: "Real" Templates for Java?"
- Reply: Markus Schaber: "Re: "Real" Templates for Java?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|