Again, I was talking about a vector concept, not the java.util.Vector class.
But, a couple points of rebuttal are in order, so show that Vector is not defunct
- All programs I write a multi-threaded. True, one should use specific synchronization chokepoints, and not synchronise every little datastructure... But a lot of times, all that chokepoint does is add or remove items to/from a Vector (producer/consumer problems), so Vector still has some utility.
- A Vector will have less overhead than a synchronized List wrapping an unsynchronised List.
- Using a Vector gives the signature type that this is synchronised, whereas giving a List that happens to be synchronised does not have the same typing information. I don't mean some compiler thing, I mean that programmers can see at a glance that it's synchronised.
- Building on your point about old JVMs. Vector versus List is both a performance tradeoff and a compatibility tradeoff. Vector works everywhere and is a bit slower, and List works most places and is a bit faster. I will always take slower if it means that code can reach more people. Who knows what esoteric platform, with an old JVM, could benefit from running your app? I try to code to the lowest common denominator possible, because there's more profit in being able to sell to more people.
But, a couple points of rebuttal are in order, so show that Vector is not defunct
- All programs I write a multi-threaded. True, one should use specific synchronization chokepoints, and not synchronise every little datastructure... But a lot of times, all that chokepoint does is add or remove items to/from a Vector (producer/consumer problems), so Vector still has some utility.
- A Vector will have less overhead than a synchronized List wrapping an unsynchronised List.
- Using a Vector gives the signature type that this is synchronised, whereas giving a List that happens to be synchronised does not have the same typing information. I don't mean some compiler thing, I mean that programmers can see at a glance that it's synchronised.
- Building on your point about old JVMs. Vector versus List is both a performance tradeoff and a compatibility tradeoff. Vector works everywhere and is a bit slower, and List works most places and is a bit faster. I will always take slower if it means that code can reach more people. Who knows what esoteric platform, with an old JVM, could benefit from running your app? I try to code to the lowest common denominator possible, because there's more profit in being able to sell to more people.