Sunday, June 14, 2009

Update - ArrayList is not a List

As Shog pointed out below, ArrayList is in fact an array. I did know that at one point, but I embraced typed containers from the moment they appeared, as I would hope most people did, and my experience with ArrayList for many years has been limited to saying 'why on earth do you use that ?' to people in forums. But, like the terrible MFC containers that were only written as a stop gap until they got STL, and yet so many shops forced their devs to use them, because 'we're a Microsoft shop', ArrayList is with us to stay, because it's part of the language, they can't remove it. Which is why we should have got typed containers in the first place.

But, even worse is that there was no list class in .NET 1.0. I can see how I forgot about this, it's really hard to believe. No list class ? How long could it have taken to 'whip one up' ? I realise that ArrayList is a name that came from Java, but, guys, steal the good stuff, not the bad. ArrayList is a stupid, stupid name for a container class, the benefits and pitfills of an array/vector class compared to a linked list are basically opposite ( which is also why both should be provided by any language released in the 21st century ).

I should mention, I set out to have a bit of content from the get-go, but I'm not claiming that MS has 365 bugs for me to report in a year, so although I have about 8 items queued up, rather than run out of steam, I am going to post roughly once a week, probably over my weekend. I do want to post with some gotchas that brought my Mac to it's knees this past week ( I do intend to post about anything where I know how to help someone fix something, Microsoft happens to be where I live, and so where I know of the most issues, but the Mac won't get off 100% scott free ), I may do that sometime this week, before a weekend post on a .NET or WPF bug.

2 comments:

  1. IMO the C# ArrayList is similar to List<object> which is implemented as an array; when capacity is exhausted a new array gets allocated, twice as large, and everything gets copied. They are not linked lists.

    ReplyDelete
  2. Really ? List<T> is not a list at all, but a vector/array class ? Is there a List class in .NET then ? Is it call Array or something ? :P

    ReplyDelete