12,740 karma · joined Feb 17, 2008 (18y ago) · 2,917 submissions
comment 14y ago · link · parent
Some counterexamples that come to mind...
- [NSImage initWithPasteboard:] (must NSImage retain the original pasteboard and/or its contents for all eternity, in case you want it back, even if it was in some odd format like NSPICTImageRep that probably doesn't match the internal representation?)
- [NSDictionary initWithContentsOfFile:] (must NSDictionary remember the file path for eternity, and/or its contents, in case you want it back?)
Yes, if an initializer is basically accepting things that become properties anyway, it makes sense to expose those properties. But initializer arguments are not necessarily sensible or useful to keep around in all situations.
comment 14y ago · link · parent
comment 14y ago · link · parent
When a pirated show is instantly available in a region that would otherwise wait a week, that shows an industry asleep at the wheel. Producers should ask themselves some hard questions if they're unable to deliver a better format when they're the ones being paid for it.
As I see it the future looks something like this:
1. ISPs and other infrastructure companies start charging much, much more for bandwidth but in exchange they invest hugely in it. The default assumption would be that everyone and his grandmother needs obscene amounts of data because this is now how they're watching TV, etc. There would be exceptions for people who somehow use very little, just like now where some people don't own a TV and don't buy cable.
2. Content companies make deals with these ISPs that basically say this: "hey, I'll produce lots of stuff people want, which will cause them to download obscene amounts of data; in exchange, give me a guaranteed cut of whatever you're charging them".
3. There would be a way to buy temporary bandwidth, e.g. instead of a pay-per-view movie you rent an hour of "high bandwidth" and download whatever you feel like watching in that time.
In other words, companies have to stop pretending the Internet isn't the best way to distribute things, and customers have to stop pretending that things don't cost money.
comment 14y ago · link · parent
To solve this particular problem in future code more compactly however, note that Python 3.2 (finally) adds an "exist_ok" Boolean keyword parameter to the multi-directory variant, os.makedirs(). In other words, calling os.makedirs("mydir", exist_ok=True) will silently ignore existing directories and only raise if other errors occur.
comment 14y ago · link · parent
But None is a result that can happen in situations that would otherwise return exactly the expected type. If "nothingness" can be meaningful (especially in a function that accepts an empty list as a parameter, say), it's nicer if the code just deals with None itself instead of requiring checks for None in all the callers.
comment 14y ago · link · parent
If you say "f(x=[])" (assuming that worked without the actual side effects it has), someone could still say "x(None)" instead of "x()", causing the function to die. Since a robust program isn't able to avoid checking for None, it might as well set defaults there too.
There is another case where this is important; you might want the equivalent of "f(x=expensive_function_to_calculate_useful_default())", and you don't want that function called unless it needs to be. Only the x=None approach allows this to be deferred.
comment 14y ago · link · parent
comment 14y ago · link · parent
comment 14y ago · link · parent
Even Python removed one of its most prominent cases of this, the print command. In Python 2.x you could have a trailing comma after a print to omit the new-line but Python 3's print() function requires print('something', end=' ') to be more explicit about it.
1840.
I don't want your iPad-optimized web site
19 points · by makecheck · 14y ago · 2 comments
comment 14y ago · link · parent
I've also seen IT people enforce their random rules on everyone, leading to things like "rba186" as someone's actual E-mail address name instead of something meaningful.
So yes, choosing your own log-in and E-mail name would be pretty nice.
comment 14y ago · link · parent
There are billions of people and plenty of languages out there (nearly 200 are spoken by at least a few million people per language, if you go by the list on Wikipedia).
We live in a world where most co-workers have probably had to claw their way up to their current language proficiency.
People who only know one language can't really complain about poor communication. Both people in a conversation have a responsibility to work at closing any gaps, and frankly a native speaker has more than 50% of that responsibility.
Even if you have learned another language, do you really know how tough it could possibly be? For example, have you learned to read, write, speak, swear and slang in the 2nd language to the point where no one will misunderstand you? And here's the real test: is the alphabet the same as your native language or is it something totally new?
I grew up with English. I spent years learning to read, write and speak French, and while this gave me some appreciation for the difficulty in learning a language it was still the same letters, similar words and a few new rules. I've since invested a lot of time in learning basic Japanese and that is something I'd recommend to anyone who thinks they're an expert at a language.
You have to try something completely unlike anything you've ever seen before you understand what a chore it must be for others to try to communicate with you.
comment 14y ago · link · parent
There is nothing quite as motivational as deciding that you're going to prove naysayers wrong. If they say that what you did sucks, you work really hard to make them liars. Anger is good for this. Hearing nothing but praise just keeps you from trying to do better, and sugar-coated problems never seem severe enough to invest time in.
It's also a clue (albeit one lacking social graces) when people speak strongly about something: the topic is important to them. Don't allow bad language to keep you from parsing a good point out of an argument; you might not hear that same argument from anyone else.
comment 14y ago · link · parent
comment 14y ago · link · parent
It's also worth noting that even if you believe you know how to improve/simplify/whatever, it may be worse than you think and sometimes you don't figure out the extent of the complexity until days have gone by.
This, like many things, is a trade-off and not a set rule. In brand new code, by all means make it small and pretty and documented and whatever else would win it an award; but in established code bases be smart about what you "fix".
comment 14y ago · link · parent
comment 14y ago · link · parent
Carriers made significant amounts of money because of the iPhone that arguably they would not have found any other way to make. Very few of their personal investments led to this success (except perhaps things like Cingular's agreement to invest in "visual voice mail" at Jobs' behest, before AT&T bought Cingular).
From my point of view the complaint from AT&T is a little like an investor trying to socialize his losses while keeping all his capital gains. AT&T enjoyed Apple's success when it benefited them, and now that it's working against them they're worried? Well, tough.
comment 14y ago · link · parent
I think the Python "decorator" concept goes a long way toward cleaning up code. Basically you can add a decorator to a routine that you've deprecated so that it will complain if it's actually used (you can even include advice on what would be a good replacement call).
As far as cleaning up what's installed as standard, it's not really practical to remove anything (the fact that it stays is one of the attractive things about Python in old code bases). What you can do though is define a preferred namespace, e.g. "preferred"; this would physically contain only those libraries that are recommended, and perhaps even forked copies of modules that only contain the functions that should be used. This gives programs the option to explicitly import from "preferred" and request purity over long-term stability.
comment 14y ago · link · parent
Older programs do care, but as I've said elsewhere in the thread an ASCII file can remain ASCII (no BOM). There's no reason to BOM-ify an old ASCII file if it really is ASCII and only ASCII-expecting programs will ever use it.
Over time these old programs will either be upgraded or go away and it will finally be safe to say that inputs must be UTF-8. At that time, the BOM has no reason to exist.
comment 14y ago · link · parent
If a program requires ASCII compatibility in order to work then by all means make the input files ASCII (no BOM), just make sure the files have no true UTF-8 dependencies in them.
Once a program supports UTF-8 "properly" however, the BOM is useful as a signal that the input is somewhat complicated.
At some point in the future when UTF-8 really is everywhere and programs may no longer even try to sniff encodings, etc. then yes, the BOM has no real reason to exist.
comment 14y ago · link · parent
But if your input could contain complex UTF-8 (e.g. it's multi-language or whatever), you're not doing any favors by hiding this fact. The BOM is a quick way to know exactly what the file is, and it shows you that your program won't work with that input. So you translate the input or you fix the program.
At some point in the future the majority of programs will handle even complex UTF-8 properly, and then the BOM will be pointless because virtually all inputs will be UTF-8.
comment 14y ago · link · parent
Raw concatenation of bytes without encoding-awareness introduces the possibility that the bytes will combine in unexpected ways. The presence of something as obvious as a BOM makes it harder to make this mistake, at least during the transition phase to "UTF-8 everywhere".
What you really want in this situation is something that forces you to see the potential bug and introduce the correct translation and/or text-concatenation tools to fix it.
And yes, at some point in the future enough tools will be truly aware of UTF-8 that the BOM will not have a reason to exist. But right now it has some value.
comment 14y ago · link · parent
Historically code pages mapped character values directly to individual bytes: typically redefining the upper half (129+) while leaving the lower numbers the same as ASCII. Programs could display a wide variety of text encodings correctly as long as they knew what the encoding was, and all they had to do was read bytes individually. These encodings could all be handled in a way largely similar to ASCII.
UTF-8 however is a multi-byte encoding, which means you could have (say) 3 bytes that combine to form a symbol. Not only that, but in certain forms multiple symbols could imply display as a single glyph (e.g. an accent followed by a letter). A program that does everything the old ASCII way would choke on multi-byte UTF-8, despite being otherwise-compatible. Consider a program with a fixed-size read buffer; if the last byte is only partway through a multi-byte character, that character will be mishandled unless the program knows how to preserve those bytes and "complete" the character when more bytes arrive.
comment 14y ago · link · parent
In practice though some programs and protocols have text/binary distinction (e.g. FTP). It's not unreasonable to have a mode that hints when bytes are to be used as text. This is frequently done to handle different new-line styles for instance.
comment 14y ago · link · parent
comment 14y ago · link · parent
Fortunately the UTF-8 encoding (e.g. see the Wikipedia page) makes it clear when a byte is the beginning of a new point and it tells you how many intermediate bytes should follow.
comment 14y ago · link · parent
Also, how can "all kinds of things" break with this mark? If something is reading UTF-8 correctly then it'll be fine with the mark; and if it's not reading UTF-8 correctly then it will screw up a lot more than the mark at the beginning of the file.