Hacker News new | past | comments | ask | show | jobs | submit

Why is Git Autocorrect too fast for Formula One drivers?

https://blog.gitbutler.com/why-is-git-autocorrect-too-fast-for-formula-one-drivers/
> Originally, if you typed an unknown command, it would just say "this is not a git command".

Back in the 70s, Hal Finney was writing a BASIC interpreter to fit in 2K of ROM on the Mattel Intellivision system. This meant every byte was precious. To report a syntax error, he shortened the message for all errors to:

    EH?
I still laugh about that. He was quite proud of it.
loading story #42766270
loading story #42763731
loading story #42762887
loading story #42763751
loading story #42762437
loading story #42766765
loading story #42762889
The root cause here is poorly named settings.

If the original setting had been named something bool-y like `help.autocorrect_enabled`, then the request to accept an int (deciseconds) would've made no sense. Another setting `help.autocorrect_accept_after_dsec` would've been required. And `dsec` is so oddball that anyone who uses it would've had to look up.

I insist on this all the time in code reviews. Variables must have units in their names if there's any ambiguity. For example, `int timeout` becomes `int timeout_msec`.

This is 100x more important when naming settings, because they're part of your public interface and you can't ever change them.

loading story #42763395
loading story #42766627
loading story #42764837
I do that, but I can't help thinking that it smells like Hungarian notation.

The best alternative I've found is to accept units in the values, "5 seconds" or "5s". Then just "1" is an incorrect value.

That’s not automatically bad. There are two kinds of Hungarian notation: systems Hungarian, which duplicates information that the type system should be tracking; and apps Hungarian, which encodes information you’d express in types if your language’s type system were expressive enough. [1] goes into the difference.

[1] https://www.joelonsoftware.com/2005/05/11/making-wrong-code-...

loading story #42764071
Though, ironically, msec is still ambiguous because that could be milli or micro. It's often milli so I wouldn't fault it, but we use micros just enough at my workplace where the distinction matters. I would usually do timeout_micros or timeout_millis.
loading story #42769337
Shouldn't that be named "usec"? But then again, I can absolutely see someone typing msec to represent microseconds.
loading story #42769154
loading story #42770379
loading story #42765347
loading story #42765881
loading story #42768949
> Now, why Junio thought deciseconds was a reasonable unit of time measurement for this is never discussed, so I don't really know why that is.

xmobar uses deciseconds in a similar, albeit more problematic place - to declare how often to refresh each section. Using deciseconds is fantastic if your goal is for example configs to have numbers small enough that they clearly can't be milliseconds, resulting in people making the reasonable assumption that it must thus be seconds, and running their commands 10 times as often as they intended to. I've seen a number of accidental load spikes originating from this issue.

loading story #42762133
loading story #42761811
loading story #42762509
loading story #42762313
loading story #42766393
loading story #42761870
loading story #42761926
loading story #42761670
loading story #42761259
loading story #42761399
loading story #42761309
loading story #42762350
loading story #42760725
loading story #42762597
loading story #42765984
loading story #42770057
loading story #42770869
loading story #42764035
loading story #42767186
loading story #42772040
loading story #42761813
loading story #42767242
loading story #42762106
loading story #42771469
loading story #42761211
loading story #42771763
loading story #42761398
loading story #42761587
loading story #42762214
loading story #42765417
loading story #42763172
loading story #42763334
loading story #42761783
loading story #42763195
loading story #42761713
loading story #42764700