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

> I do think code organization is one of the primary jobs of a programming language/ecosystem. I want my tools to help me be better about that, not worse.

Isn’t splitting up all your classes into separate files considered to be a good thing?

Considering how huge we can make files in JS I’m sort of inclined to consider that a problem instead of a feature.

I think any project that started around PHP 4/5 will look like Wordpress. Looking at more recent projects (after PSR’s became a thing) would be more representative.



It is but when you use third party code, what guarantees do you have that it didn’t do something stupid like declare a variable like $TIMEOUT? Whether on purpose or by accident. And of course any class or function become global even if you run include/require inside the body of a function or a method.


Include inside the body of an anonymous function if you care about toplevel $TIMEOUT=123 overriding some global variable.

Anyway you don't have any guarantees in JS either, for example. Imported module can just redefine Date object prototype or any global via globalThis. If you don't trust the libraries to not make a mess, don't use them is the only real solution. And it will be completely silent as opposed to PHP failing loudly when you try to redefine constant or class or function.


Variables would stay inside the scope of your anonymous function. Functions and classes will become defined globally. Surprise!




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

Search: