ρ, σ := G[:32], G[32:]
Somehow much better than seeing "rho", "sigma". ρ, σ := G[:32], G[32:]
Somehow much better than seeing "rho", "sigma".For a start, I don't know how to type these on a keyboard.
Secondly, most people wouldn't know what these symbols are called. Granted, those looking at the code probably have a greater chance of knowing. But it isn't friendly code in my opinion. I think clarity is key, and "rho" or "sigma" are pretty clear.
Also, add in that there's a constant "n" and a constant "η". Just begging for confusion.
This code will be read many more times than it is written, and anyone auditing its correctness will be comparing against the spec.
If the variables are spelt out, then you have to do the mental (or otherwise) translation before you can compare the two, adding overhead. For comparing the symbols visually, you don't even need to know their names.
I'm as proud of my heritage as the next Greek-American, but just because mathematicians use unintelligible symbols in their manuscripts doesn't mean we have do the same thing in code. Let's prioritize comprehensibility and give variables meaningful names, instead.
Well, no, this was the main issue with homograph attacks in domain names [1] that brought us to the use of punycode in browsers [2]
In particular for a cryptographic library, I wouldn't want to constantly have to watch out for sneaky malicious variables put in the right place (e.g. try to compare visually the Cyrillic а, с, е, о, р, х, у with the ascii a, c, e, o, p, x, y (no, they're not the same characters).
EDIT: I realize that many programming languages today allow the use of unicode variables and I like that it's a possibility, it's just not the best when you need to be paranoid about the code
- [1] https://en.wikipedia.org/wiki/IDN_homograph_attack - [2] https://en.wikipedia.org/wiki/Punycode
You can learn how to do that, even find a way to type "sigma", but more importantly, it best benefits readers, not writers, so you don't need to learn to type it
> and "rho" or "sigma" are pretty clear.
no it's not, where would you get clarity from is all the clarifying literature for these notions use the actual math notation σ?
> "n" and a constant "η". Just begging for confusion
looks very distinct, one is obviously mathy, another isn't
How would you feel about adding acutes and cedilles to characters? It just adds complexity. Let's stick to the smallest common denominator.
Of the languages I've checked, Perl, Python, and JavaScript (in Chrome and Firefox) do not. PHP does.
> invalid character U+2081 '₁' in identifier
Though that's also not surprising given how poor overall Unicode support is
> invalid character U+2081 '₁' in identifier
But AutoHotkey does allow it
super² := 1, sub₂ := 2