News for hackers. Stuff that matters.
Re:Rust is a hard way to make a web API by hamandcheese on Friday January 15, 2021 @10:42PM (#25799825)
I’d love to understand the rationale for preferring extremely short variable names.
Re:Rust is a hard way to make a web API by dmlerner on Friday January 15, 2021 @11:40PM (#25800098)
I like short variable names - for variables used in only a short block of code. I like long variable names - for e.g. a field on a struct used all over a file, and certainly exported ones.

I think "Go uses single letter variable names" is not so true in practice. There's a balance, in every language, between when to use short and long names. Go's balance is tilted (a good bit) more towards short, but it's not a hard rule.

There's significant mental overhead in reading `numberOfSubprotosOnProto`, as well as time hearing it in my head. I'd rather see `n` declared, used a few times in the next <10 lines, and then disappear. If there's two similar concepts in the same function, use slightly longer names, sure. Certainly not m and n.

I think that's the same reason math tends to use single letter variables. "Taylor series are easy! Just memorize: 'f_series_degree(evaluation_point, expansion_point) = sum(derivative_order=0..series_degree, (evaluation_point - expansion_point)^derivative_order * f^{derivative_order}(expansion_point) / derivative_order!)'

No thanks, I'll take f_n(x, a) = sum(i=0..n, f^n(a)(x-a)^n/n!).

Re:Rust is a hard way to make a web API by franklyt on Friday January 15, 2021 @11:53PM (#25800155)
I don’t know if it’s ironic or not, but as someone not into mathematics, the first example is far more readable, and it’s not close.
Re:Rust is a hard way to make a web API by runald on Saturday January 16, 2021 @05:16AM (#25801341)
By readable, I think you mean you get to read some whole words thereby get the impression of better readability, but in actuality it doesn't not necessarily aid comprehension if you don't know anything about taylor series, or maths in general.

I'm not saying more descriptive variable names doesn't help, but saying that you are not into mathematics makes your point moot.

Re:Rust is a hard way to make a web API by franklyt on Saturday January 16, 2021 @10:17AM (#25802698)
But I know what an evaluation is, a point is, a degree is, etc. These words contain semantic data.
Re:Rust is a hard way to make a web API by tedk-42 on Friday January 15, 2021 @11:26PM (#25800028)
Single letter variable names are throw away variables which you don't actually care about except for maybe a line or so.

I think to use them when I'm trying to "show my working out" and it takes me back to algebra class days so I don't mind

Re:Rust is a hard way to make a web API by tempest_ on Friday January 15, 2021 @11:04PM (#25799918)
Gotta save those bytes
Re:Rust is a hard way to make a web API by justsomeuser on Saturday January 16, 2021 @09:26AM (#25802322)
Some people prefer lattes, some cappuccinos, but it's all milk baby.