News for hackers. Stuff that matters.
Re:Tell HN: C Experts Panel – Ask us anything about C by Gibbon1 on Tuesday April 14, 2020 @08:16PM (#22873028)
I once did a stupid test using either a int or unsigned in a for loop variable the performance hit was about 1%. Problem is modern processors can walk, chew gum, and juggle all at the same time. Which tends to negate a lot of simplistic optimizations.

Compiler writers tend to assume the processor is a dumb machine. But modern ones aren't, they do a lot of resource allocation and optimization on the fly. And they do it in hardware in real time.

Re:Tell HN: C Experts Panel – Ask us anything about C by thaumasiotes on Tuesday April 14, 2020 @11:42PM (#22874286)
> modern processors can walk, chew gum, and juggle all at the same time

It's easier than it sounds. One of the major problems you usually run into when learning to juggle is that you throw the balls too far forward (their arc should be basically parallel to your shoulders, but it's easy to accidentally give them some forward momentum too), which pulls you forward to catch them. Being allowed to walk means that's OK.

(For the curious, there are three major problems you're likely to have when first learning to juggle:

1. I can throw the balls, but instead of catching them, I let them fall on the ground.

2. My balls keep colliding with one another in midair.

3. I keep throwing the balls too far forward.)

There's actually a niche hobby called "joggling" which, as the name implies, involves juggling while jogging.

Re:Tell HN: C Experts Panel – Ask us anything about C by saagarjha on Tuesday April 14, 2020 @09:50PM (#22873641)
> Compiler writers tend to assume the processor is a dumb machine.

A lot of C developers tend to assume the compiler is a dumb program ;) There are significant hoisting and vectorization optimizations that signed overflow can unlock, but they can't always be applied.

Re:Tell HN: C Experts Panel – Ask us anything about C by Gibbon1 on Tuesday April 14, 2020 @11:33PM (#22874233)
If C had real array types the compiler could do real optimizations instead of petty useless ones based on UB.
Re:Tell HN: C Experts Panel – Ask us anything about C by saagarjha on Wednesday April 15, 2020 @01:18AM (#22874772)
Fair, hence the push in many language for range-based for loops that can optimize much better.