Can anyone suggest good sources of information, particularly books on the new features in Java 1.5? I'm particularly interested in generics. For example, it seems to me, that you should can build up concepts as interfaces and specify template classes with templates that must implement particular interfaces. This would be better than C++ because I don't think you can specify that a template class must, for example, implement assignable and equality comparable, in C++. (I know Boost does this, but there is some runtime overhead.) The new java may be capable of it if you're willing to accept .equals() instead of operator=(), etc. I'm also interested to find out other new features. Apparently templates are compiled once only - no code bloat and no delayed errors. Can anyone comment on the status of gcj and java 1.5? If gcj can handle java 1.5 templates, it may compile better than C++ and give comparable run-speed. -- JDL
John, I can't say I think this is particularly on-topic for the SuSE-Programming-E list. See below for a better alternative. On Wednesday 09 March 2005 10:16, John Lamb wrote:
Can anyone suggest good sources of information, particularly books on the new features in Java 1.5?
I found two small volumes that summarize the new features in Java 1.5 / 5.0: - Java 1.5 Tiger -- A Developer's Notebook (tm) Brett McLaughlin, David Flanagan O'Reilly - Java 2, v5.0 (Tiger) New Features Herbert Schildt Osborne / McGraw Hill
I'm particularly interested in generics. For example, it seems to me, that you should can build up concepts as interfaces and specify template classes with templates that must implement particular interfaces. This would be better than C++ because I don't think you can specify that a template class must, for example, implement assignable and equality comparable, in C++. (I know Boost does this, but there is some runtime overhead.) The new java may be capable of it if you're willing to accept .equals() instead of operator=(), etc.
I'm sure it's debatable, but I think Java generics are a poor substitute for proper templates. As to your point about constraints on acceptable parameter types being missing from C++, that's not really true. If the template uses a member function, then any attempt to use as a parameter a type that does not provide it will cause template instantiation to fail.
I'm also interested to find out other new features. Apparently templates are compiled once only - no code bloat and no delayed errors.
No code replication, no type-specific static optimizations, either. As for delayed errors, I don't believe they're entirely precluded by Java's type erasure appropach to generic types.
... JDL
If you're interested in these things, I recommend you join us over on the Advanced-Java list run which is run from Discuss.Develop.com. It's a pretty low-volume list and is meant (as its name suggests) specifically to address advanced Java programming and design topics. Randall Schulz
John, On Wednesday 09 March 2005 11:11, Randall R Schulz wrote:
John,
...
I'm particularly interested in generics. For example, it seems to me, that you should can build up concepts as interfaces and specify template classes with templates that must implement particular interfaces. This would be better than C++ because I don't think you can specify that a template class must, for example, implement assignable and equality comparable, in C++. (I know Boost does this, but there is some runtime overhead.) The new java may be capable of it if you're willing to accept .equals() instead of operator=(), etc.
I'm sure it's debatable, but I think Java generics are a poor substitute for proper templates.
As to your point about constraints on acceptable parameter types being missing from C++, that's not really true. If the template uses a member function, then any attempt to use as a parameter a type that does not provide it will cause template instantiation to fail.
By the way, there's already considerable commentary on the Web comparing C++ Templates and Java Generics. A Google search for "C++ Templates Java Generics" produces quite a few relevant hits.
...
Randall Schulz
Randall R Schulz wrote:
If you're interested in these things, I recommend you join us over on the Advanced-Java list run which is run from Discuss.Develop.com. It's a pretty low-volume list and is meant (as its name suggests) specifically to address advanced Java programming and design topics.
Thanks. Davi de Castro Reis wrote:
Yes. Boost has the concept_check stuff, but AFAIK, there is no runtime overhead at all. Also, you can guarantee the interface mixing templates and inheritance.
template <class T : public myInterfaceClassName> class ...
Pretty simple uh? But you rarely see people using it, because generic programming and traditional object programming seems to be some sort of competitors.
I couldn't find any reference to this in the draft standard or in
Stroustrup and I couldn't get an example like this to compile in g++
3.4.2 or 3.4.4 (though I know 3.4.2 won't accept some legal stuff like
class : public class A { ... } object;)
OTOH, when I tried an example, I found that
template<typename T>
class X {
...
private:
void do_nothing() const {
const T* const t = 0;
static_cast
On Thursday 10 March 2005 2:30 pm, John Lamb wrote:
Davi de Castro Reis wrote:
Yes. Boost has the concept_check stuff, but AFAIK, there is no runtime overhead at all. Also, you can guarantee the interface mixing templates and inheritance.
template <class T : public myInterfaceClassName> class ...
Pretty simple uh? But you rarely see people using it, because generic programming and traditional object programming seems to be some sort of competitors.
I couldn't find any reference to this in the draft standard or in Stroustrup and I couldn't get an example like this to compile in g++ 3.4.2 or 3.4.4 (though I know 3.4.2 won't accept some legal stuff like class : public class A { ... } object;) John, We are talking Java 1.5 where generics are introduced, not C++. -- Jerry Feldman
Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
Jerry Feldman wrote:
On Thursday 10 March 2005 2:30 pm, John Lamb wrote:
Davi de Castro Reis wrote:
Yes. Boost has the concept_check stuff, but AFAIK, there is no runtime overhead at all. Also, you can guarantee the interface mixing templates and inheritance.
template <class T : public myInterfaceClassName> class ...
John, We are talking Java 1.5 where generics are introduced, not C++.
Hvit? Now I am confused. AFAIK, there is no 'template' keyword in Java and it would use 'extends' or 'implements' in place of ':' if it allows such things. It's a nice idea though.. I like the idea that something important can be expressed through the syntax rather than just constructed through an idiom. -- JDL
Jerry Feldman wrote:
On Thursday 10 March 2005 2:30 pm, John Lamb wrote:
Davi de Castro Reis wrote:
Yes. Boost has the concept_check stuff, but AFAIK, there is no runtime overhead at all. Also, you can guarantee the interface mixing templates and inheritance.
template <class T : public myInterfaceClassName> class ...
John, We are talking Java 1.5 where generics are introduced, not C++.
Hvit? Now I am confused. AFAIK, there is no 'template' keyword in Java and it would use 'extends' or 'implements' in place of ':' if it allows such things.
It's a nice idea though.. I like the idea that something important can be expressed through the syntax rather than just constructed through an idiom. This is true, but we were talking about Java Generics, which is effectively
On Friday 11 March 2005 2:36 pm, John Lamb wrote:
the Java version of the C++ Templates.
Time for someone to invent a new language :-)
--
Jerry Feldman
Jerry, On Friday 11 March 2005 11:49, Jerry Feldman wrote:
...
This is true, but we were talking about Java Generics, which is effectively the Java version of the C++ Templates.
This is a adequate characterization if you're taking the "five-mile-high" perspective. On the ground dealing with details, they're very, very different things with different strengths and weaknesses. There are plenty of people who wish, as I do, Java had taken a more C++-like approach.
Time for someone to invent a new language :-)
Yes and no. We don't need another language in the spirit of Simula / C++ / Java. Perhaps something the integrates AOP with OOP would be a logical next step.
-- Jerry Feldman
Randall Schulz
On Friday 11 March 2005 3:35 pm, Randall R Schulz wrote:
Yes and no. We don't need another language in the spirit of Simula / C++ / Java. Perhaps something the integrates AOP with OOP would be a logical next step. There's got to be someone out there who does not like curly braces. Maybe someone will resurect COBOL :-) -- Jerry Feldman
Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
On Saturday 12 March 2005 08:18, Jerry Feldman wrote:
On Friday 11 March 2005 3:35 pm, Randall R Schulz wrote:
Yes and no. We don't need another language in the spirit of Simula / C++ / Java. Perhaps something the integrates AOP with OOP would be a logical next step.
There's got to be someone out there who does not like curly braces. Maybe someone will resurect COBOL :-)
Perhaps. Apparently there is a very large quantity of COBOL and FORTRAN still executing robust code. That is, it doesn't need constant 'updating' nor maintenance - and interesting idea not to need 'updates' ? Colin
On Fri, 2005-03-11 at 13:18, Jerry Feldman wrote:
On Friday 11 March 2005 3:35 pm, Randall R Schulz wrote:
Yes and no. We don't need another language in the spirit of Simula / C++ / Java. Perhaps something the integrates AOP with OOP would be a logical next step. There's got to be someone out there who does not like curly braces. Maybe someone will resurect COBOL :-)
Its called KOBOL by the Kompany. There is a lot of old code out there. -- ___ _ _ _ ____ _ _ _ | | | | [__ | | | |___ |_|_| ___] | \/
template <class T : public myInterfaceClassName> class ...
Pretty simple uh? But you rarely see people using it, because generic programming and traditional object programming seems to be some sort of competitors.
I couldn't find any reference to this in the draft standard or in Stroustrup and I couldn't get an example like this to compile in g++ 3.4.2 or 3.4.4 (though I know 3.4.2 won't accept some legal stuff like class : public class A { ... } object;)
Puf. Somehow I couldn't make it compile also. I am pretty sure there is some notation like the one above that is valid C++ code (or maybe I just had a dream about it). Well, there are other solutions for this problem. Check out traits: http://www.gotw.ca/gotw/071.htm []s Davi de Castro Reis
John Lamb wrote:
Can anyone suggest good sources of information, particularly books on the new features in Java 1.5?
I'm particularly interested in generics. For example, it seems to me, that you should can build up concepts as interfaces and specify template classes with templates that must implement particular interfaces. This would be better than C++ because I don't think you can specify that a template class must, for example, implement assignable and equality comparable, in C++. (I know Boost does this, but there is some runtime overhead.) The new java may be capable of it if you're willing to accept .equals() instead of operator=(), etc.
Yes. Boost has the concept_check stuff, but AFAIK, there is no runtime overhead at all. Also, you can guarantee the interface mixing templates and inheritance. template <class T : public myInterfaceClassName> class ... Pretty simple uh? But you rarely see people using it, because generic programming and traditional object programming seems to be some sort of competitors. []s Davi de Castro Reis
participants (6)
-
Carl William Spitzer IV
-
Colin Carter
-
Davi de Castro Reis
-
Jerry Feldman
-
John Lamb
-
Randall R Schulz