4 ms·
I have absolutely no idea how many people might share print screens of their code, and how often some beast looking at these images might, because of that, find
by woolion 3y ago
I have absolutely no idea how many people might share print screens of their code, and how often some beast looking at these images might, because of that, find a way to discover how to type a similar looking symbol in unicode, enter it in their editor, and compile it without error, therefore introducing a subtle bug.
Luckily I rarely share my code through pdf, but mostly through git. Therefore, that hypothetical beast will read the code through its own editor, so the risk is mostly avoided. There is still the risk that this beast might appear behind my shoulders, see the pretty symbols and start that process anyway, but I have no idea how often that might happen too.
It's a weird thing that this beast can do such an elaborate process, but not ask a question about what the symbols are.
For better arguments, there's a long history of problems with programming languages that use non-ASCII symbols as default, and it has been considered a mistake.
That crazy idea of 'letters' that look alike and thus introduce bugs is much worse with unicode than ligatures:
>>> a = "hello world"
>>> b = "hеllо wоrld"
>>> a == b
False
Example from "Unicode text spoofer":
>This browser-based utility fakes regular characters in text and replaces them with Unicode characters from other alphabets. The text that you paste or enter in the input text area automatically gets all possible characters replaced with Unicode homoglyphs in the output. You can spoof letters, punctuation marks, spaces, and even insert zero-width spaces between individual symbols.
Now imagine instead of doing this, you use hello_world as variable name. You can thus interleave use of different variables that look alike, and have really buggy code.
Last argument, which is the one most important to me. Typing <= or != is ugly as shit.
That is not how these symbols are supposed to look like, it's just a practical kludge.
Ligatures are a simple solution to have both, that do not require a revolutionary way to change programming languages, and only engage yourself.
To share print screens of code without ligature maybe configure a second editor with another font. That does not sound really hard...
- eviks 3y agoYou don't kill good design just because it can be misused, you improve tooling design to deal with misuse For example, the text spoofer issue can be resolved in the text tools, like having variables with different names can be colored differently (this coloring scheme is better than having color just denote variable even without spoofing as it allows you to catch typos easily) Also you can have zero-width spaces highlighted
- blep_ 3y ago> having variables with different names can be colored differently This, too, is entirely personal preference. I've tried it and found it resulted in too many colors for my brain to assign individual meanings to, and then I couldn't even benefit from syntax highlighting anymore because those colors also blended into the rainbow of text.
- eviks 3y ago> entirely personal preference The differentiation benefit is not. Personal preference is what tool you choose to deal with spoofing, eg, you could also use a different font for different symbol ranges instead of colors. > I've tried it and found it resulted in too many colors for my brain to assign individual meanings to Well, you don't assign individual meaning to individual colors, but to color ranges which a given type can vary over. For example, going from green to yellow could be the range for variable names, so you associate that range with variables Which color ranges have you tried?