3 ms·
> in modern languages the rule is generally to have fixed-size integers. Modern languages have unlimited size integers :-) "Modern" as in "since at least the
by mpweiher 4y ago
> in modern languages the rule is generally to have fixed-size integers.
Modern languages have unlimited size integers :-)
"Modern" as in "since at least the 80s, more likely 70s".
- fluoridation 4y agoGood luck using those to specify the data layout of a network packet.
- josefx 4y agoYou are supposed to stream your video data as base64 encoded xml embedded in a json array.
- mpweiher 4y agoWell, for that you'd probably use a specialisation of Integer that's bounded and can thus be represented in a machine word.
- fluoridation 4y agoAnd then you'll be wasting time marshaling data between the stream and your objects because they're not PODs and so you can't just memcpy() onto them.
- kuratkull 4y agoGood luck seeing your performance drop off a very sharp cliff if you start using larger numbers than your CPU can fit into a single register.
- mpweiher 4y agoWell, in those case other languages fail. Either silently with overflows, usually leading to security exploits, or by crashing. So in either case you are betting that these cases are somewhere between rare and non-existent, particularly for your core/performance intensive code. Being somewhat slower, probably in very isolated contexts (60-62 bits is quite a bit to overflow), but always correct seems like the better tradeoff. YMMV. ¯\_(ツ)_/¯
- josefx 4y agoHow many languages actually take advantage of the fact that they could get more performance out of "small" register sized integers? You tend to lose a lot of performance to arbitrary sized integers in most languages even if your inputs are small. > but always correct seems like the better tradeoff. Not if you are dealing with time constraints. Glitchy output isn't good, but locking up the system because some buggy code path is trying to allocate a 10 GB integer can be worse.
- mpweiher 4y ago> How many languages actually take advantage of the fact that they could get more performance out of "small" register sized integers? Er...all of them? I am not aware of one that uses growable integers as their default integer representation that does not use some form of tagged pointer optimisation. > Glitchy output isn't good Hmm...understating the problem here just a tad. "In 2021, they ranked 12th in the updated Common Weakness Enumeration (CWE) list of the most common flaws, bugs, faults, and other errors in either hardware or software. The team behind the list ranked integer overflows just after “Missing Authentication for Critical Function”, due to the severity and prevalence of integer overflows." https://www.comparitech.com/blog/information-security/integer-overflow-attack/ https://www.comparitech.com/blog/information-security/intege... > Some buggy code path is trying to allocate a 10 GB integer can be worse Hmmm...overstating the problem here just a tad. Not even sure how you'd manage that, given that that would be an integer with 4 billion digits.