I mentioned this before in some places here, that restricting us to ASCII only in the year 2023 is maybe a bit old fashioned and language syntax could be improved by embracing unicode.
The linked article talks about using Unicode in language syntax, such as keyswords. For example, ā instead of forall.
Sure that works. But why?
Itās essentially an alias, so just another way to do the same thing. Crystal tries to avoid that to remove the burdon of having to learn two things when one does suffice.
ā26 Characters ought to be enough for anybody.ā - Bill Gates, probably.
I didnāt post this because I want crystal to change to using unicode. Itās open source after all, and as you pointed out, i could just alias those things.
I just wanted drop the principle in as many peoples minds as possible (without being spammy I hope), just because I feel the concept is valuable.
Maybe one person sees this and in 4 years develops an incredible thing, using the seeds in this pattern.
Also, on the topic of having to learn 2 things, why is it Array.sum() and not Array.ā() ?
Again, I donāt want to change crystal, this should be posted under āoff topicā (unless i did something wrong).
I just want to plant seeds. in heads. (without it being gross)
For me personally, not having an easy way to access those characters without operating system specific shortcuts (if they even exist) prevents me from wanting to use them in a programming language.
Either a language uses Unicode names extensively (APL etc.) or does not use them at all. Anything in between sounds like only doing it for the sake of looking āmodernā.
If #ā is merely an alias of #sum, the vast majority of the people will continue to use the latter. The only way to make sense of the former is to have a standard library where the written names all vanish, or are so rare that they become seen as aliases to symbolic names. Such an approach is inherently incompatible with prior efforts.
I could see using this (after looking at the Haskel link) as a domain specific language if all the developers are in the domain. For a general purpose language, give me simple textual words that anyone familiar with programming is going to understand.
I suppose you could make a shard full of aliases or macros that implement this sort of thing, then itād be optional for developers. āOptionalā would be key here, imo.
Well, we do have AltGr. I use that to do a lot of special inputs like Ʊ or Ā± or Ʀ or ā¢, but I donāt believe most distros are configured out-of-the-box to use a layout with AltGr. And it still wonāt cover most of the symbols weād see in a programming context.
The word sum only has meaning to English speakers. For others it doesnāt mean anything.
But ā is a universal sign for sum. So Iād argue itās technically more inclusive because it doesnāt require knowledge of a specific language.
While math is universal, our language for it isnāt. Itās shared across many languages, Iām a bit skeptic about its universality outside the influence of āwestern civilizationā. For instance, has China just adopted our math notation, or do they have their own?
sum indeed requires knowledge of English, but so does the rest of Crystal (as pretty much all programming languages does these days). FWIW, sum is exactly the same in Danish, and I suspect a few others.
Besides, that I managed almost half a century on this earth, without being aware of the meaning of the sigma sign, is a point in itself. Iād wager that thereās fewer people that understand ā but not sum, than the reverse.
Thereās a different take: use an editor plugin to prettify the look of the code. For instance, in Emacsā company-coq, every time I write forall, the editor shows ā. I think this nicely combines the look of āprettyā code (for some peopleās definition), at the same time of making the code easily transferrable to others.
Keep the actual code and just give it a different visual representation in the editor.
Very interesting, portable, and with minimal impact on other people working on the code base. nice!
Hmm. I have to read up on fonts.
Do you happen to know if ligatures are a font feature that needs to be supported by whtatever is displaying the characters?
Or is it a thing that is automatically supported by truetype font handling?
Truetype supports the concept of ligatures, but the font itself needs to define them.
An editor has to support ligatures when rendering text and itās font engine should support it; then it relies on the data in the font to identify when to use them regardless of the font itself.
VSCode supports ligatures, you just have to enable it in settings; not sure about other editors, but I assume most modern editors/IDEs support it as well. So you only have to solve #1, which is to modify a font so to define custom ligatures. The post in Stack Overflow provides a link to the open source font that you could fork and tweak:
A popular example of this is Fira Code, which is a modified version of the OFL-licensed Fira Mono, but with the ligature glyphs drawn specifically for the project.