4 ms·
It's not specifically stated, but the assumption seems to be that we should sometimes make our code look closer to how we display math in papers or on a whitebo
by abeppu 6y ago
It's not specifically stated, but the assumption seems to be that we should sometimes make our code look closer to how we display math in papers or on a whiteboard.
I'm legitimately on the fence about this.
I recently re-watched Guy Steele's 2017 PPOPP on "Computer Science Metanotation", and aside from wanting to make CSM an unambiguous formal system, he specifically says at one point that he wants tools to support CSM as it appears (i.e. with stacked overbars, gentzen-style inference rules, etc) because "anything else is a translation".
And partly I get that. There is real cognitive work if you have to constantly translate back and forth between two representations of the "same" thing.
But should we favor readability or ease of interaction / modification? Keyboards give you a way to insert a sequence of characters. Notations that are not graphically linear (e.g. a symbol that has both a subscript and a superscript) create an ambiguity about how you input them. "Modes" where we display something different than what is typed can create ambiguity about how to edit them.
And if a tool only covers 90% of the notational convention you care about, it quickly gets frustrating as you repeatedly bump up against that boundary. I experience this in emacs org mode with "symbol" support.
- djaque 6y agoIt isn't a problem in Julia editors. You input characters using the same notation as latex (IE \mu or \hbar) and then tab autocomplete to unicode. Even jupyter notebooks support that convention. Most people in Julia's target audience know latex already and so there is zero learning curve. It did hugely simplify my scientific code where I already had variable names like hnu, omega_squared, and k_prime_prime which become arduous when checking against long equations.
- neolog 6y agok'' is better than k_prime_prime, sure. But there's still lots of notation that isn't just a sequence of characters. And Latex-style representations are restricted to sequences of characters. A big formula in Latex code is hard to read compared to the rendered version. LyX would be a nicer representation.
- deleted 6y ago[deleted]
- pmeira 6y ago> Most people in Julia's target audience know latex already Is Julia's target audience really that small? Either that or you'd be surprised how many people don't use LaTeX but do write scientific code and papers.
- oxinabox 6y agoEven if you don't use Latex, all the equation editors in e.g. word etc use more or less the same latex symbol names Julia does (I remember typing things in by name in MS-Word 2007 long before I started latex). Even if they don't use more latex than that. And if the people don't use enough symbols in their papers to memorise the type-able names, they probably don't want to use them in their code in the first place.
- threatofrain 6y agoIMO the people whose scientific papers are equation-heavy will have someone else do the editing, or the publisher will have a template. Latex could use a disruption, but who will do it...?
- centimeter 6y agoAll of my university colleagues (physics dept) knew how to use latex.
- sundarurfriend 6y agoI don't know Latex and find it difficult to learn, but have found that it's almost trivial to remember the Latex names for these symbols, especially since it's often a small subset of these that you use, depending on your field. They've been pretty quick to get into my muscle memory. Just like with natural languages unrelated to yours, it's the grammar that really does your head in, needing just the vocabulary is Easy mode.
- bunje 6y agoSo you need a special editor to write code in Julia?
- oxinabox 6y agono, the comment is the included REPL has it, and that most editor plug-ins (of which they exist for vim, emacs, sublime, Atom, VS-Code) intended for julia, add the same unicode shortcuts, as well as the usual syntax highlighting, keyword completion etc. If you don't want to use the, but do want to enter unicode, then you can do it the normal way. But I feel like the fact that you want to enter unicode but don't want to install a plugin to make it easier is pretty weird. I guess it could come up if editting someone elses code. As a general rule most libraries (including the standard libary) make very limitted use of unicode in their APIs, so you don't have to use unicode to work with the library. I would go so far as to say if a library requires you to use unicode you should open an issue, and get them to add a ascii alias for that function. (julia standard library had just such an issue opened a few versions ago about the compose operator ∘ and not we have a `compose` function to match). I would also say internally most packages make very limitted use of unicode also. Even with the plugins it is still a bit annoying to type. Plus often it would be a less meaningful variable name. E.g. why say: θ, when you could be saying `departing_assent_angle` or something else that conveys context specific meaning. Its nice to have the option for when it is clear, but I think pleasingly people only use it in moderation.
- moonchild 6y agoIt's for this reason that I'm a fan of APL, which was intended both as unambiguous computer notation and as effective mathematical notation.
- carapace 6y agoI wonder if anything ever came from his CSM stuff or if he just moved on?
- andreareina 6y agoEmacs is actually why this is attractive to me. The latex input mode makes it easy to input a large set of Unicode that I care about, but my font not supporting them means that the fallback is used, which throws everything out of alignment, frequently messing up the line-height as well.
- joppy 6y agoOn the other hand, if a tool only covers 10% of the notation you care about because of a restriction like plain-text, it’s very difficult to document what you’re doing as you bump up against this boundary. Humans have been using nonlinear notation in a wide variety of fields, but computer programming languages seem especially stuck on plain text everywhere, despite the utility of such notation. I would rather faff around for a minute or two trying to figure out how to change my integration limits in a comment than leave some horrendous documentation comment like “computes the integral from a to b of the blah blah blah blah” and by this point because you can’t see the familiar notation, you first have to interpret it before checking the function. (Several PhD students I know working in applied mathematics and physics will “translate” these comments from code onto a scrap piece of paper in front of them, before attempting to dig into the function). Personally I think it would be great if I could embed more rich text (styling, equations, and images) in comments to better communicate my intent. This stuff otherwise just winds up being left out (because it’s too hard), or in some other separate documentation which is difficult to keep in sync during development.