On 2 nov, 17:02, Jens Alfke wrote:
To use an analogy: There are thousands of old graphics file formats floating around too, and it’s not hard to find images saved in them, but that doesn’t mean that every platform’s built-in image class/library knows how to read them all. Generally you just expect support for the ones in wide use like JPEG/PNG/GIF. If you’re writing code that needs to be able to open Targa or PICT or Xerox Alto bitmaps, you go find an external library that supports them and link with that.
The same is true IMHO of reading text files. The bog-standard built-in ReadLine function should be expected to handle formats in current use, i.e. Unix and Windows line breaks, and 8-bit and UTF-16 encodings. Anything more exotic, like Mac-classic line breaks or Shift-JIS encoding, can be left to 3rd party packages.
What is classic is a matter of perspective. I can say, we don't need
to bother with inches and feet and yards and miles, we abandoned those
in the dark ages, everything should be metric by now. Well, it isn't.
An importent point is that line-end codings is not something that
separates one document from another like EBCDIC from ASCII from Shift-
JIS. The latter are very different beasts. But Unix, DOS or Mac ASCII
text files, they can and do live in the same environment, usually
without the user noticing the difference.
But this is just part of the issue of why I started this thread.
I have come to expect from modern programming languages to have line
processing build in, or at least part of the standard library. See
Perl, Python. Go only offers a partial solution. It's like that age
old C functions, fgets(), you can get by by using a buffer that you
think is big enough. Go is a modern languages where you don't have to
bother about those C things like allocating and freeing memory, where
you can just concatenate two strings together without having to worry
about available buffer size. Why then is there no function that simply
gives me a single line of text when I want to?
There are other things I am missing in the standard library. Like
handling different text encodings. Yes, EBCDIC and Shift-JIS, all
those strange beasts, to me, that's standard toolkit stuff. But here
we are at a point where there is no clear answer to what should be in
the standard library. It's a matter of perspective, from a certain
point the choices become arbitrary. Why are there all those crypto
packages, but no OAuth functionality? Why no library for building a
GUI (even something primitive, like tK). Why yacc, but not (f)lex?