Web Framework (97)

94 Name: #!/usr/bin/anonymous : 2008-02-19 23:38 ID:Heaven

>>93

> Are you even aware that most language do make a difference between byte streams and character streams?

Are you even aware there's no such thing as a character stream in most languages? The stream itself is in bytes. In order to operate in characters you need to decode. That produces charstrings from a bytestring.

Very few languages differentiate between bytestrings and charstring:

>>> 'foo' == u'foo'
True

Python doesn't.

perl -e 'print do { use bytes; "foo"; } eq do { use utf8; "foo"; };'

Perl doesn't either.

(Common Lisp however, does)

Since you don't know the coding of a file (because the filesystem doesn't know), or perhaps since you're writing an IRC client and the coding can change mid-stream (and change back with a terminator character) you're almost certainly writing buggy code.

> I've never seen a language where you had to decode byte streams from a file.

That's a problem. You must decode bytestrings into charstrings if you're going to operate on them as characters. Because character operations work on bytestrings, you can end up working on something you think is coded when it isn't.

I recommend people avoid character operations or explicitly typing their strings as charstrings or bytestrings because it involves keeping track of the coding throughout a potentially long path. Other programmers recommend people simply use unicode for everything, but that causes people to code/decode needlessly and introduces new places where exceptions can be raised in surprise.

> If you're not going to argue about the real world, why should we bother listening to you?

You shouldn't listen to me. You should think about this yourself. Programmers are supposed to be thinking about this sort of thing. You are not thinking about it. You're arguing that other programmers are doing the same thing when they're clearly not and using that as justification to be an asshat.

This thread has been closed. You cannot post in this thread any longer.