8 ms·
I love how this shows some of the problems with unnecessary dependencies even back in 1995. Let’s say you really only cared about the sign of the result — free
by codeflo 4y ago
I love how this shows some of the problems with unnecessary dependencies even back in 1995.
Let’s say you really only cared about the sign of the result — freeing a resource when a refcount reaches 0 is a plausible use-case for that. But instead of using a single CPU instruction, you decide to link in a Windows function, because it’s easy, and why not pay for the overhead of a dynamically linked function call when CPUs are so fast?
And the joke is, when users upgraded to Windows 98, your program became a lot slower, because without asking you, the API was augmented to emulate a CPU feature you don’t need.
If this isn’t essentially 1995’s left-pad, I don’t know what would qualify.
- Arainach 4y agoWriting assembly isn't portable. Windows NT 3.1-4 ran on MIPS, PowerPC, and more. Intel was coming out with new instruction sets all the time.
- codeflo 4y agoNot sure why you mention Intel extending their instruction set, the addition of stuff like SIMD never changed the behavior of anything that existed before. Very few programs ran on non-x86 back then anyway. Some people used to argue that writing assembly is more portable than using OS functions. I’m not saying I fully agree with that view, but it’s a discussion one can reasonably have.
- Arainach 4y agoIntel was constantly adding new instructions which could be more performant. Inline assembly can never take advantages of that; compilers or OS functions can
- codeflo 4y agoTo be clear I understand you correctly, you think there was a chance that Intel would add a CPU instruction that is "more performant" than ADD? In fact, significantly so, to the extent that this would justify the overhead of a dynamically linked function call? Do I understand you correctly? (BTW, this is exactly the kind of argument people made in defense of left-pad, which in my view completely validates my analogy.)
- nyanpasu64 4y agoHopefully on Windows NT the function would be inlined into a single instruction, though I don't exactly have faith in pre-2000 compilers. I assume this would be less than practical on Windows 98 with its fallback path.
- codeflo 4y agoThe function is dynamically linked from kernel32.dll, compiler inlining is irrelevant here.
- codeflo 4y agoWow, that comment must have hit a nerve.