HACKER Q&A
📣 kulikalov

Why doesn't math look like a programming language?


Why do we still use symbols like ∑ instead of just writing it inline like sum()? Or probability() instead of P(). I mean it's page one in any "Good programmer" book: use descriptive names.

I realize that all these funny greek letters and multiline spelling quirks were accumulating in math "vocabulary" for ages because people used to write equations by hand on a confined piece of paper or clay or whatever they were using.

But isn't it possible to modernize the math syntax to use more descriptive names, variables and functions?


  👤 eternityforest Accepted Answer ✓
I am convinced whatever math people are doing is a completely different way of thinking, and math people seem to like their notation, so I defer to them.

Perhaps there is some super notation that could somehow make math accessible to more people, but I doubt it would look like code, since they are two different tasks.

Mathematicians often deal with systems of multiple equations and multiple variables. Every part connects to everything else. It's like those trippy analog and mechanical things where one part does 5 things at once.

Programming is much more heirarchal. You can deal with one layer of abstraction at a time, thinking in terms of parts that become black boxes when you aren't actively dealing with them.

Sometimes the only challenge in programming is just the size of a task, and it's more tedious than challenging.

Math seems to demand a new way of thinking for basically every task.

Math as code would be amazing for people like me, who basically never at any point have a need to actually do any math beyond copy and paste. But my opinion doesn't matter much, since I'm not actually doing anything interesting, and current notation isn't a significant part of my life.

If I need to solve something, xcas or Maxima understand descriptive names just fine.

If I needed to understand the things in a proper math paper... I would probably be doing the stuff the math people do, and I'd think the notation was great, just like they seem to.

I don't know how they keep track of the meaning all those symbols. Maybe they don't, and the abstractness is useful?


👤 yeellow
Why don't you try and show us the result? After one page of doing probablity theory you will understand why P(XWe have this discussion on HN every few months. Math is not notation, if someone can't get and remember what \Sigma means writing it as "sum" won't help. Yes, sometimes people use cryptic symbols or notation, as many people write unreadable code.

👤 dagw
Math notation is often 2-dimensional and nested. People often don't just write ∑, they write ∑ and then write stuff above and below that ∑ in smaller letters. The they will nest statements with that statement and so on. Something like this statement below (admittedly random 'gibberish') is almost impossible to read (or write) when written out linearly, but would quite easy to visually write and parse if written out in standard math notation.

sum(div(integ(0,inf(),pow(n,-x*pi()),x),sum(p,n,q),0,n))


👤 dagw
I mean it's page one in any "Good programmer" book: use descriptive names.

Even programming has lots of this sort of shorthand going on going on. You probably use several of them every day without really thinking about it. We write "def" instead of "define", "struct" instead of "structure", "var" instead of "variable", "mut" instead of "mutable", "puts" instead of "put_string", "std::vector" instead of "standard_library::vector", and you can probably think of 50 more if you put your mind to it. I'm sure even you have named a loop index variable "i" or "idx" at some point. Are you also advocating we change all of these to make them more descriptive?


👤 Hermitian909
Off the top of my head:

- More international, I can read an equation from a french mathematician without issue

- Historical, you point out this out to an extant, but part of this is that to read papers you need to know the notation anyway.

- When reading a paper in mathematics I will often extract some equation from the text and play with it to better understand the idea on paper, again, this is easier with a more terse notation.

- Most importantly, mathematics is a different process than software engineering. Mathematicians still write more than they type, particularly on chalk boars. This is not a point to be hand waved away. Mathematics usually involves a lot of writing and playing with these symbols in notepads and on blackboards either alone or in collaboration with other mathematicians. The speed and conciseness from the symbols helps a great deal in this process. Switching to more descriptive forms in text would just end up confusing as people try to translate between symbols and text.


👤 nicoburns
It's not lack of paper that's the limit here. It's how much you are able to see at once. Personally I feel like the notation is not the problem. However what is a problem is that mathematicians have a tendency to use notation without defining it (and mathematically notation is not as standardised as you might think).

👤 vertere
Standard notation like sigma for sum isn't really a descriptiveness issue, everyone knows what that means. Not dissimilar to programming languages using `+` instead of `plus()`. Non-standard variables are where more descriptive names would be useful, though the tendency to use single letter (greek or otherwise) names is reinforced partly by writing `ab` for `a*b`.

Also much of math notation is effectively 2d. Programming langs use linear text. Latex syntax is sometimes used for a linear-text representation (even if it's not intended to be rendered), but it reduces readability.

And people still write equations by hand a lot, because the notation is more efficient than typing it out.


👤 t-3
> But isn't it possible to modernize the math syntax to use more descriptive names, variables and functions?

That's exactly what programming is. The issue is, programming languages do a lot of other things that are irrelevant to mathematics, and the syntax is so much more verbose that it doesn't make sense for pure math. You don't want control structures interrupting your train of thought every other line when trying to understand an equation, analogous to spaghetti code filled with gotos.


👤 smartmic
I would rather prefer the other way around and see APL more used for math-oriented programming tasks …

👤 jleyank
Err, the math symbols are language independent. No guarantee that the words for sum and probability start with s and p. Why switch one arbitrary set of symbols with another.

👤 breck
I think it's an interesting question.

Why stick with 2D math? If you're senior and already trained your brain to work in 2D math then it's a no brainer to continue to exploit what you know. If you're young, 2D maths is orthogonal to programming languages and I think very much worth the investment of practice: work on problems from a different perspective; very dynamic, domain and scale free; work offline; utilize large amounts of learning material; read early literature.

Why does 2D math break naming conventions we have with programming languages? You don't get autocomplete with pen and paper; you have to write out intermediate steps; and there's no backspace key. So offline bytes are expensive today as they were 100 years ago, whereas online bytes in programming languages have dropped exponentially.

Why does 2D math not stick to 1d linear forms? Notation inventors design their languages to take advantage of what the tools can do. Languages looked different before we had syntax highlighting. The tools for 2D math (pen+paper) do not have many features of the IDE, but they do have 2 dimensions with variable cell sizes. 2D math notations exploit those to make writing (and doing intermediate computations) easier.

Why not build programming languages for every construct seen in mathematics? People do! You've got symbolic languages like Mathematica to matrix languages like APL. If you've seen it written in 2D math, someone's probably turned it into a language or library.

What will the future of 2D math look like? I expect much like the present. Maybe someone will discover some brilliant new trick, but I don't think that likely. Perhaps with better hardware and AI we'll have some advanced Remarkable-like Tablets that blend the best of 2D handwritten math with the best features from IDEs. I expect 2D math has probably plateaued and will remain around as a useful orthogonal tool until AI takes over most jobs from humans (In the end both 2d maths and programming languages might not matter—it might just be binary + AIs running the show).

Recommended reading:

- A History of Mathematical Notations by Florian Cajori (1929)

- Syntax-Directed Recognition of Hand-Printed Two-Dimensional Mathematics https://dl.acm.org/doi/abs/10.1145/2402536.2402585 (1967)

- A Review of Two-Dimensional Programming Languages (1972) https://dl.acm.org/doi/10.1145/942576.807009


👤 quickthrower2
I suspect because mathematics has a longer history and although the specific notation has evolved for things, going against the grain in a single paper is going to be hard.

Using computers more and more to prove things might change this though?


👤 beardyw
Whilst I sympathise, putting everything inline would have its problems. For example division symbols become much less clear and require parentheses. Exponentiation is easy to appreciate done in the math style. And so on.

👤 timonoko
Sympy is your friend. It has all kinds of squiggles. https://www.sympy.org

👤 pchangr
I think what you’re looking for is precisely LaTeX