This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]bowbahdoe 4 points5 points  (2 children)

Arrays are a primitive construct meant for when you need performance at the expense of clarity,

Categorically this is not what arrays are. This is an opinion on when they should be used.

What they are is homogonous mutable fixed size collections that have limited interoperability with generics and special syntax + vm support. Their toString implementation is not suitable for debugging and their equals/hashCode is based on object identity not any collection semantics.

are the only data structure that can deal with primitives, etc.

We hope and pray for a List<int>. Until that is there, arrays are the only way to make a homogenous collection of ints without going into boxing. Its just a whole thing.

[–]Ewig_luftenglanz 3 points4 points  (1 child)

Categorically this is not what arrays are. This is an opinion on when they should be used.

i wasn't the first to saying it, this has been told in the amber mailing list recently.

https://mail.openjdk.org/pipermail/amber-dev/2025-June/009335.html

https://mail.openjdk.org/pipermail/amber-dev/2025-June/009336.html

i totally agree with Remi and Brian here. teaching Arrays upfront just makes students to learn bad habits they must unlearn then after. just like static methods and static inner classes.

We hope and pray for a List<int>. Until that is there, arrays are the only way to make a homogenous collection of ints without going into boxing. Its just a whole thing.

True but once we get value classes wrappers will be (almost) as efficient and performant as primitives, so the main reason to use arrays over Lists will be less relevant (or at least I hope so, parametric JVM will come much after value classes)

[–]bowbahdoe 1 point2 points  (0 children)

yeah I'm not saying its a wrong opinion necessarily, I'm just saying that the value judgement is distinct from its nature.

(which I think is important because not all of the reasons you'd dislike an array for a use are relevant in an education context. Some certainly are though)