Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Wholeheartedly agree that sticking - where possible - to [closed, open) is a good idea. It has helped me tremendously when implementing, e.g. computational geometry algorithm. Robust triangle rasterization comes to mind.

Another interesting point: in the weird corner of the world where I grew up, half-open intervals were always denoted : [low_bound, hi_bound[

I am of course completely biased, but I've always found this notation much more elegant and intuitively obvious than the [low_bound, hi_bound) that seems to be the prevalent norm in the anglo world.

Using '[' after the upper bound clearly shows that we're open at the top whereas the ')' is fairly arbitrary.

And while I'm on the topic of weird culture-induced quasi-arbitrary biases: I had a math teacher that would bark (and I mean BARK!) at us if we ever used '>' in inequalities.

The justification was that with this constraint, all inequalities ended up written and laid out with its two members respecting the standard "left-to-right" drawing of the real line, which made it much easier to picture what was going on geometrically.

It also enforced consistency throughout a long demonstration - one less thing added to the cognitive load.

He was made fun of a lot by the student body, of course, but later in life, as a programmer, I have found myself sticking to the habit and I always force myself to mostly use '<', very rarely '<=, and almost never '>' and ">".

I find this makes code much more readable, just like back in the days of my old teacher with math inequalities., and pretty much for the exact same reasons.

Of course, doing that does not help at all when reading other folks code, those uncivilized heretical users of the 'greater than' form.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: