I’d like to voice the contrarian opinion that, as someone who isn’t a mathematician, these symbols make the code look like gibberish to me. I had to squint to even see the circle on the end of the lollipop symbol, no way I’m not mistaking that for a hyphen. I don’t know the names for these symbols, so my brain has to 1) learn new images, 2) pattern match them throughout the code. I would be totally lost. If the code…
I agree. I read this line: > ∀ instead of forall, which is faster to input than the whole word. It reminds me of the idiom that code is often written once but read often, so one would want to optimize for readability and not fewer keystrokes. At least for production code.
Writing prettier Haskell with Unicode syntax and Vim
51–60 of 62 posts
Re: Writing prettier Haskell with Unicode syntax and Vim
#52[0]: https://espanso.org/
Re: Writing prettier Haskell with Unicode syntax and Vim
#53Earlier quoted context omitted.
Agree, there is definitely a trade-off, I certainly don't know how to input those characters quickly even if the author states it is faster in Vim and I am not a Vim newbie. Also, if you get a stacktrace in a log file, do they still print nicely? Do they still print nicely if I'm viewing that stacktrace on a build server's web interface? There are probably some number of utilities that this code is "viewed" by that d…
Honestly, I would have had this concern ~10 years ago, but it's 2023. Unicode is ubiquitous, to the point that you'd need to pretty aggressively go out of your way to find things breaking due to it.
Re: Writing prettier Haskell with Unicode syntax and Vim
#54I’d like to voice the contrarian opinion that, as someone who isn’t a mathematician, these symbols make the code look like gibberish to me. I had to squint to even see the circle on the end of the lollipop symbol, no way I’m not mistaking that for a hyphen. I don’t know the names for these symbols, so my brain has to 1) learn new images, 2) pattern match them throughout the code. I would be totally lost. If the code…
A solution to the problem if incomprehensibility is to use a plugin to replace the words. I use emacs prettify symbols:
https://emacsredux.com/blog/2014/08/25/a-peek-at-emacs-24-do...
Re: Writing prettier Haskell with Unicode syntax and Vim
#55Earlier quoted context omitted.
If you open any reasonable math textbook (except for maybe logic related ones), chances are, you won't see the ∀ symbol anywhere at all. It's often considered bad taste to write a symbol like this when you can just write "for all". The main obstacle in learning math comes from not understanding the background material enough and basically never from not understanding the notation.
And the notation are introduced to you gradually. Even books that do not have a chapter on the notation used, will have a reference page. If not, you’re not reading introductory material and some background is assumed.
This is a serious drawback to the traditional math notation: if you didn't come up along one specific educational pathway, it seems to be effectively impossible to work your way in and figure out what any of it means. You can't pronounce any of it, you can't look it up; even if you can work out the names of the symbols, they often mean different things in different contexts. It is a mess.
For many years now, the way I have ingested CS papers is to read the introduction closely, getting my head around the concept, then bail out once the inscrutable symbols show up and go find an actual implementation in some real, documented, parseable programming language - any one will do - from which I can readily infer what the rest of the paper was supposed to mean.
Re: Writing prettier Haskell with Unicode syntax and Vim
#56Does this mean I'm ready to embrace the use of mathematical notation via unicode glyphs in programming? No. I have a math degree and after dozens of university courses on math I've seen a lot of math notation. This notation uses a dizzying number of symbols across various mathematical disciples. LaTeX allows one to use any of 75 distinct kinds of arrows alone! Left, right, doubled, up, down, diagonal to the upper right, looped, long, bidirectional, harpooned, wiggly, maps-to, and so forth. That's just the arrows. Why does LaTeX allow typesetting with so many distinct arrows? Because mathematicians use them as distinct concepts.
I count 160 relational symbols available for use with standard LaTeX: less-than, equal, equivalent, congruent, subset, parallel, similar, approximate, the list goes on and on. See [1].
Mathematicians don't even use these symbols consistently. Consider the ubiquitous lambda, appearing all over in functional programming. Surely, the use of a lower-case greek lambda is prettier than spelling out the word 'lambda', but it may in many contexts not stand for an anonymous function. It's use as a symbol can also mean: wavelength of any wave, number of offspring, radioactive decay constant, occurrence density within a time interval, eigenvalues, charge density, Lagrange multiplier, empty string, and so forth. Wikipedia lists 24 distinct uses for lambda, [2].
Why do mathematicians, engineers, and scientists use so many different symbols? Because they are doing something fundamentally different with them than programmers. They use the symbols as abbreviations that will be understood by their audience, which might be students watching a lecture, readers of a technical article, or even themselves at some time in the future. The context in all of these uses is very different than the context of a program. The program must be precise and unambiguous, and the program may be one hundred times longer than a published math paper. For this reason, spelled out identifiers and keywords using standard ASCII glyphs are wordier and less "pretty" but are far more practical.
[1] https://www.cmor-faculty.rice.edu/~heinken/latex/symbols.pdf
[2] https://en.wikipedia.org/wiki/Lambda#:~:text=Lambda%20indica....
Re: Writing prettier Haskell with Unicode syntax and Vim
#57Earlier quoted context omitted.
If you open any reasonable math textbook (except for maybe logic related ones), chances are, you won't see the ∀ symbol anywhere at all. It's often considered bad taste to write a symbol like this when you can just write "for all". The main obstacle in learning math comes from not understanding the background material enough and basically never from not understanding the notation.
And the notation are introduced to you gradually. Even books that do not have a chapter on the notation used, will have a reference page. If not, you’re not reading introductory material and some background is assumed.
Even in our own field, Computer Science, there are too many confusing cases: Knuth uses |S| to mean the cardinality of set S, |f| to be the number of solutions when f is a boolean, |x| to be the absolute value of x, |z| to be the absolute value of a complex number, and |a| to be the length of a. All within the same book, TAOCP vol 4A Part 1.
Re: Writing prettier Haskell with Unicode syntax and Vim
#58Unicode in code might be what pushes people to consider variable-width font. Just look at the simple arrow in a text editor (hopefully the text filter on this website thinks this symbol is OK): → (U+2192 RIGHTWARDS ARROW). It’s tiny. And I notice that the author uses plain `->`. You do need at least an “em” width for that kind of symbol. But I wouldn’t want a normal variable-width font where colons are tiny and at-si…
Re: Writing prettier Haskell with Unicode syntax and Vim
#59It looks pretty but in all honesty I would quit my job if someone forced me to do this.
Re: Writing prettier Haskell with Unicode syntax and Vim
#60Earlier quoted context omitted.
And the notation are introduced to you gradually. Even books that do not have a chapter on the notation used, will have a reference page. If not, you’re not reading introductory material and some background is assumed.
Perhaps this is true for some texts, but take a look at math journals where mathematicians are writing for other mathematicians within their own field. They reuse symbols, sometime an integral symbol is for Riemann integration and sometimes it's for Lebesgue integration. The subject of the paper will make it clear which is which. Even in our own field, Computer Science, there are too many confusing cases: Knuth uses…
What "the size of" means is different applied to each type of object, and may have to be defined to explain some of them (esp. |f|), but it's common in math that general concepts apply differently to different things, while having some properties in common.
I think the notation is helpful rather than confusing because "the size of" carries with it some intuitive connotations which are common to each of those examples.