News for hackers. Stuff that matters.
Re:Leaky Abstractions by an1sotropy on Wednesday June 02, 2021 @05:58PM (#27374525)
Another common leaky abstraction: floating-point numbers as an abstraction of the real numbers. It works nearly all the time, until you have to really know about numerical precision, or where a NaN came from.

https://www.johndcook.com/blog/2009/04/06/numbers-are-a-leak...

Re:Leaky Abstractions by kortex on Wednesday June 02, 2021 @09:14PM (#27376047)
Relevant: the list of integers you can convert to float, invert twice, and don't get the same number back.

https://oeis.org/A275419

Re:Leaky Abstractions by an1sotropy on Thursday June 03, 2021 @02:11PM (#27385194)
This is a treasure; thank you!
Re:Leaky Abstractions by chii on Wednesday June 02, 2021 @11:12PM (#27376842)
i wouldn't call floating point numbers an abstraction on real numbers. It's a representation - like char[] is a representation of strings, which is itself an abstraction used to manipulate human readable text!
Re:Leaky Abstractions by an1sotropy on Thursday June 03, 2021 @02:10PM (#27385175)
Read the link above about FP as a leaky abstraction of the reals; it explains it better than I can. FP is not really a representation of reals, because you can't represent the entire number line with a finite number of bits. It is a representation of a cleverly chosen subset of the reals, so well-designed that many people forget that they're not dealing with real numbers. That intelligent people can write code with FP values, operating on them thinking they are real numbers, and not knowing how FP works, and get programs that often do nearly the right thing, speaks to the success of FP as an abstraction. Understanding how things can go wrong is the leaks (like, non-associativity). I don't think people manipulating char[] representations of strings are ever at risk of forgetting that it's just an array of chars (they program with full awareness of the implementation), so it doesn't feel like there's much abstraction happening there. Other higher-level data structures for text manipulation probably do implement some useful abstractions; I haven't worked with those.
Re:Leaky Abstractions by chii on Friday June 04, 2021 @01:17AM (#27390832)
> I don't think people manipulating char[] representations of strings are ever at risk of forgetting that it's just an array of chars

and yet, when people start adding unicode text under this representation, and the program fails to work properly. Or when counting characters, and assume the glyph count would match the char array length.

or any number of other string issues.

Re:Leaky Abstractions by an1sotropy on Friday June 04, 2021 @11:22AM (#27394485)
yea good point. Unicode does overwhelm simplistic ideas about string representation. Love those grapheme clusters.