Java Generics and Collections 278
andrew cooke writes "Java 6 was recently
released, but many programmers are still exploring the features
introduced in Java 5 — probably the most significant changes in
the language's twelve year history. Amongst those changes (enumerations,
auto-boxing, foreach, varargs) generics was the most far-reaching,
introducing generic programming in a simpler, safer way than C++
templates and, unlike generics in C#, maintaining backwards (and
forwards) compatibility with existing Java code." Read on for the rest of Andrew's review.
Java Generics and Collections | |
author | Maurice Naftalin, Philip Wadler |
pages | 273 |
publisher | O'Reilly Media, Inc. |
rating | 9/10 |
reviewer | Andrew Cooke |
ISBN | 978-0-596-52775-4 |
summary | Guide to Java generics; also includes interesting discussion of collection classes. |
Given the history of Generic Java, Naftalin and Wadler's Java Generics and Collections has a distinguished pedigree. In this review I'll argue that this is a new classic.
If you're a Java programmer you've probably heard of generics, an extension to the type system that was introduced in Java 5. They give you, as a programmer, a way to write code even when you don't know exactly what classes will be used.
The obvious example is collections — the author of a List class has no idea what type of objects will be stored when the code is used.
Before generics, if you wanted to write code that handled unknown classes you had to use make use of inheritance: write the code as if it would get Objects, and then let the caller cast the result as necessary. Since casts happen at runtime any mistakes may cause a runtime error (a ClassCastException).
Generics fix this. They let you write code in which the classes are named (parameters) and the compiler can then check that the use of these class parameters is consistent in your program. So if you have a List of Foo instances you write List<Foo> and the compiler knows that when you read that list you will receive a Foo, not an Object.
I'll get to the book in a moment, but first a little history. If you know any type theory — particularly as used in functional languages like ML and Haskell — then you'll recognize my quick description above as parametric polymorphism. You'll also know that it is incredibly useful, and wonder how Java programmers could ever have managed without it.
Which explains why Philip Wadler, one of the people responsible for Haskell, was part of a team that wrote GJ (Generic Java), one of the experimental Java mutations (others included PolyJ and Pizza) that, back in the day (late 90s) helped explore how parametric polymorphism could be added to Java, and which formed the basis for the generics introduced in Java 5.
So if you want to understand generics, Wadler is your man. Which, in turn, explains why I jumped at the chance to review O'Reilly's Java Generics and Collections, by Maurice Naftalin and Philip Wadler.
This is a moderately slim book (just under 300 pages). It looks like any other O'Reilly work — the animal is an Alligator this time. It's well organized, easy to read, and has a decent index.
There's an odd discrepancy, though: Wadler is the generics Guru; this is going to be `the generics reference'; generics are sexy (in relative terms — we're talking Java here) and collections are not; the title has "Java Generics" in great big letters with "and Collections" in little tiny ones down in a corner. Yet very nearly half this book is dedicated to collections.
Generics is a great, practical read. It starts simply, introducing a range of new features in Java 5, and then builds rapidly.
If you are completely new to generics, you'll want to read slowly. Everything is here, and it's very clear and friendly, but there are not the chapters of simple, repeated examples you might find in a fatter book. Within just 30 pages you meet pretty much all of generics, including wildcards and constraints.
If that makes your head spin, don't worry. Read on. The next hundred or so pages don't introduce any new syntax, but instead discuss a wide range of related issues. The chapters on Comparisons and Bounds and Declarations contain more examples that will help clarify what generics do. And the following chapters on Evolution, Reification, and Reflection will explain exactly why.
So the first seven chapters introduce generics and then justify the implementation — any programmer that takes the time to understand this will have a very solid base in generics.
There are even some interesting ideas on how Java could have evolved differently — section 6.9 Arrays as a Deprecated Type presents a strong case for removing arrays from the language. It's a tribute to the clarity and depth of this book that the reader is able to follow detailed arguments about language design. Fascinating stuff.
The next two chapters, however, were my favorites. Effective Generics and Design Patterns give sensible, practical advice on using generics in your work, including the best explanation of <X extends Foo<X>> I've seen yet (so if you don't know what I am talking about here, read the book).
(A practical word of advice — if at all possible, use Java 6 with generics. Java 5 has a sneaky bug).
The Collections part of the book was more along O'Reilly's `Nutshell' lines: the different chapters explore different collection types in detail. I must admit that at first I skipped this — it looked like API docs re-hashed to extend the size of the book.
Then I felt bad, because I was supposed to be reviewing this book (full disclosure: if you review a book for Slashdot you get to keep it). And you know what? It turned out to be pretty interesting. I've programmed in Java for (too many) years, and I guess I've not been quite as dedicated to tracking how the library has changed as I should have been — I learned a lot.
Again, a wide range of readers are welcome. This is more than a summary of the Javadocs, ranging from thumbnail sketches of trees and hashtables to a discussion of containers intended for multi-threaded programming.
The way I see it now, this part is a bonus: the first half, on generics, makes this book one of the standards; the second half is an extra treat I'm glad I stumbled across (I guess if you're some kind of weird collection-fetishist maybe it's even worth buying the book for).
I've used generics since the first beta release of Java 5 and had experience with parametric polymorphism in functional languages before that (in other words, I can tell my co- from my contra-variance). So I guess I'm heading towards the more expert end of the spectrum and I was worried I'd find the book boring. It wasn't. After claiming to be expert I don't want to spoil things with evidence that I'm actually stupid, but reading this book cleared up a few `misunderstandings' I'd had. I wish I had read it earlier.
If you're new to generics, and you don't mind thinking, I recommend this book. If you're a Java programmer who's a bit confused by <? super Foo> then this is the book for you.
The only people who shouldn't read this are people new to Java. You need to go elsewhere first. This is not a book for complete beginners. This is a great book in the classic — practical, concise and intelligent — O'Reilly mould.
You can purchase Java Generics and Collections from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Generics are basically good. (Score:5, Interesting)
One thing that I found in Java5 was that it lacked generics for several cases, e.g. Awt/Swing objects that were able to contain Object themselves. Not that it was a big problem, but it wouldn't have been bad to have that support there too...
Anyway - Generics is one of the best features of added to Java lately. It really helps. How I miss it when I'm programming for J2ME...
Re: (Score:2)
Re: (Score:2)
SpecificClass[] sca = scv.toArray(new SpecificClass[0]) [sun.com];
should do it, right?
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:3, Informative)
Re: (Score:3, Interesting)
I'm sorry, but I don't know what you are smoking. Vector is entirely retrofitted to use generics, and it does it fine. And a comment like "ArrayList is a much better choice nowadays" is complete BS. They are virtually identical, with one important difference, spelled out in the documentation [sun.com]: "This class is roughly equivalent to Vector, except that it is unsynchronized". Meaning that if you ever plan to do anything with threads, stick with Vector. In fact, always stick with Vector. It's a better class, and
Re: (Score:3, Informative)
Actually, no. Use ArrayList and synchronize access to it where needed in your code. The synchronization in Vector is a very blunt tool.
Re: (Score:3, Informative)
The problem with this logic is that the synchronization provided by the Vector class is, at best, useless. At worst, it's a recipe for disaster.
The Problem is that the synchronization is applied at the method level. That means there's nothing to stop invocations of different methods from both attempting to update the same data inside the vector at the same time, which can cause bugs that are almo
Re: (Score:3, Informative)
I believe the GP was talking about this problem [javaworld.com], with reading and writing the Vector at the same time (not writing from two threads). Which is not threadsafe.
Re: (Score:2)
Re: (Score:2)
Basically, just do this where foo is the type in the array and fooList is your Collection of Foo objects.
The foos array now is populated with the contents of the fooList.
The toArray() will return an array of type Object, so you will need to use the argument supplied version of the method if you want the compon
Re: (Score:2)
The problems with Comparables usually come about because of a failure to implement Comparable instead of just implement Comparable. Java typically won't tell you that's the problem, it will steer you off into some other wild goose chase, but if you implement Comparable the challenges typically disappear.
All I really wanted... (Score:4, Interesting)
That said, this sounds like a good resource on Java Collections in general (though Sun's javadocs are pretty nice themselves), as well as the other features introduced in Java 5. There also seems to be some discussion of more complex generic structures.
I'm still a bit lukewarm about buying it, but if I were getting back into a lot of Java stuff, I probably would.
Re: (Score:2)
http://java.sun.com/docs/books/tutorial/extra/gene rics/index.html [sun.com]
Also highly worthwhile is http://java.sun.com/docs/books/tutorial/collection s/index.html [sun.com] which describes the generics-enabled standard collection classes, which is 90% of what you'll want generics for anyway.
Share and enjoy.
Re: (Score:2)
Re: (Score:2)
I do wish Sun's JavaDocs generally had more examples. Like, at least a couple of examples per class.
Java 'generics' are not real generics (Score:5, Informative)
Java generics don't provide real type safety, for example, you can easily put Strings in List (that's why Collections.checkedCollection kludge was added).
In C# (or C++), on the other hand, parameterizing a generic type creates a _new_ _type_ which guarantees type safety and allows some quite interesting tricks. For example, in C# generics can be parametrized by primitive types and structs (which don't exist in Java, anyway) so you can have List without overhead of boxing. That's impossible in Java.
Re: (Score:3, Informative)
"you can easily put Strings in List" should be "you can easily put Strings in List<Integer>".
"so you can have List without overhead of boxing" should be "so you can have List<Integer> without overhead of boxing"
Re: (Score:2)
List s = new ArrayList();
List l = s;
l.add("foo");
Further, if you do:
Integer i = s.get(0);
you get a runtime class cast exception.
Re: (Score:2)
List s = new ArrayList<Integer>();
List l = s;
l.add("foo");
Re: (Score:2)
I'd also meant to add the generic to the definition of s, so that it should be:
List<Integer> s = new ArrayList<Integer>();
So when you pull the element out:
Integer i = s.get(0);
it can be done without an explicit cast. But the cast occurs anyway and generates a ClassCastException if you've put a non-Integer into the array. That's far later than it ought to be; the error occurred long ago and far away, so debugging it can be a real
Re: (Score:3, Interesting)
harvey@clownfish:~$ cat test.java
import java.util.*;
public class test
{
public test()
{
List s = new ArrayList<Integer>();
List l = s;
l.add("foo");
}
}
harvey@clownfish:~$ javac test.java
Note: test.java uses unchecked or
Re: (Score:2)
Anyone who uses JPA/Hibernate queries, or works with generics much at all sees this warning come up everywhere, and thus tends to disable the warning in those places. This is fine as long as you pay attention to the warning elsewhere, but since it won't prevent the code from compiling, you can and probably still accidentally deploy something broken anyway.
Generics in C# don't let you use the backward API at all. C++ doesn't even understand the idea
Re: (Score:2)
If you put back the generics in both your post and mine, as somebody corrected for me in a sub-post, I think you and I are talking about the same thing.
I don't know why somebody would cast a List<Integer> to a plain
Static type checking (Score:2)
Re: (Score:2)
Re: (Score:2)
{
lst.add("Hello, world!");
}
List<Integer> intList=new ArrayList<Integer>();
doSomething(intList);
assert(intList.get(0) instanceof Integer);
Re: (Score:2)
Re: (Score:2, Informative)
Re:Java 'generics' are not real generics (Score:4, Informative)
l = new List();
l.add(foo);
Foo foo = l.get(0);
is much safer and easier to read than
v = new Vector();
v.add(foo);
Foo foo = (Foo) v.get(0);
especially when you consider that the obvious mistake
v = new Vector();
v.add(bar);
Foo foo = (Foo) v.get(0);
throws a cast exception at runtime.
I've read a lot of complaints that type erasure (the means by which Java generics are implemented) doesn't solve the whole problem. But there was a certain class of program that generics solved, and it has made development in Java much more productive and safe.
Re: (Score:2)
But the problem is that generics could be implemented in a much better way, C# proves that.
Re: (Score:2)
System.Collections.Generic.List l = new System.Collections.Generic.List();
System.Collections.ArrayList l = new System.Collections.ArrayList();
Doesn't sound very elegant. At least in Java you have only one set.
Re: (Score:2)
Re:Java 'generics' are not real generics (Score:5, Informative)
I've never understood this objection. This will always generate a compiler warning, and depending on your compiler settings may not even compile successfully. The only time you might turn those warnings off is when you're having to deal with non-genericized legacy code.
Re:Java 'generics' are not real generics (Score:5, Interesting)
With "real" generics the system has two choices: either generate lots of bloated specific instances of the code, or add type-checking at runtime. CLR designers thought they were going to do the former and it was going to be 'uber leet' and fast, but found out it's not practical (most of the optimizations that C++ uses to limit bloat do not apply well in a dynamic language) so they got stuck with the latter, for objects.
In Java, the code goes to add something to a generic list for example and it does one cast to the generic parameter type. Many times it can completely remove this check since it already knows from flow that the type is compatible. CLR can do this too, but only if it *also* knows the specific instance of the list (what the generic parameter types are), so it can remove fewer checks. This makes optimization harder as well since each use of a generic parameter can potentially block inlining and/or hoisting.
On top of that, the tests CLR has to do are *much* slower since they have to check many parallel type hierarchies (one per generic type references). For example, when passing a LinkedList of Integers to a parameter of type List of Numbers CLR has to in effect check both List assignable from LinkedList and Number assignable from Integer.
So in the vast majority of code not only do you end up with more checks but slower ones, and CLR has to maintain a complicated hierarchy of instantiated types to optimize this. All so primitives can be used faster in some cases, which is pretty ironic since in my experience these cases are usually easy to optimize by hand to use an array or patch out to inline C++ or JNI'd code.
In other words they messed up their runtime for bullet points without considering the implications. Not even to mention that in Java if you don't like generics, you just don't use them.
Re: (Score:3, Interesting)
It appears that you're confusing CLI generics and C++ templates. I must admit that I have little knowledge of C++ templates, but a comparison of Java's Generics by Type Erasure and C#/CLI's true generics definitely favours the latter.
The following set of slides by Peter Sestoft sums up the differences pretty well: http://www.itu.dk/courses/PFOO/F2006/diku-javacsha rpgenerics.pdf [www.itu.dk]
Slide no. 23 sums up the majo
Re: (Score:2)
For example, here: http://www.artima.com/intv/generics2.html [artima.com]
Too bad Java generics are completely useless (Score:2, Informative)
Yeah, and by maintaining that backwards compatibility, they became totally worthless.
The only thing it offers is some compile-time sanity checking, but even that can be disabled through use of a new compiler pragma directive to su
Re:Too bad Java generics are completely useless (Score:5, Insightful)
Many operations are ERRORS, not warnings. This is caught by IDEs, and by the compiler.
In order to make it possible to interact with legacy code, you can pass a generified collection to a method that expects a "raw" collection. This gives you a very clear warning. So for 95% of all use cases, generics give you a lot of assistance. You manage to come up with a remaining 5% example, where a programmer casts, suppresses compiler warnings, and then passes in a object of the wrong type, and this makes generics worthless?
Wadler was involved with the design of Haskell, and he and people like Gilad Bracha designed Java generics. I trust their skills more than a Slashdot Anonymous Coward.
Re: (Score:3, Insightful)
A) Before generics were added, the toArray(T[]) function already existed as toArray(Object[]). Since this function pre-dates generics, the fact that
Re: (Score:2)
I personally would hate to have 7 different JREs, trying to figure out which one I need for which programs.
Re: (Score:2)
I think you may be getting your facts wrong on this one. The toArray() methods precede Java Generics by at least a version. Those methods exist
Reading Generified Code Makes My Brain Hurt (Score:2, Interesting)
Then there is the Collections API itself which upon first glance seems like it was written by amateurs who have never had to write any performance critical code in their li
Re:Reading Generified Code Makes My Brain Hurt (Score:4, Insightful)
Generics syntax is quite readable and easy-to-use, especially with good IDE support. And generics certainly make the code more readable because the add type information.
Foreach loops, varargs and autoboxing is just a minor syntax sugar, nothing really big.
I've used a lot of collection frameworks in a lot of languages (and even wrote my very own vector and string for C++), Java Collections Framework is quite OK. It's not hard and reasonably fast.
Re: (Score:2)
public interface Functor2 {
R apply(T1 value1, T2 value2);
}
public static R fold(Collection coll, R init, Functor2 func) {
R result = init;
for (T value : coll) {
result = func.apply(result, value);
}
return result;
}
Re: (Score:2)
There's nothing complex in adding a type parameter in angular brackets.
Re: (Score:2)
Re: (Score:3, Informative)
Sun does not control the development of Java, the Java Community Process does. And it is not C# that is seen as a threat I believe, but Ruby and functional languages. There is a VERY heated debate in the Java community over the new language features that are proposed for the Java platform, and both sides put up some very convincing arguments (simplicity is good vs a language needs to evolve
Re: (Score:3, Interesting)
And you can justify to your boss spending weeks implementing your own collections framework to save a whopping 50 ms of processing per day? To say nothing of the ramp-up time required of the poor schmuck who has to maintain code that uses your w
Re: (Score:2)
Exactly. Since I've met Python I can't help not thinking it is the VB killer.
What creates a lot of problems for the language on my point of view, but I was never the target audience of any of those languages.
Re: (Score:2)
Every time you layer one thing on top of another, you generally get a performance hit. If the lower layers are poorly implemented, or rather they have not been given the sort of attention they need for their purpose, then building on top of them is like building a skyscraper on a foundation that is designed for a single stor
Generics, jeez (Score:2, Interesting)
Java has come a long way but there's still a reason Java programmers cost about 60% of the cost of actual C++ progra
Two words: Type erasure (Score:5, Informative)
Among other hiccups this makes it impossible to overload methods whose argument types differ only in the parametric information included with them.
By contrast, C++ templates and C# generics create a type disjoint from all other types in the same type class for each set of parameters in the type declaration.
Yet another sterling example of Java lossage.
Two words: Bracket erasure (Score:5, Informative)
So List<String> and List<java.math.BigInteger> and List<javax.swing.JComponent> all compile down to the same type: List.
Re: (Score:2)
Re: (Score:2)
C++ has that problem, but Microsoft was a bit more efficient with that in .Net. It tries to share code wherever possible.
For structs and values, code is generated per-type. Thus, there are separate code blocks for List<int> and List<DateTime>, but multiple List<int> instances will share code.
For classes, all instances share one single code block. Thus, List<LeftHandedScrewdriver> and List<SelfSealingStemBolt> share code.
Re: (Score:2)
I don't see any reason to consider the Java approach superior. The backwards compatibili
Re: (Score:2)
Java-only programmers? (Score:3, Insightful)
Enumerations are available in Pascal and pretty much all of its descendants IIRC. It's also a type of field in an SQL database for much the same purpose as enumerations in programming languages.
The foreach loop has been in Perl since 2.0 in 1988. C# got foreach in 2000. It's in PHP. It comes from earlier FOR..IN loops from shells.
I'm sure there are examples of the other features which are similar to the Java version of them. The syntax may be different, and the exact details of darker semantic corners may be different. The concepts, however, are pretty easy to have run across unless someone has only used the one language.
The review seems to imply that bringing in what has been proven to work well in other languages is too confusing and should be done at a slower pace. The truth is, people program in a subset of any general-purpose language at first, and that subset grows over time. If someone works with code from other programmers, one picks up the parts of the language to which they are exposed as they are exposed to them. No one needs to cram all night to be up on all the new features of a language the day after the manual gets updated.
warning: nitpicks ahead (Score:2, Informative)
*prepares to be modded troll*
People need to stop comparing Java/C# generics to C++ templates - they take similar syntax, but they aren't the same thing. I'm not sure how one can even be safer than the other.
And C# 2.0 maintained compatibility with existing C# 1.0 code (you still have access to the old containers) while actua
Re: (Score:2)
Java One session (Score:5, Informative)
I agree with reviewer, the book is very good. It is true that Java generics is a compile time check, and that the generics information is removed (erasure). Nevertheless, that was a deliberate tradeoff for backwards compatibility, and it still makes coding complex Java a lot safer and easier. Look for instance at the 1.5 and 1.6 improvements to the concurrency libraries [sun.com] with Future, Callable and Executors.
Poppycock (Score:2)
Java 5 SCJP (Score:2)
Re:C# compatibility? duh... (Score:5, Insightful)
On topic, C# 2.0 was introduced with
Re: (Score:2)
There is nothing wrong with offering compatibility. Microsoft's approach to compatibility needs to change a bit. Separating the legacy system from the modern system should be more exact like Classic support in OS X (pre intel). Really old apps ran in a sandboxed
Re: (Score:2)
This is what makes it so utterly astounding to me that a great many of the standard libraries that Microsoft pushed on everybody for
They didn't even bother with a deprecation phase - just gone.
So not only will code compiled for
You have to manually check which version you're running and run diffe
Re: (Score:2)
Re: (Score:2)
The sad part of this story was that the pursuit of a better OS was scrapped. Longhorn was more than a mere codename; it was a radically different vision than what Vista ended up as. I can only imagine the frustration at Microsoft as they had to make that decision. They
Re:C# compatibility? duh... (Score:5, Insightful)
Are you joking? I hope you're joking. Because the alternative is that you are being criminally thick. I really think Slashdot should have a mod option -1 Misinformed
Say what you will about Microsoft, but backwards compatibility has always been one of their cornerstones. Their compatiblity layers still allow you to run apps from the early 90's on a modern copy of Vista today. I have managed to get some very old VB3 code working with a minimum of modification on VB6, which then, using Project Analyzer, got compiling in
And who are you comparing them with? Linux? You must be joking. Linux has trouble (read: is completely unable to) maintain binary compatibility with even relatively recent "old" code because of changing libc versions, etc.
Please, name ONE other operating system out there that can claim to run decade-old binaries flawlessly in its most recent incarnation.
Disclaimer: I'm a dedicated FOSS user and not a Microsoft shill in any way. But please, let's give credit where credit is due.
Re: (Score:2)
Re: (Score:2)
PS, you said "Linux" when you meant "GNU/Linux". AFAIK the kernel ("Linux") takes backwards-compatibility pretty seriously... obviously that's only a small part of the puzzle, the rest is up to the various distributors.
At the end of the day, does it matter? If you have the source to the programs you run then you can always update them to work with newer systems. If not then, well, that comes with the territory.
Re:C# compatibility? duh... (Score:5, Informative)
The code is riddled with conditional paths for different OS versions. Testing across windows versions was a nightmare.
I suggest it's you who is being criminally thick.
And modded up, too (Score:2)
Re:C# compatibility? duh... (Score:4, Informative)
Re:C# compatibility? duh... (Score:4, Informative)
Re: (Score:2)
Re: (Score:2)
Uhm, how did this get modded up? Backwards compatability isn't referring to running multiple JVMs. It's referring to the fact that you can write new classes that use generic types and methods, and those classes are still byte code compatible with pre-generic classes. This is because the type checking done by generics is compile time only - typing info is removed from the
Re: (Score:2)
Re: (Score:3, Interesting)
It's impossible to do in C#/C++.
Re: (Score:3, Interesting)
If you're maintaining an existing Java application, it's not likely that you're going to rewrite it in C# anyway. If you are starting from scratch without any commitment, I think C#'s approach to generics is better (I'm just talking about this particular issue, I'm not saying that C# is better than
Re: (Score:3, Insightful)
Whether that is a useful compatibility mechanism or a fundamental weakness in the type system that defeats the entire point of generics is left as an exercise to the reader.
Re: (Score:2)
Whether that is a useful compatibility mechanism or a fundamental weakness in the type system that defeats the entire point of generics is left as an exercise to the reader.
Re: (Score:2)
If your code uses Java 5 features then it won't run on JDK1.4. You can use tools like Declawer or Retroweaver to run 1.5 code on 1.4 but only to a certain degree.
Re:C# compatibility? duh... (Score:4, Informative)
Your wrong. Or at least when it comes to Generics (I haven't tested the rest). Everything is done at the compiler level. So even if you use Generics the code is changed to work in 1.4 if you set javac -target 1.4.
Re: (Score:3, Informative)
As soon as you use a generic, the Java compiler requires -source 1.5 and -source 1.5 requires -target 1.5 or higher. So -target 1.4 won't work, even though theoretically generics needn't require 1.5 binaries as all the checking is done at compile-time.
Re: (Score:2)
Re: (Score:3)
Re: (Score:2)
Which happens seldom, because by default the JDK will output a classfile version that older JVMs will refuse to run. People compiling for retrograde targets usually use a JDK from that version too, otherwise they could inadvertantly target standard library API's that don't exist in older versions. Java could make non-erased generics in the future too, just by way of changing the classfile
Re: (Score:2)
For example, you want a class that contains a list - you get to look forward to either (a) reams of boilerplate code as you forward all the methods of the list that an outside user might need, or (b) publicizing the list and completely mucking up your class invariants.
Plus, no typedef, so get, nested> class, declarations> - twice if yo
Re: (Score:2)
Re: (Score:2)
Heh... Now you just have to get operator overloading and type inference, and you'll be able to write
like those of us with real programming languages.Re: (Score:2)
Re: (Score:2)
The hope that deprecated will never happen.
Re: (Score:3, Informative)
As for metaprogramming - you can look at Nemerle (http://nemerle.org/Main_Page) which excels at metaprogramming. It's one of the best languages I've seen.
But there's research in bridging the gap between databases and code - see http://en.wikipedia.org/wiki/Language_Integrated_Q uery [wikipedia.org] for an example.
Re: (Score:2)
Unfortunately, lazy or newbie programmers will use autoboxing and varargs more than just sparingly and being the second generation coder on a project where these features are used liberally is
Re: (Score:2)
Generic code is much easier to maintain and read because you have MORE type information. Another changes like foreach loop and varargs are just syntax sugar and do not deserve more than a few minutes of attention.
Re: (Score:2)
You know, one of the biggest critisisms of classic VB was always that it only had interfaces and libraries, and not real implementation inheritance.
I think what I'd like to see if for polymorphism to be done entirely with interfaces, and for implementation inheritance to be supported, but hidden from client code.