Anyway, this is not a complaint about the language (which I like very much), just a dislike of the popular usage
Anyway, this is not a complaint about the language (which I like very much), just a dislike of the popular usage
In any code you write, you should be asking, "how will people check this?" If the answer is "by comparing it to something else," then it should resemble the original as much as possible. If the answer is "by thinking about it," then it should be formatted for self-contained comprehensibility. The distinct use cases lead to different best practices.
For the record, I'm not a blackboard addict, I never had a career in academia and I'm not even really a member of Julia community any more than any other person who wrote maybe a couple thousands of LoC in Julia. But I wish people would realize it's not 1970's anymore, and ASCII is culturally outdated. For that matter, I would love if I could write formulas in my code the same way I do on paper, like in that MathJax sample from the article. That's why math notation exists at all, imperfect as it may be (and I hate many things about established math notation, but it's the best we have). I just don't see how it's possible without abandoning plain-text, which I surely wouldn't like because we (currently) don't have tools that would make handling it as effortless, as editing text in Vim.
The fact is it's easier to type "mu" instead of "u" (like right now, I can't be bothered to look up "mu unicode", or open the special characters picker, or exhaustively brute force alt-gr key combos to find the mu).
Take it a step further, I wish physicists and mathematicians would stop naming their variables so poorly so that only the most seasoned of their field can follow along.
Sometimes, like v (velocity) it's quite obvious, at other times I find myself staring at scripts with insane variables like a,o,t_o, etc. And this is a habbit that seems to carry over to non-academic code as well. It's trivial to spot code written by a mathematician because it tends to be incredibly obfuscated.
Do you really need to name your constants K_(single letter)? Or can you just write "AIRDENSITY" once and let your editor autocomplete it in the future?
The reason I complain about these symbols is because they don't have clearly defined meaning. Maths/Physics had to pull out the Greek alphabet after it exhausted the Latin alphabet (and overloaded most letters with 2 or more meanings) and then promptly molested the Greek one in the same way. Just look at Omega. It's useless. It has been overloaded with so many possible meanings that it has none. Stop naming your variables "omega". Unlike Maths, programming languages support variable names of more than 1 character long.
Honestly I really hate seeing mu_a, delta_k and company all over the place. If we are gonna name our variables like this might as well give us the actual characters
your criticism of Perl is unfair. Base perl has supported unicode variable names since more than 20 years ago, way before all the other languages that you speak about.
You just type \mu and then hit the tab button and you get μ. I actually switch over to my Julia REPL all the time when I’m emailing someone and want to type a greek character.
So you can see how this becomes a bit of a barrier to entry.
For new users, if they're not used to writing unicode characters and don't have an editor with nice support, then they don't have to write them.
The julia community has a pretty strong convention of giving both unicode and ascii versions of almost all functions. Some packages don't have this convention, but I'm not aware of any big important ones that don't follow it.
I use vim, and have a completions plugin (part of julia-vim mode), so that I can write \mu<tab> for any unicode name, which makes it as easy to type as "mu", but easier for me to read (as it matches my textbook expectation of the formula).
And LaTeX codes are not always obvious. For example it's \triangleleft but \leftarrow
Edit:
There are like 5 replies to this mentioning different ways of doing it (including memorizing 3 digit unicode values) none of which seem more intuitive than writing "mu".
\mu<tab>
I agree that we need better system-wide tools for arbitrary Unicode input. Font support and confusable glyphs are also issues. But I think these are solvable problems, and they will be good problems to have solved.
Also, Emacs has an input method which supports "\mu", and this convention is also used in Racket for things like λ.
Write for the convenience of the reader, not of the writer!
We're in the 21st century, all the tools we use should have reasonable Unicode support. The fact that we collectively keep on talking about typing non-ASCII characters as a real problem is a pretty depressing reflection of our shared computer infrastructure :(.
For example these equations look similar,
x^2+4x+5=0
y"+4y'+5=0
Even though one is a polynomial equation and the other is a differential equation, the common visual pattern suggests that the techniques needed to solve them may be similar.
On the other hand in programming there's no need to do this, all the math has already been worked out on paper, so it's better to use clear, distinct, easy to type variable names.
How important is form when I'm programming mathematics?
Not important.
Who in their right mind does math on a computer, math is implemented on a computer, but it's done by hand.
Maybe you think this becuase your used to writing math on computers that make writing that math ugly and obtuse?
Besides, having the math you've written by hand closely match the syntax you use on the computer can greatly reduce the cognitive burden of switching between code and paper.
Making your code performant, and doing a thorough numerical analysis, usually requires a significant rearrangement of your formulae.
Why would I use the variable name "probability_distribution_on_m" instead of "rho_m", when I know all along what rho_m means in the contexte of my code (the symbol use throughout the paper). Usually, I comment at the beginning and specify what the variables mean and to what they correspond in the paper. And if somebody needs to read my code, that person will need to understand the paper first. More descriptive variable names won't make the person understand the paper better.
Of course, when I am writing some non-scientific software, I will use descriptive variable names, because there is no complicated formula, no paper that sets the context of the code, and it makes sense in general to have descriptive variables for logic elements for a clear code.
What I do think is bad form would be naming it ρ_m.
The solutions to those problems is to use better fonts, terminals, and editors. Using Unicode characters is fine but some people do have legitimate problems with them.
Not all fonts are good fonts for an evey use use; heck, not all fonts make 0 and O or 1 and l and I clearly distinguishable.
> The solutions to those problems is to use better fonts, terminals, and editors
Exactly.
Typing certainly does add more friction between u and µ than a chalkboard would, though it is perhaps also notable that mathematicians seem to have felt that it's worth the effort, and have come up with a quite nice system for it in LaTeX -- and I would certainly not mind seeing more languages and editors add support for LaTeX completions the way the Julia ecosystem has.
Some proper use casees IMHO are: 1. in "terminal" code: scripts, notebooks. 2. function internal variables 3. for making the code look like their counterpart of a paper.
idk what to think of 3. if you look at any paper, non of them only uses ASCII, which raises the question, if we're happy with reading papers (even CS ones) with symbols, why not in our code?
Maybe I'm behind on this, but needing to use the mouse to find symbols in a huge menu is very painful.
You can copy and paste too but again, huge break of flow.
Do some editors support discord-style emoji syntax, where typing :fo would bring up a menu of emojis that might match foo. Then hitting enter inserts the emoji over the :foo: representation. You can also not use the auto complete menu.
Ex. :pow2: might turn into ²
Better yet, you can reverse look up how to type a thing:
help?> χ²ᵢ
"χ²ᵢ" can be typed by \chi<tab>\^2<tab>\_i<tab>This is optional, the language adapts to the capability of the user. He can write ∑ or sum for a function, µ or mu for an identifier.
https://docs.julialang.org/en/v1/manual/functions/
You get people riled up in this thread with your false assumption, next time simply ask questions.
Do you have any example? As far as I know this is strongly discouraged in the community.
I fully think this is a problem with archaic input - but that doesn't mean it would not be inconvenient when navigating through a code base :/
clear control
clear mod2
clear mod4
keycode 134 = dead_greek dead_greek dead_greek dead_greek
keycode 108 = Multi_key
remove Lock = Caps_Lock
keycode 66 = Control_L
add control = Control_L
But you have to figure out the keycodes that your keyboard is sending to make it work for your particular machine. The program xev is good for this.This mapping also makes the capslock key into another control key, which is good if you use Vim.
The Greek letters will be on keys that make sense, and the other Unicode characters are pretty rational too: to make é, type <mod>'e. You can make any key combination produce anything, even long strings, by putting the mappings in the Compose file. My Compose file is in /usr/share/X11/locale/en_US.UTF-8. I have snippets in there, such as my email address. This way the mappings work anywhere, not just in a particular editor.
https://unix.stackexchange.com/questions/292868/how-to-custo...
In particular: https://gitlab.com/interception/linux/tools
https://gitlab.com/interception/linux/plugins/caps2esc
(for remapping caps lock to escape - in the terminal and under Wayland).
EDIT: In general it makes sense to set up your keyboard with a compose key and a “dead Greek” key, and set up your Compose table so the shortcuts make sense to you. Then you can use an expanded set of symbols everywhere, including comment boxes like this one. You can even put things like your email address in your Compose table.
On the other hand, if you're going to use \mathfrak{i} to index a simple loop you're doing it wrong.
So, if you are maintaining code where that is the idiom, use a font where that isn’t an issue.
You can also put Greek symbols in superscripts or subscripts and that works just fine.
Do you think the Symbolize (or the Notation package) are useful? I don't see any examples in the docs, so hard to tell.