# Unicode: a bad idea, in general

**URL:** <https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897>\
**Category:** General Usage\
**Created:** [June 5, 2023, 3:25pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897 "2023-06-05T15:25:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [June 5, 2023, 3:25pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/1 "2023-06-05T15:25:07Z")

</div>

![image](https://global.discourse-cdn.com/julialang/original/3X/b/d/bdc70683e6800cef24afac67116a7b20eb587b19.png)

Can you find the \rho? And not confuse it with p?

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [June 5, 2023, 3:44pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/2 "2023-06-05T15:44:21Z")

</div>

As far as I can tell, using `l` is, in general, also a bad idea. Maybe the ascii alphabet should be pruned?

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [June 5, 2023, 3:45pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/3 "2023-06-05T15:45:15Z")

</div>

Haha, your crusade continues!

Perhaps this is a font problem, not a Unicode problem…

 ![Screenshot 2023-06-05 at 16.43.36](https://global.discourse-cdn.com/julialang/original/3X/0/c/0c5fe4c21d44265acfb60d750299a60e1a705f44.png)

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [June 5, 2023, 3:47pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/4 "2023-06-05T15:47:44Z")

</div>

I suggest removing `a` and `o` and `l` and `I` from the list of acceptable symbols. Probably best to also disallow `O`, `0` and `1`, too, just to be sure.

---

<div class="post-metadata">

**Author:** ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Post date:** [June 5, 2023, 4:09pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/5 "2023-06-05T16:09:29Z")

</div>

Not sure I agree. It also depends on what font you use.

I can clearly tell where the rho is. Also I would avoid `l` like others have said. Use `\ell` instead.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [June 5, 2023, 4:09pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/6 "2023-06-05T16:09:55Z")

</div>

> [@cormullion](#):
>
> Perhaps this is a font problem, not a Unicode problem…

Precisely, and there is very little control people have in general (github, vs your local editor, vs …).  
Meaning, potential for confusion is considerable.

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [June 5, 2023, 4:15pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/7 "2023-06-05T16:15:47Z")

</div>

We could introduce reasonable replacements, that are better to distinguish. `0` gets `🦄`, 1 gets `🌈`…? I am 🌈🦄🦄% in for that.

I think it is really a font problem, and maybe one solution is to either use `ρ` in a certain part of your code _or_ `p`, but not both (too close to each other).  
Or one uses speaking variables (instead of those from the paper) instead. Though for points `p,q` I also prefer to use p and q. But maybe the rho has a nice different constant name?

---

<div class="post-metadata">

**Author:** ![adienes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adienes/32/37459_2.png) [@adienes](https://discourse.julialang.org/u/adienes)\
**Post date:** [June 5, 2023, 4:20pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/8 "2023-06-05T16:20:49Z")

</div>

I usually write `cue` for `q` so as to disambiguate from `b,p,δ,9,d,σ,6,ρ,∂`. Although when writing multi-threaded code I am sure to instead use `queue` to stay on-theme.

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [June 5, 2023, 4:35pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/9 "2023-06-05T16:35:31Z")

</div>

For my case, UTF-8 is just amazing! I use it all the time with very good results.

For example, take a look at this equation used in the SGP4 orbit propagator:

 ![Captura de Tela 2023-06-05 às 13.30.55](https://global.discourse-cdn.com/julialang/original/3X/e/8/e8fd1e1ed0a04cd21857be881298360835d8fe70.png)

This is the FORTRAN implementation:

 ![Captura de Tela 2023-06-05 às 13.31.25](https://global.discourse-cdn.com/julialang/original/3X/7/5/752397c463362bb845486e476ed4781363626ba8.png)

This is the Julia implementation full of UTF-8 symbols:

 ![Captura de Tela 2023-06-05 às 13.31.48](https://global.discourse-cdn.com/julialang/original/3X/9/3/93281e2c3ab06e2843fdcf8017b4afed08b91097.png)

You can see how close we can make the programming language to the mathematical notation. It turns out that it greatly simplified debugging and reduced the errors. I try to avoid, however, UTF-8 symbols in the API (like in keywords) but I am also starting to change my mind even in this point.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [June 5, 2023, 4:48pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/10 "2023-06-05T16:48:48Z")

</div>

Why aren’t you using `nll₀` instead of `n₀′′` or `n′′₀`? (`′` is `\prime`)

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [June 5, 2023, 4:51pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/11 "2023-06-05T16:51:41Z")

</div>

I think your last point is the important one:

For a script you are running, this is totally fine - maybe provide enough reference where the notation is from (i.e. the paper) then it should be fine.

For an API, e.g. keyword arguments, I think this is not too much recommended, unless really well documented. One might tend to obtain “magic-symbols” otherwise, that you have to learn. Speaking keywords are then (often, not always) better.

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [June 5, 2023, 4:55pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/12 "2023-06-05T16:55:34Z")

</div>

This seems like style guide material

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [June 5, 2023, 4:58pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/13 "2023-06-05T16:58:31Z")

</div>

For me being able to write `\rho` and it renders as ρ in Julia code is really a Godsend. When working with equations based on physical models, where each variable has a symbolic but also physical meaning, equations just stand out so much clearer.

Being able to look at the equation in paper and find it very faithfully represented in Julia code is so helpful for not losing touch with the physics. And I also like 🌊 for when I write some code using waves etc. 🙂

I think it is really a nice to have and there is no reason to remove Unicode.

Of course bugs, issues, misunderstandings can occur, but they can also happen without it. I have not heard of any terrible example as of now where not being able to spot a rho, leads to 1 month of debugging etc.

Kind regards

---

<div class="post-metadata">

**Author:** ![The\_Mastermage](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/the_mastermage/32/49444_2.png) [@The\_Mastermage](https://discourse.julialang.org/u/The_Mastermage)\
**Post date:** [June 5, 2023, 5:29pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/14 "2023-06-05T17:29:45Z")

</div>

The problem described here is, not inherent to the Julia language but a problem inherent to physics and math in general. Where you often have the problem of not being able to easily distinguish certain letters. Especially when it comes to handwriting aswell. Just as an example we would often write Poisson Brackets {} with the Greek letter Xi. If you have ever written that by hand you will quickly see how fast the Xi deterioates into some weird squiggle. Similar things with i and j when written as subscripts.

There is no inherent solution to this problem that is not going against the established practices in Physics and Maths. So the best way is imo to try and avoid where reasonable and otherwise just always make sure you know that there are easily mistakable variables. Possibly use a subscript on one of them.  
Otherwise @Ronis_BR has the best explanation for why this is a good feature in general.

---

<div class="post-metadata">

**Author:** ![lostella](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lostella/32/356_2.png) [@lostella](https://discourse.julialang.org/u/lostella)\
**Post date:** [June 5, 2023, 7:07pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/15 "2023-06-05T19:07:18Z")

</div>

I think the issue has little to do with Unicode symbols, and more to do with single-letter variable names. It is of course tempting to write (say) `\gamma` to indicate that stepsize parameter: it’s so close to the math equations in that one paper describing the algorithm! Except, maybe, that other paper uses `\alpha`… then maybe `stepsize` is a better name after all 😕

I am guilty of these mistakes myself, but the more I read code, the more I’m convinced that it should not necessarily look like “the math from the paper”: the math from the paper has the whole paper around it, providing context to the symbols. Code usually doesn’t, and expecting it to be readable when sprinkled with `a`s or `\alpha`s is a bit too much for me.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [June 5, 2023, 7:10pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/16 "2023-06-05T19:10:42Z")

</div>

> [@Ronis\_BR](#):
>
> take a look at this equation used

I know what you are saying, but part of that mess in Fortran is just Fortran being Fortran (`2.0d0` instead of `2`). And it still takes five lines in Julia compared to six in Fortran. Breaking up the expression might be a good idea anyway.

In short, I believe there is virtue in avoiding fancy symbols, which may or may not end up being displayed correctly. Just a short while ago, there were still places in the PDF documentation of Julia where Unicode symbols were either unrecognizable or entirely missing…

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [June 5, 2023, 7:12pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/17 "2023-06-05T19:12:23Z")

</div>

> [@Ahmed\_Salih](#):
>
> write `\rho` and it renders as ρ in

I am not convinced. Just to type the thing I have to employ four keystrokes instead of three. And, auto-completion does not work for \rho…

---

<div class="post-metadata">

**Author:** ![mkoculak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkoculak/32/28310_2.png) [@mkoculak](https://discourse.julialang.org/u/mkoculak)\
**Post date:** [June 5, 2023, 7:23pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/18 "2023-06-05T19:23:19Z")

</div>

That would actually make a nice feature for the REPL and VSCode extension, if one could toggle the unicode and `\symbol` representation of code.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [June 5, 2023, 7:26pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/19 "2023-06-05T19:26:37Z")

</div>

if that’s bad, I invite you to see:

![image](https://global.discourse-cdn.com/julialang/original/3X/2/3/23f864ec4e569b12798a9a68f2a4c3405bb1f858.png)

(idk if it’s bad but I certainly don’t want to make my pkg impossible to contribute to for outsiders due this, it’s not the hill worth dying on)

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [June 5, 2023, 7:46pm UTC](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897/20 "2023-06-05T19:46:57Z")

</div>

> [@lostella](#):
>
> then maybe `stepsize` is a better name after all 😕

But this is picking one of the best possible cases for using fully-written-out variable names. `stepsize` is short and sweet, and likely to be used only a single place in your expression.

Often, variables have no clear ‘meaning’, as such, with any well-recognized, concise name. Which do you prefer of these two, for example:

```julia
tanh(β*d/2) / tanh(α*d/2) - 4α*β*k^2 / (k^2 + β^2)^2

```

or

```julia
tanh(square_root_of_wavenumber_square_minus_angular_frequency_squared_over_shear_velocity_squared * thickness/2) / tanh(square_root_of_wavenumber_squared_minus_angular_frequency_squared_over_longitudinal_velocity_squared * thickness/2) - 
4*square_root_of_wavenumber_squared_minus_angular_frequency_squared_over_longitudinal_velocity_squared*square_root_of_wavenumber_square_minus_angular_frequency_squared_over_shear_velocity_squared * wave_number^2 / (wave_number^2 + square_root_of_wavenumber_square_minus_angular_frequency_squared_over_shear_velocity_squared^2)^2

```

There are some other ways of doing this, but without unicode, most would probably opt for

```julia
tanh(beta*d/2) / tanh(alpha*d/2) - 4alpha*beta*k^2 / (k^2 + beta^2)^2

```

and that is less readable than the first, and no more explicit.

I think this is really quite simple: Use unicode symbols when it makes your code more readable.

[Next page](https://discourse.julialang.org/t/unicode-a-bad-idea-in-general/99897.md?page=2)
