4 ms·
Blog author here! I read the source quite a few times. Almost every language has a dynamic array of some sort. They all do the same thing. They all have slight
by forrestthewoods 5y ago
Blog author here! I read the source quite a few times.
Almost every language has a dynamic array of some sort. They all do the same thing. They all have slightly different names. push / push_back / add / append. size / length / len / count. If you don't already know the name of a function then finding it is in a sea of text is very difficult and not fun.
Zig ArrayList: https://github.com/ziglang/zig/blob/master/lib/std/array_list.zig https://github.com/ziglang/zig/blob/master/lib/std/array_lis...
C++ Vector: https://en.cppreference.com/w/cpp/container/vector https://en.cppreference.com/w/cpp/container/vector
Rust Vec: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html https://doc.rust-lang.org/stable/std/vec/struct.Vec.html
Sometimes I just want to see a list of functions. I can skim a list of 40 functions in seconds. Scrolling 800 lines of code and trying to pick out every single function takes much longer and is much more error prone.
- mst 5y agoWhen I find myself in such a suboptimal situation, I tend to fall back to grep '^ *pub fn' <file> or equivalent for the language in question. A smarter approach would probably be a code folding plugin for my editor, but I tend to keep my editing environment deliberately stupid so I can spend my cognitive complexity budget elsewhere. (this is not to downplay your annoyance, just it seems worth mentioning that stupid problems often have stupid workarounds and I have lots of practice at being stupid ;)