"Real" Templates for Java? (Retry)

M

Markus Schaber

Hi,

[It seems that my original post yesterday got stuck somewhere and did
noth arrive at most news servers, thus a repost.]

Does anybody know a tool for java that does "real" templates (Not the
limited "Generics" that come with Java 1.5, but more like the Templates
in C++ are, so you have multiple specialised class files for differently
instantiated Templates to avoid all hidden run-time typecasts etc)?

We hope to get the following advantages over the java 1.5 Generics:

- Avoiding of runtime typechecks / casts altogether.

- 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.

- 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.

- Runs in java 1.4 VMs, as it will take some time for 1.5 to get stable
enough.

- 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 :).

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).

Thanks for your answers,
Markus Schaber
 
C

Chris Uppal

Andrew said:
[It seems that my original post yesterday got stuck somewhere and did
noth arrive at most news servers, thus a repost.]

What leads you to believe that?

Hmm, neither Markus's post nor Daniel's reply have made it to my news server
(Giganews, who are generally pretty good, I thought).

But then, I've been suspecting for some time that only about half the posts I
make are seen widely...

As for the original question: I'm not aware (and I don't want to /become/ aware
;-) of a template facility for Java. You may like to research the various
generics implementations that were proposed before the 1.5 stuff was settled
on. There were quite a number using a variety of techniques (e.g. one used
dynamic code generation to handle primitives). I can't remember all the names,
or which was which, but if you start with PolyJ, GJ and Pizza then you'll find
cross-references to the rest.

-- chris
 
M

Markus Schaber

Hi, Andrew,

[It seems that my original post yesterday got stuck somewhere and
did noth arrive at most news servers, thus a repost.]

What leads you to believe that?

For reference it (as well as the replies from
Danniel Bonniot) can be seen in all their glory, here..
<http://groups.google.com/groups?th=5266f5e6f6912612>

That's true, Google finds it, as well as some other servers.

It turned out that a strange interaction between a buggy nntp client and
some lack of sleep leaded to some cancel messages for my postings to be
sent, and so some servers deleted the message.

Sorry for the inconvenience.

Markus
 
A

Andrew Thompson

Sorry for the inconvenience.

It is not an inconvenience. I would recommend
you cross-reference it to the Google of the
original if you can locate it.*

* Obviously though, sometimes it has not reached
Google yet, or, as might happen in exctly the
circumstance you described, has indeed been
'lost to the ether'.

Chris Uppal's response also echo's your concern,
...you ..do see *his* response, no? ;-)
 
M

Markus Schaber

Hi, Andrew,

As for the original question: I'm not aware (and I don't want to
/become/ aware;-) of a template facility for Java.

We don't need the full C++ template engine. Type parametrization is
enough, but it should not be implemented only half-ways. (We could trust
in the JITs to eliminate the cast / typecheck overhead, but the lack of
runtime type information in the template instances is a severe loss of
power.)

We think that the Java developers included just enough genericity to
enhance their container classes.
You may like to
research the various generics implementations that were proposed
before the 1.5 stuff was settled on. There were quite a number using
a variety of techniques (e.g. one used dynamic code generation to
handle primitives). I can't remember all the names, or which was
which, but if you start with PolyJ, GJ and Pizza then you'll find
cross-references to the rest.

I'm already researching into those. PolyJ implements only Java 1.0, as
well as it seems dead and rather windows-centric, and depends on guavac
which is orphaned itsself.

GJ implements just the same as Java 1.5. I did not have a look deep
enough at Pizza, but it seems that they provide additional features, but
use the same techniques as Java 1.5.

Currently, Nextgen seems to be the most promising system, but it is only
available in non-documented binary form.

Thanks for your efforts,
Markus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,268
Latest member
AshliMacin

Latest Threads

Top