Remix.run Logo
Index, Count, Offset, Size(tigerbeetle.com)
51 points by ingve 3 days ago | 11 comments
qouteall an hour ago | parent | next [-]

With modern IDE and AI there is no need to save letters in identifier (unless too long). It should be "sizeInBytes" instead of "size". It should be "byteOffset" "elementOffset" instead of "offset".

throwaway2027 17 minutes ago | parent [-]

Isn't that more tokens though?

0x457 9 minutes ago | parent | next [-]

Sure you get one or two word extra worth of tokens, but you save a lot more compute and time figuring what exactly this offset is.

Onavo 15 minutes ago | parent | prev [-]

Not significantly, it's one word.

wahern 2 hours ago | parent | prev | next [-]

Relatedly, a survey of array nomenclature was performed for the ISO C committee when choosing the name of the new countof operator: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3469.htm

It was originally proposed as lengthof, but the results of the public poll and the ambiguity convinced the committee to choose countof, instead.

dataflow 2 hours ago | parent | prev | next [-]

Is there any other example of "length" meaning "byte length", or is it just Rust just being confusing? I've never seen this elsewhere.

Offset is ordinarily just a difference of two indices. In a container I don't recall seeing it implicitly refer to byte offset.

SabrinaJewson 2 hours ago | parent | next [-]

In general in Rust, “length” refers to “count”. If you view strings as being sequences of Unicode scalar values, then it might seem odd that `str::len` counts bytes, but if you view strings as being a subset of byte slices it makes perfect sense that it gives the number of UTF-8 code units (and it is analoguous to, say, how Javascript uses `.length` to return the number of UTF-16 code units). So I think it depends on perspective.

AlotOfReading 2 hours ago | parent | prev [-]

It's the usual convention for systems programming languages and has been for decades, e.g. strlen() and std::string.length(). Byte length is also just more useful in many cases.

card_zero 2 hours ago | parent | prev | next [-]

I can't read the starts of any lines, the entire page is offset about 100 pixels to the left. :) Best viewed in Lynx?

zephen an hour ago | parent | prev [-]

The invariant of index < count, of course, only works when using Djikstra's half-open indexing standard, which seems to have a few very vocal detractors.

GolDDranks 3 minutes ago | parent [-]

Fortunately only a few. Djikstra's is obviously the most reasonable system.