Re: NScollections vs Java collections
Re: NScollections vs Java collections
- Subject: Re: NScollections vs Java collections
- From: Jérémy DE ROYER via Webobjects-dev <email@hidden>
- Date: Sun, 2 Feb 2025 11:18:37 +0000
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ingencys.net; dmarc=pass action=none header.from=ingencys.net; dkim=pass header.d=ingencys.net; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Qx1Fdgk7TQRUrSo1Zo+2FmfxiGXz7TXP8ME0V9fRKqU=; b=IZJLP8PbsLBRkh1n0LwOGNgbiPGNuFscKl1SqnHAPa2Qhh/AKsMGMrXTf8E9O9ERRfIspoWV1Qsj9lyEU0UgLmXBbh9E1Di9mv8/hHHbeu5DP1S2Ya9aqEWCLGBIoDbWBlLANF5C83/2gmNv44M76VLv0K+k64mk4mw9+M2ezXJ6U0uDFr0ku3vGXQpyilzlG8bgQ/jYLLsQ8RsV/GHuTJy78klcSyHudNkMAXgJlIXeamAbr2GZ62MM+upAWiZUuZx2rJuU9kmYects4478TWTpLGvBESIC4nQjWyKDS0NeeVLDB9a0Yf7/nLQEErJkpabPwAPHgHpa/jxYqKgJ8g==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lshqwhk/Rv5GqceKKlWUjTQqJqUgwOxfmR+NZDON3Qz3jphBmafg9YE4UHYu739s6jAmUnsN0p5PydMppqMTRnQeYMDln3rilCWGHZIGjz73ScCgbyV9EvXEteiW5lv1i03oaw2ba/YzyAqFK9vb+SiTfpwspJK9EkCFKwM6HaOrX8F9Vom5kLqoFwgDyh+1YtI0lpGlItuP9Y83XYbmq/80qKqJCw4Fd3g+u7uI5ohn/Iy30thIrwMjhGPHgswGow6lzqmxKYo5yO4jTub043LT6qXUJXxBaqRis1lkO7ORWpI+LpV2AkpnmhvKxNkmFzo/f51p/HK1Lkk1Styfcw==
- Thread-topic: NScollections vs Java collections
Hi all,
Even if I still use EOF (due to inheritance limitations of Cayenne), I followed
Hugi’s precepts :
- « use 100% java native whenever possible »
One other advantage when working in a team… is that 100% java is widely
documented and exampled... and it's more attractive to newbees.
Sorry if I don’t « really » answer the question 😄
Jérémy
Le 2 févr. 2025 à 11:13, Hugi Thordarson via Webobjects-dev
<email@hidden> a écrit :
When I made the switch to Java collections I did do some benchmarking. Haven’t
got the code anymore (this was a decade ago) but at that time, the Java
collection classes were faster, but the operations were really so fast in both
cases that the differences were negligible — at that time.
Since then, a decade of improvements has happened in the Java collections so I
think we can guess where you’ll find performance improvements — and will keep
getting performance improvements. On one hand you have old classes written in
an old version of Java, on the other hand you have actively maintained open
source classes used by millions of programmers and maintained by the
performance-obsessed authors of Java and the JDK itself.
And now for the opinion piece:
Unless you’re writing extremely performance-sensitive code — even if the
foundation collections were faster I think it makes sense to use Java
collections and write to the standard Java collection APIs where you don’t
*need* foundation collections, because If you’re using foundation specific
APIs, your code is really already obsolete at the time of writing. I never
regretted the switch and have hardly seen an NS* collection class in my code in
years, except where explicitly required as a parameter for passing into WO
APIs. (that story may be a little different if you’re using EOF which uses the
NS collections everywhere, so this may not apply in that case).
The Java collection classes do have their warts, the most obvious one to us
coming from the NS* world being the non-API-differentiation between mutable and
immutable collections (weird design oversight) but that hasn't plagued me,
really. It’s just something you’re aware of and don’t really hit often.
Another one for us WO users is that you can’t use KVC operators on Java
collections (someArray.@sortAsc, .@sum etc). When I made the switch I always
thought I’d miss these hugely and planned to write operator support into
ERXComponent’s valueForKeyPath(), but never got around to it since I really
didn’t miss the operators, preferring to keep my logic in Java rather than
templates (compile time errors and refactoring support are awesome things).
Probably just saying things you know — but I thought it might have some value
hearing from someone that moved to Java collections and doesn’t regret it.
Cheers,
- hugi
On 2 Feb 2025, at 00:29, ocs--- via Webobjects-dev
<email@hidden<mailto:email@hidden>> 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<mailto:email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list
(email@hidden<mailto:email@hidden>)
Help/Unsubscribe/Update your Subscription:
This email sent to
email@hidden<mailto: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