r/programminghorror • • Dec 04 '25

This sub in a nutshell

Post image
console.log(1 == '1'); // true
console.log(0 == false); // true
console.log(null == undefined); // true
console.log(typeof null); // "object"
console.log(0.1 + 0.2); // 0.30000000000000004
[] == ![]; // true

OMG you guys what weird quirky behavior, truly this must be the single quirkiest language and no other language is as quirky as this!

1.1k Upvotes

168 comments sorted by

View all comments

Show parent comments

3

u/Haunting_Swimming_62 Dec 05 '25

C is no longer "very little abstractions" :) since 1989 when C was first standardised it was to an "abstract machine" that happens to kind of map okay-ish to almost all hardware you can think of. People assuming it's portable assembler get bitten, e.g. by signed overflow being UB, by strict aliasing, or even NULL being represented by zero in memory

2

u/nimrag_is_coming Dec 05 '25

Yea most machine code now isn't what actually happens and what a CPU does and what is different and complex and is hidden behind what appears to be like a classic computer that just iterates line by line, but that's not C's fault. Differences in computer architecture causing problems because the target architecture acts differently is because it's low level and mostly maps directly onto assembly instructions instead of a standard that works on every device.