Live data from Hacker News

Trust your compiler: Modern C++

categorica.io

41–47 of 47 posts

Re: Trust your compiler: Modern C++

#41
post #28
post #18

Earlier quoted context omitted.

> even the best compilers don’t use a third of the opcodes our modern CPUs boast of That’s not necessarily an indication of the weakness of compilers. It also could be an indication that hardware designers could leave out instructions. X86, in particular, will have lots of them for backwards compatibility reasons (extreme example: the old 80-bit x87 FP stack) There also are instructions that are expected to never get…

x87 support may not be the most obscure part of the instruction set. Ther is also hardware support for BCD math in 16 bit amd 32 bit mode. Who uses that anymore?

bcd is a reasonable way to do fixed-point decimal arithmetic.

binary floating point, let alone IEEE, is almost useless for implementing decimal arithmetic.

Re: Trust your compiler: Modern C++

#42
post #7

Earlier quoted context omitted.

Quite funny comment on the vibe coding age.

Quit poking at the openbsd maintainers. Jokes aside (I mean maybe they are one I don't know), it is at least a coherent opinion that inherently complex but critical software infrastructure would ideally be kept as simple and understandable as possible with all the correctness and verification apparatus staying out of the way so you can see what is there to be backdoored. I use rust primarily and like using it, but th…

If I am not too mistaken, microsoft rust syntax is close to c++ brain damage one, namely it is the issue more than any solution. Not to mention the cost of its runtime.

Re: Trust your compiler: Modern C++

#43
post #33
post #28

Earlier quoted context omitted.

x87 support may not be the most obscure part of the instruction set. Ther is also hardware support for BCD math in 16 bit amd 32 bit mode. Who uses that anymore?

Unfortunately some exchanges (twse) uses packed BCD encoding.

BCD allows for insanely fast conversion to and from decimal string representation. And if doing arithmetic in it is only slightly worse than doing it in binary... it may actually be faster on the whole for some workloads.

Re: Trust your compiler: Modern C++

#44
post #30

Don't trust your compiler. Your code is only fast if you're lucky. https://tiki.li/blog/lucky_code.html

that's a nice example. on my M4, i measured 3.4s vs. 0.42s. honestly surprised there's ~10x improvement to be found.

as you've pointed out, you've literally micro-optimised this - isn't this what you'd expect? :)

Re: Trust your compiler: Modern C++

#45
post #33

Earlier quoted context omitted.

Unfortunately some exchanges (twse) uses packed BCD encoding.

BCD allows for insanely fast conversion to and from decimal string representation. And if doing arithmetic in it is only slightly worse than doing it in binary... it may actually be faster on the whole for some workloads.

But those instructions were dropped in 64 bit mode.

Re: Trust your compiler: Modern C++

#46
post #44
post #30

Don't trust your compiler. Your code is only fast if you're lucky. https://tiki.li/blog/lucky_code.html

that's a nice example. on my M4, i measured 3.4s vs. 0.42s. honestly surprised there's ~10x improvement to be found. as you've pointed out, you've literally micro-optimised this - isn't this what you'd expect? :)

But what is the resulting assembly? I would assume completely different!

Re: Trust your compiler: Modern C++

#47
I trust the C++ committee to introduce new features in the most convoluted way possible, then spend the next 20 years trying to fix it, while adding even more syntax that makes my eyes hurt.

Case in point: templates. They are essentially a pure functional programming language embedded inside C++, expressed in a verbose syntax that barely resembles the rest of the language, and somehow makes even Java look concise.

It has been a slow-motion train wreck, with one questionable design decision after another. And a perfect example of why design by committee often leads to unnecessary complexity.

Post reply on HN