# Warning against Unicode confusables

**URL:** https://discourse.julialang.org/t/warning-against-unicode-confusables/108734
**Category:** Internals & Design
**Tags:** unicode
**Created:** [January 9, 2024, 2:19am UTC](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734 "2024-01-09T02:19:49Z")
**Posts on this page:** 12
**Page:** 3

<div class="post-metadata">

### Author: ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)
#### Post date: [January 12, 2024, 7:24pm UTC](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734/41 "2024-01-12T19:24:29Z")

</div>

> [@Ininterrompue](#):
>
> and the \subset symbol, which, I know what the symbol is in isolation, but have no idea what it’s doing in this context.

There’s a mode to help find out what [this symbol](https://en.wiktionary.org/wiki/%E2%8A%91) actually is and what it is for. It’s easy to dismiss things as “unreadable” if one remains ignorant of the context, people have said the same about text written completely in ASCII.

```julia
help?> Core.Compiler.:⊑
  ⊑(𝕃::AbstractLattice, a, b)

  Compute the lattice ordering (i.e. less-than-or-equal) relationship between lattice elements a and b over the
  lattice 𝕃. If 𝕃 is JLTypeLattice, this is equivalent to subtyping.

help?> ⊑
"⊑" can be typed by \sqsubseteq<tab>

```

Understanding the context is vital, and writing in ASCII doesn’t magically make things plainer to understand. What does `f(x)` do?

---

<div class="post-metadata">

### Author: ![Ininterrompue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ininterrompue/32/5594_2.png) [@Ininterrompue](https://discourse.julialang.org/u/Ininterrompue)
#### Post date: [January 12, 2024, 7:27pm UTC](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734/42 "2024-01-12T19:27:58Z")

</div>

Even if I understood the context of the code, it really doesn’t help the readability point if I confused \subset with \sqsubseteq. It’s in the same vein as \rho with p, and many others, which, yes, does occasionally occur using ASCII characters, but occurs more frequently with Unicode given the vastly greater number of available symbols.

---

<div class="post-metadata">

### Author: ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)
#### Post date: [January 12, 2024, 7:36pm UTC](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734/43 "2024-01-12T19:36:48Z")

</div>

> [@Ininterrompue](#):
>
> Even if I understood the context of the code, it really doesn’t help the readability point if I confused \subset with \sqsubseteq.

I don’t think this in particular was an issue of readability or understanding context. I’m no mathematician and don’t know the type theory involved, but I for one can plainly see `⊂` (\subset) is round and `⊑` (\sqsubseteq) is square with an underline, these are nowhere near as similar as `p` and `ρ`. I’m just demonstrating ignorance is an opportunity to put in a little effort to find out a little more. If I already understood the context, I wouldn’t have trouble reading familiar symbols.

---

<div class="post-metadata">

### Author: ![Ininterrompue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ininterrompue/32/5594_2.png) [@Ininterrompue](https://discourse.julialang.org/u/Ininterrompue)
#### Post date: [January 12, 2024, 7:44pm UTC](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734/44 "2024-01-12T19:44:00Z")

</div>

Sorry, I meant \subseteq, ⊆ and ⊑ look similar, in fact I didn’t even know ⊑ existed. [This](https://www.reddit.com/r/math/comments/2dkijb/what_are_these_symbols/) reddit post which was second in the results list for “square subset symbol” also has this confusion. So, results may vary

---

<div class="post-metadata">

### Author: ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)
#### Post date: [January 12, 2024, 7:46pm UTC](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734/45 "2024-01-12T19:46:30Z")

</div>

> [@Ininterrompue](#):
>
> also has this confusion.

The question is “what are these symbols?” and the first sentence is “they look like subset, union and intersection symbols, but with straight lines”, so they in fact did not confuse them, for the same reason I wouldn’t confuse `u` and `v`.

> [@MilesCranmer](#):
>
> failed to render on my very modern MacBook Pro in Firefox:

Checking on a not-so-modern MacBook Pro in Safari, it renders just fine. You might have to change some Firefox settings to get more Unicode support. I don’t use Firefox so I can’t give any advice, but a Google search yields many user questions about Unicode rendering, hope some of those help. Also reminds me that Unicode doesn’t determine how the symbols are visually represented, that’s what fonts do (so it’s really their fault for confusion), and they don’t necessarily support all of Unicode.

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [January 12, 2024, 8:10pm UTC](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734/46 "2024-01-12T20:10:29Z")

</div>

> [@Benny](#):
>
> Checking on a not-so-modern MacBook Pro in Safari, it renders just fine. You might have to change some Firefox settings to get more Unicode support. I don’t use Firefox so I can’t give any advice, but a Google search yields many user questions about Unicode rendering, hope some of those help.

It’s not so much about operating system or app these days — it’s mostly about font coverage. I highly recommend installing [JuliaMono](https://juliamono.netlify.app), [Noto Sans Mono](https://fonts.google.com/noto/specimen/Noto+Sans+Mono?query=noto&classification=Monospace) and the terribly-ugly-but-super-comprehensive [GNU Unifont](https://en.wikipedia.org/wiki/GNU_Unifont) as a final failsafe — and then you’ll see no more ? boxes! Most systems gracefully fallback to a font that has the missing glyph, even going outside of the requested font face(s).

---

<div class="post-metadata">

### Author: ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)
#### Post date: [January 12, 2024, 8:47pm UTC](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734/47 "2024-01-12T20:47:06Z")

</div>

In VSCode, if you use a [unicode confusable](https://util.unicode.org/UnicodeJsps/confusables.jsp), it will highlight it in yellow. For example using `р (CYRILLIC SMALL LETTER ER)`, it shows

![image](https://global.discourse-cdn.com/julialang/original/3X/4/f/4fe3e899ffff6bc8aeb98918407cba18b9bf35d4.png)

You can disable highlighting for specific characters using `editor.unicodeHighlight.allowedCharacters` in `settings.json`.

---

<div class="post-metadata">

### Author: ![MilesCranmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescranmer/32/21070_2.png) [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)
#### Post date: [January 12, 2024, 9:34pm UTC](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734/48 "2024-01-12T21:34:05Z")

</div>

> [@stevengj](#):
>
> - In tutorial materials aimed at beginners, encourage people to be cautious about Unicode symbols. (You _should_ introduce them at some point, because people will see them in other Julia code, but make sure to emphasize that they are optional, and definitely don’t include them without explanation.) I recently submitted a PR to the _Think Julia_ book to correct just such an issue ([replace “🐢” with “turtle” in examples by stevengj · Pull Request #61 · BenLauwens/ThinkJulia.jl · GitHub](https://github.com/BenLauwens/ThinkJulia.jl/pull/61)), though I’m not sure when/whether it will be merged. Clarifying patches submitted to other tutorials might be helpful too.
> - Something in the Julia manual to emphasize this? A new FAQ, or edits somewhere else, a blog post? If you have a good idea for this, please feel free to submit a PR aimed at clarifying this issue to newcomers.
> - Maybe an addition to the [style guide](https://docs.julialang.org/en/v1/manual/style-guide/), suggesting that public APIs should typically be ASCII or have ASCII synonyms for accessibility. (Of course, people in specialized fields may choose to disregard this, just as people can disregard anything in the style guide if they wish.)
> - If there are isolated Unicode-only APIs in packages (i.e. some random little thing, not a package designed top-to-bottom to use Unicode symbols), a PR to add an ASCII symbol might well be welcome. (No, [`xor`](https://docs.julialang.org/en/v1/base/math/#Base.xor) doesn’t count here: lack of an infix operator ≠ lack of an API.)
> - Implement warnings about confusable symbols in linting tools. (I opened an [issue for Aqua.jl](https://github.com/JuliaTesting/Aqua.jl/issues/259)).
> - Others?

I think these are all great ideas! In particular I really like the ideas of updating the style guide, and putting this as a new check Aqua.jl as these would effect change at an ecosystem level to solve this into the future.

By the way, I wonder if there are any surveys which exist of programmers who are _not_ using Julia (to avoid survivorship bias) that ask them if (1) they have at any point tried to learn Julia, (2) what resources they looked at (or what the first application they tried was), and (3) why they didn’t continue to learn it. It would be great to carefully vet the resources that failed Julia converts have looked at first, or more generally what applications they have tried to build – to help identify and fix such weak points. I’m sure it would be a bit unexpected.

For me, I had heard Julia was very good at differential equations so that’s the type of library I checked out first. That’s basically what formed my introduction to Julia (in addition to the very very early chapters of the docs), rather than me reading much of the Julia docs at first (which honestly more came at an intermediate level, and explored via google searches) – and I stuck with it. But I wonder where new users are hitting a snag and leaving. It’s hard to infer all of this stuff based on what internet complaints focus on, but I guess that’s one such signal.

---

<div class="post-metadata">

### Author: ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)
#### Post date: [January 12, 2024, 11:40pm UTC](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734/49 "2024-01-12T23:40:05Z")

</div>

> [@stevengj](#):
>
> - Implement warnings about confusable symbols in linting tools. (I opened an [issue for Aqua.jl](https://github.com/JuliaTesting/Aqua.jl/issues/259)).
> - Others?

`JuliaFormatter` already features [formatting options](https://domluna.github.io/JuliaFormatter.jl/dev/#for_in_replacement) that help normalizing e.g `for` loops to consistently avoid using `∈` (or consistently use it). Maybe more formatting options could be added to e.g:

- replace `α` with `alpha` in tutorials (or vice versa if a unicode-hating developer wants to contribute to a unicode-loving project);
- replace `ϱ` or `⍴` with `ρ` (in complement to a linter, in order to help fixing confusions if/when they happen).

---

<div class="post-metadata">

### Author: ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)
#### Post date: [January 13, 2024, 1:48pm UTC](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734/50 "2024-01-13T13:48:28Z")

</div>

> [@MilesCranmer](#):
>
> My intuition is that P(hates unicode) \> P(likes unicode) among general programmers, but perhaps P(hates unicode) ~ P(likes unicode) among computational scientists like yourself?

I’d also expect a dependence of Unicode acceptance on age, with higher acceptance for younger people. Thus the problem with Julia acceptance by unicode haters might just disappear with time, as they slowly become less relevant.

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [January 13, 2024, 2:27pm UTC](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734/51 "2024-01-13T14:27:42Z")

</div>

I suspect it’s mostly a question of exposure, where people who have used greek letters extensively in their education or have a native language (or frequently used second language) which goes beyond ASCII are a lot more accepting of unicode. But maybe emojis will change the equation for English-only speakers over time.

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [January 13, 2024, 5:52pm UTC](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734/52 "2024-01-13T17:52:35Z")

</div>

This topic was automatically closed after 24 hours. New replies are no longer allowed.

[Previous page](https://discourse.julialang.org/t/warning-against-unicode-confusables/108734.md?page=2)
