3 ms·
> everyone else says "pshaw, anyone could have written that!" it really depends on the problem domain tho, doesnt it? Would you call the fast inverse square r
by chii 1y ago
> everyone else says "pshaw, anyone could have written that!"
it really depends on the problem domain tho, doesnt it?
Would you call the fast inverse square root[0] code good taste?
[0] https://en.wikipedia.org/wiki/Fast_inverse_square_root#Overview_of_the_code https://en.wikipedia.org/wiki/Fast_inverse_square_root#Overv...
- Etheryte 1y agoBeing a good fit for a given purpose doesn't mean that something is in good taste. That piece of code is very performant, yes, but I'm pretty sure none of us would want to meet it in code review, save for a few niche edge cases. To draw a parallel from fashion, for most part, arctic snow gear does not win fashion prizes, but it does keep you alive. There's a time and place for both, doesn't mean that everything useful is in good taste.
- AlotOfReading 1y agoWhat is "most" here? Traditional Arctic clothing (e.g. Inuit clothing) has huge fashion aspects. Being able to look good and stay comfortable in a blizzard are both important to many people in the far north. I highly recommend checking out the clothing and fur stores to accessorize if you're in an Inuit town with nothing but "purely practical" Western clothing. A fashionable design will improve both the look and the cold weather performance. This sometimes gets taken to the extremes of high fashion, like this design by an Inuit woman: https://vafashion.ca/pages/the-ukiaksaq-collection-nyfw-2020 https://vafashion.ca/pages/the-ukiaksaq-collection-nyfw-2020
- 01HNNWZ0MV43FF 1y ago> I'm pretty sure none of us would want to meet it in code review, save for a few niche edge cases. It does no I/O and has no action-at-a-distance. The float-long-float casts are the worst part. If a coworker brought it to me with a performance justification and some unit tests I'd be pretty happy to pass it.
- rapsey 1y agoOne is an algorithm, a purely technical solution. The other is the way code is structured in an application.
- RHSeeger 1y agoReally the post you're replying to should have been written the other way around Writing code that looks so simple, everyone else says "pshaw, anyone could have written that!" is good taste. Not all dogs are golden retrievers, etc
- peterfirefly 1y agoYes, but the "good taste" part lies mainly in three things: 1) recognizing that a reciprocal square root is more useful than an actual square root (and likely cheaper), 2) recognizing that full precision isn't necessary, 3) recognizing that one (or two) Newton-Raphson iterations is good enough with a decent starting approximation. The starting approximation is just magic.
- WalterBright 1y agoAs a young programmer, I would have also written the the function name "Q_rsqrt". As an old programmer, I would write "FastInverseSquareRoot()". It took a looong time for the penchant to write identifiers adhering to the FORTRAN limit of 6 characters to fade away. (Yes, I know Q_rsqrt is 7.)