4 ms·
> Namespaces are a honking good idea - we should do more of them! That should be: english.namespaces english.verbs.are english.articles.a american.english.
by kazinator 10y ago
> Namespaces are a honking good idea - we should do more of them!
That should be:
english.namespaces english.verbs.are english.articles.a american.english.vernacular.adjective.honking ...
- qwertyuiop924 10y agoNo, that's Java. Flat is better than nested: no self-respecting Python programmer would write hierarchy that deep.
- joesb 10y agoSo which rule take precedents here? Namespace is obviously not flat, at least it's more nested than one without namespace. That's the problem I have with people praising Zen of Python as if it means anything. It's like a bible you just pick the verse you like to justify your action even if it might conflict with other rules. Then you praise the whole thing for being so wise.
- qwertyuiop924 10y agoIt means a lot: good python code follows it. However, yes, some of the verses conflict, because it turns out that good advice sometimes contradicts itself. All I can say is don't go too far in either direction.
- LyndsySimon 10y agoMuch of the point of the Zen of Python is that it's self-contradictory.
- eximius 10y agoBalanced, you must be.
- ubernostrum 10y agoNo, Java looks like the famous quotation about the nail and the horse from: http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom...
- deleted 10y ago[deleted]
- pyre 10y agoYou would prefer PHP[1] where the standard library has no namespaces? [1] I refer to "classic" PHP. No clue if anything PHP5+ fixed this, though I doubt that they would make such a breaking changed even across major revisions.
- jwdunne 10y agoThe standard library isn't namespaced. If you want to use a stdlib function inside an NS, you can without issue. If you want to use a stdlib class, or any top level class, it needs backslash before its name or you need to import it. There is a community move towards a standard namespacing with PHP-FIG. This is useful and we are seeing lots of progress on internals thanks to the work by the community. Like a lot of things, PHP name spaces are or were a big mess. Lots of progress is being made to improve though I think a lot must remain. I've thought about creating a project that packages up various categories in the stdlib into namespaces with consistent inputs and outputs. That would be nice but the process isn't a lot of fun.
- kazinator 10y agoYes, I would. And though PHP is widely agreed to be piece of shit (it seems: I don't work with PHP so I'm here only relaying this popular sentiment), that doesn't tarnish the idea by association (which is what I sense you might be trying to do). ISO C and POSIX also have a flat library namespace, together with the programs written on top. Yet, people write big applications and everything is cool. Another example is that every darned non-static file-scope identifier in the Linux kernel that isn't in a module is in the same global namespace. Namespaces are uglifying and an idiotic solution in search of a problem. They amount to run-time cutting and pasting (one of the things which the article author is against). Because if you have some foo.bar.baz, often things are configured in the program so that just the short name baz is used in a given scope. So effectively the language is gluing together "foo.bar" and "baz" to resolve the unqualified reference. The result is that when you see "baz" in the code, you don't know which "baz" in what namespace that is. The ISO C + POSIX solution is far better: read, fread, aio_read, open, fopen, sem_open, ... You never set up a scope where "sem_" is implicit so that "open" means "sem_open". Just use "sem_open" when you want "sem_open". Then I can put the cursor on it and get a man page in one keystroke. Keep the prefixes short and sweet and everything is cool. I was a big believer in namespaces 20 years ago when they started to be used in C++. I believed the spiel about it providing isolation for large scale projects. I don't believe it that much any more, because projects in un-namespaced C have gotten a lot larger since then, and the sky did not fall. Scoping is the real solution. Componentize the software. Keep the component-private identifiers completely private. (For instance, if you're making shared libs, don't export any non-API symbols for dynamic linking at all.) Expose only API's with a well-considered naming scheme that is unlikely to clash with anything.