[java] Using built-in vector / linked list vs. manual implementation

Started by
9 comments, last by sponge 20 years ago
quote:but im lazy so if it's not worth the trouble im not going to bother.

Go with the laziness instinct if you want to succeed as a programmer. You should not be thinking about writing your own collections until you have your program up and running correctly with Sun's implementations AND you have performance problems AND you have used a profiler to show that the data structures are causing the problems.

Heed the advice of computer science pioneer Donald Knuth "Premature optimization is the root of all evil". It's harder than it sounds, the biggest mistake newbies do are to over-design and waste their time on places where it doesn't matter. You must learn to trust the laziness instinct in order to become a truly efficient programmer.

Btw, the people claiming that getting rid of casts will make your programs faster have probably failed to follow the steps above, as most people who have actually profiled programs running on Sun's later VMs will tell you that the VMs are excellent at optimizing away the costs of casts.

quote: How can you possibly think that your own linked list would be faster? Please.

Linked lists are probably where he would have the best chance of achieving an improvement, because Sun's LinkedList implementation allocates a "list entry"-object for every object you store in the list. This extra allocation can be eliminated with your own structures, but should probably only be touched if it causes annoying garbage collection pauses as the allocation itself is quite fast in Sun's VMs.

[edited by - HenryAPe on April 18, 2004 4:09:00 PM]

This topic is closed to new replies.

Advertisement