3 ms·
Wouldn't you want to call that "string" versus "bytes" (instead of "text" versus "string")? (That's the Python parlance, if I'm not mistaken, and it seems good
by FabHK 9y ago
Wouldn't you want to call that "string" versus "bytes" (instead of "text" versus "string")? (That's the Python parlance, if I'm not mistaken, and it seems good to me.)
- rocqua 9y agoIn that case, which is HTML? Because it's meant for machines to read, so should be treated more carefully that pure 'text'. However, HTML shouldn't be processed like bytes either. I suppose with HTML the real issue is that there is human readable text in there.
- nothrabannosir 9y agoHTML is serialisation of a DOM. It's not a sequence of text, but a semantic tree of it. Both encoded as sequential bytes, but different concepts when decoded.
- the8472 9y agoHTML5 is specified in terms of unicode characters and forbids most control and non-characters[0]. In that sense it is human-readable text. It's not easy to read, especially when minified. But so is shorthand or very dense scientific texts. Some things are meant to be human-readable and machine-parsable at the same time. Those things are not mutually exclusive. And sometimes humans will complain even more than machines if you mangle their text in any way. [0] https://html.spec.whatwg.org/#preprocessing-the-input-stream https://html.spec.whatwg.org/#preprocessing-the-input-stream
- brudgers 9y agoTo me, Bytes are a different abstraction. In terms of automata, a string consists of characters. Related to the problem of conflating text and strings is the traditional conflation of characters and bytes via ASCII. Again for me, in terms of handling text versus strings, the Python ecosystem is not the paragon of well considered language design. Abstractions over strings, text, characters, and bytes are a significant breaking change between Python 2 and 3 and among the reasons that Python 2 code is still written in significant amounts...and still there is no 'text' type.
- FabHK 9y ago> traditional conflation of characters and bytes But that's precisely what "string" vs "bytes" untangles... (talking Python 3 here; Python 2 suffers precisely from the mess you mention)
- brudgers 9y agoThe previous comment used "Python" without specifying which one...and part of me feels that to some degree Python 3 just put another layer on the mess because it still did not make the important distinction between texts as human readable artifacts and strings as a computer science concept. Or to put it another way, a stream of bytes can readily be parsed as a string of characters by an automaton because bytes can be parsed as characters and a stream as a string. But this all happens at a lower level of abstraction than text as something that humans read and write both with and without computers. I mean Python 3's distinction between strings and bytes in no way address messy problems like ß/ss in German.
- deleted 9y ago[deleted]