Hacker News new | ask | show | jobs
by paxys 1603 days ago
UTF-8 reverse string has been a thing for a long time in most/all programming languages. It may not work perfectly in 100% of the cases, but that doesn't mean reversing a string is no longer possible.
2 comments

"It may not work perfectly in 100% of the cases, but that doesn't mean reversing a string is no longer possible."

It depends on your point of view. From a strict point of view, it does exactly mean it is no longer possible. By contrast, we all 100% knew what reversing an ASCII string meant, with no ambiguity.

It also depends on the version of Unicode you are using, and oh by the way, unicode strings do not come annotated with the version they are in. Since it's supposed to be backwards compatible hopefully the latest works, but I'd be unsurprised if someone can name something whose correct reversal depends on the version of Unicode. And, if not now, then in some later not-yet-existing pair of Unicode standards.

> By contrast, we all 100% knew what reversing an ASCII string meant, with no ambiguity.

Not if the ASCII string employed the backspace control character to accomplish what is today done with Unicode combining characters.

Or, in fact, if it employed any other kind of control sequence.

I always thought it was interesting that ASCII is transparently just a bunch of control codes for a typewriter (where "strike an 'a'" is a mechanical instruction no different from "reset the carriage position"), but when we wanted to represent symbolic data we copied it and included all of the nonsensical mechanical instructions.
Well the control codes were specifically for TTY rather than typewriters, many of the control codes still make sense from that standpoint.
Like... \r\n
> It may not work perfectly in 100% of the cases, but that doesn't mean reversing a string is no longer possible.

I don't understand why in maths finding one single counter-example is enough to disprove a theorem yet in programming people seem to be happy with 99.x % of success rate. To me, "It may not work perfectly in 100% of the cases" exactly means "no longer possible" as "possible" used to imply that it would work consistently, 100% of the time.

It is very useful in engineering to do things that are mathematically impossible, by simply ignoring or rejecting the last 1%.

Sometimes that's unacceptable, because you really do care about 100% of cases. When it isn't, you get really cool "impossible" tools out of it :)

Because programming is not a science (or at most it is an applied science).

By your logic any software that has a single bug would be useless, and if that were the case this entire profession wouldn't exist.

Because you have additional information that separates it from the general case.

Even in mathematics if you add additional constraints you can solve subclasses of problems.