Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> what difference does it make if it's a global or namespaces?

I feel that it's often easier to remember short unique name like str2int than long, deceivingly reasonable name like: System.Web.Script.Serialization.JavaScriptSerializer.Serialize

I agree though that array_uniq is same as Array::uniq

> why polluting global namespaces is a bad thing.

Why is that bad for language wide utility functions?

I though global is bad mostly in your own custom code or you application specific libraries because it's accessible from everywhere which hides the dependencies (no to mention global mutable state which makes "action at distance" prevalent).



You love continuing to bring up the Java like example, this discussion however is about PHP. PHP will never have namespacing nested like that in the base language, so no point beating that dead horse.

> why is that bad for language wide utility functions?

There's a handful of reasons, but one important one is backwards compatibility with existing codebases (naming collisions).




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: