Hacker News new | ask | show | jobs
by andai 10 days ago
Article says pointers and its are both just bitvectors, but doesn't explain what a bitvector is.

It seems to be a vector of bits? Except in practice, a bitvector is just an int where you're using the binary digits to store stuff? And you gotta use these awkward bitwise operators to actually use it? (Popular in 90s video games, to save RAM!)

Or was it another way of saying "ultimately it's the same pattern of ones and zeroes so you can do whatever you want with it as long as you know what you're doing" ?

4 comments

>ultimately it's the same pattern of ones and zeroes

Exactly. Much equivocation happens when talking about concepts and representation of those concepts. Numbers, bitvectors, pointers, ones-and-zeros, colors, characters, indices, enum values, and whatever all share the same representation. The author thought "bitvector" best represented the commonality (though it doesn't).

It got me wondering so I checked. According to Wikipedia [1], it's a contiguous sequence of bits.

I guess the point here is CPUs operate on groups of bits that are very localized spatially (physically).

[1] https://en.wikipedia.org/wiki/Bit

Yeah, “bitvector” implies individually addressable bits, which is something you most certainly cannot do with pointers. I think the term they were looking for was “bag of bits”, i.e. opaque. But even that only applies to void pointers, anything with a defined size has arithmetic semantics too.
> Except in practice, a bitvector is just an int where you're using the binary digits to store stuff?

I think he's trying to say it's just the opposite: an int is really "just" a bitvector, when it comes down to it, and you just happen to be using a constrained set of operations to emulate the behavior we expect of integers.