4 ms·
This is one of the things that I feel is an inappropriate abstraction that is around for historical reasons. When I do FFI to call C from rust, I usually wrap t
by the__alchemist 5mo ago
This is one of the things that I feel is an inappropriate abstraction that is around for historical reasons. When I do FFI to call C from rust, I usually wrap the generated API (Which is pointer based) into rust's &[] array syntax. Arrays/lists/Vecs etc in most non-C languages feel like an abstraction over a collection of items; I feel like C's exposing the pointer directly is taking a low-level memory/MMIO operation and inserting it into business logic. Conceptually, I like to keep them separate; pointers for writing drivers, accessing registers, writing to flash memory etc. Arrays/lists/vecs for higher level operations on collections.
Tangent: I have a pet theory that part of Zig's raison d'etre is to fix some of the problems with C, while accommodating its pointer-based data structures, and the resulting patterns.
- vulcan01 5mo agoThis talk – "Programming without pointers" – by Andrew Kelley may be interesting to you. https://www.hytradboi.com/2025/05c72e39-c07e-41bc-ac40-85e8308f2917-programming-without-pointers https://www.hytradboi.com/2025/05c72e39-c07e-41bc-ac40-85e83...
- throwaway27448 5mo agoLearning to program with pointers is enormously useful. It's simply bad software engineering to not use typing to enforce constraints on access to pointers (or addresses, or however you'd like to term them)
- doyougnu 5mo agoIIRC that talk of about using indices (u32) to represent data in an array. That is orthogonal to representing that information in the type system since you can just type the index
- deleted 5mo ago[deleted]
- throwaway27448 5mo agoHow do you distinguish the array from the index? Is an array not just a pointer and index description?
- codethief 5mo agoInteresting talk, thanks for sharing!