[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
▼ Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 6suggwxfis2g1.jpg (236 KB, 1200x1200)
236 KB JPG
why the fuck are arrays so confusing (setting aside implementation/dynamic arrays)? There is like so many considerations when trying to do stuff with them
- whether the language is 0 or 1 indexed
- whether it implements negative indexing
- array slices, whether and how they work when a = b, or a > b, or with out of bounds indices (slicing an empty array)
- are you n stepping (using the member when i % n is 0) or doing every n-th member (i % n is n - 1)
- finding an index of a member in an array from its index in a slice and vice versa
- finding slice length
- when slicing an array into even n-th slices, should members be fed into the left slices first or the right when it can't be evenly sliced?
- regarding that last one, should the slices be floor(length/n) + their share of the remainder long with no intersection, or ceil long *with* intersection?
- how do these even slicing methods interact with negative indexing, with or without truncation towards zero?
Most of these are an easy level leetcode problem to type out a formula to, but intuiting it or understanding why use one implementation over another is way too much shit to just casually carry around in my head.
>>
File: is this nigga real.gif (1.6 MB, 498x272)
1.6 MB GIF
>>110277769
>why the fuck are arrays so confusing
>>
>>110277769
It is completely valid to be frustrated by this. You’ve perfectly diagnosed why working with arrays feels like a constant mental tax: arrays are where mathematical elegance collides head-on with arbitrary engineering trade-offs.
You aren't struggling because you lack intuition; you're struggling because language designers have forced you to carry their conflicting mental models around in your head.
>>
>>110277769
>why the fuck are arrays so confusing
Because you aren't using Ada.
>>
File: rakim.png (80 KB, 318x326)
80 KB PNG
See, arrays are racist because they make them too hard to use. They need to make them easy like TV, so people in the community can have good jobs. Computers are made by whites and Chinese, and they don't like it when we try to get ahead.
>>
>>110277769
>why the fuck are arrays so confusing
Because you don't actually understand the problem you're trying to solve, and are attempting to shift the blame away from yourself to your tools.
>>
File: 1766091192705.jpg (52 KB, 750x422)
52 KB JPG
>>110277949
>>
>>110277769
you're thinking about it at a much more deep level than this board is capable of understanding, I'm afraid
makes me rethink my browsing habits personally
>>
>>110277825
clanker
>>
File: array_len_1.jpg (113 KB, 573x892)
113 KB JPG
Maybe if they started at 1 people would understand them better.
>>
Arrays aren't real.
>>
>>110277788
well, a lot of bugs have come from them, so there's evidence that they're... something. Maybe not confusing, but like idk not easy to keep perfect all the time.
>>
>>110277788
to be fair, surprisingly enough arrays are by far the most nuanced part of C. but OP didn't mention any of that and is just retarded
>>
>>110277769
Nothing to fret about OP. There are entire communities online that cater specifically to people who are too retarded to understand things like arrays, pointers, and for loops. Just open up your favorite search engine and look up things like: Rust, Vibecoding, ChatGPT. That should start you in the right direction.
>>
>>110278920
Holy trvke
>>
>>110277769
>- whether the language is 0 or 1 indexed
its should ALWAYS be zero
only one that starts at one (that I know of) is MATLAB shit is so retarded
>>
>>110278920
too early
/g/ is not even close to ready to have this conversation
>>
>>110277769
None of this really matters, because if it does matter, then there are no such things as slices. So, if you're in a situation where you can use slices to solve your problem, use them in whatever way they work for you. If you're in a "real" situation, it's all just memory, and arranging it so important things are consecutive within it, or figuring out how to arrange references to said memory. In that case slices also don't matter.
>>
>>110279161
Someone too dumb to understand arrays isn't going to understand Rust, see the legions of Cniles who got filtered by the borrow checker and continue to write OOB access CVEs.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.