Re: NScollections vs Java collections
Re: NScollections vs Java collections
- Subject: Re: NScollections vs Java collections
- From: OCsite via Webobjects-dev <email@hidden>
- Date: Mon, 3 Feb 2025 02:55:53 +0100
Thanks (to all who responded)!
I do use WOnder (is there nowadays any WO programmer who does not? Really?),
but still, self-evidently it makes sense to use Java collections primarily, and
go to NS-ones only when needed.
All the best,
OC
> On 2. 2. 2025, at 23:46, Ramsey Gurley <email@hidden> wrote:
>
> I believe the answer is highly dependent on whether you're using the NS
> collections from WebObjects JavaFoundation or the ones from WOnder. If I
> remember correctly, Anjo did a lot of work optimizing performance on the ones
> in wonder, making those much faster than the ones found in JavaFoundation.
>
> How do they compare to Java collections? It probably depends on what
> implementation you are using. Whereas NSDictionary is a sort of one size fits
> all, Java has LinkedHashMap, ConcurrentHashMap... all different
> implementations with different performance profiles. Is NSArray faster than
> List? Is the List a Vector, ArrayList, etc? And then what are you doing with
> the list? Are you doing a lot of inserts and removals, simply iterating the
> list, does it need to be threadsafe, and so on.
>
> As for what I use, I use whatever makes sense. To me, NS collections are just
> another implementation of Java collections, no better or worse. A lot of the
> WO API expects NSArray/NSDictionary, so I use those if I'm expecting them to
> touch WO code. If I see a private _NSThreadsafeMutableDictionary, I don't
> have any problem converting that into a ConcurrentHashMap which has nice
> methods like computeIfAbsent() which the _NS thing does not. When writing new
> API, I usually use the most basic Map/List/Set for method parameters these
> days unless there is something I need from a specific implementation like
> thread safety. For return values, I still like NS classes when I want to make
> sure something returned is considered immutable. I'm not aware of a standard
> Java collection which signals immutability in the type like
> NSArray/NSDictionary do. I'm sure there's a third party jar I could find and
> use, but why bring in another third party dependency if I already have
> immutable collections in WO?
>
>
> On 2/2/25 9:29 AM, ocs--- via Webobjects-dev wrote:
>> Hi there,
>>
>> did ever anybody tried some benchmarks to find whether it is better to use
>> WO collections (NSArray, NSDictionary...) as widely as possible (ie
>> essentially anywhere, unless one really needs to store nulls or can't do
>> without ConcurrentHashMap or so), or whether it's better to use standard
>> collections (List, HashMap...) wherever they happen to work properly (which
>> is surprisingly often, but not anywhere)?
>>
>> Are they roughly comparable, or are one or the others considerably better?
>>
>> Thanks!
>> OC
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden