logoalt Hacker News

mejutoco • yesterday at 9:04 PM • 1 reply • view on HN

If you want text _in addition to_ regex you can use comments in regex, like in https://softwareengineering.stackexchange.com/questions/1783...

> Should equations in math also use full words and comments?

My "also" referred not to have multiple representations but to also in math have prose instead of equations. I could have expressed it better. I did not think of that interpretation.

As for math, I really do not think that is true. Look at how this beautiful proof is so long in prose.

https://mathcs.clarku.edu/~djoyce/java/elements/bookI/propI4...

Is that better than a^2+b^2 = c^2 ?

https://en.wikipedia.org/wiki/Pythagorean_theorem

Notation helps to be concise. Imagine more complicated things without notation in maths. Of course if you look at Principia Matematica we see the limits of notation as well.


Replies

crazygringo • yesterday at 11:13 PM

The point is, if you don't use regex that frequently, you can completely forget that ^ means start and $ means end. And adding those as line comments ("^ # Start of expression") would be dumb.

That's why a well-designed DSL tries to make its syntax as self-explanatory as possible. Using "start" instead of "^", or "digit" instead of "d".

We're not doing equations here, we're doing engineering. Analogies to proofs are not helpful. There is a very good reason why, in coding, we give descriptive variable names such as "accountBalance" rather than "b".

Conciseness is not a virtue in programming. Clarity is. Things should not be longer than they need to be -- but neither should they be shorter. The name of something should not be 100 characters long, but neither should it be 1 character long. A word or two is generally the sweet spot.