6 ms·
Every time I see an article like this I thank God I'm not using PHP. It's always, "Remember to always use do_something() instead of dosomething() or else someth
by Sizlak 15y ago
Every time I see an article like this I thank God I'm not using PHP. It's always, "Remember to always use do_something() instead of dosomething() or else something will suck for some reason."
- wvenable 15y agoThis article is a serious micro-optimization and, in general, not something people should be that worried about. If you nit-pick enough, all platforms have these sorts of issues.
- jessedhillon 15y agoIn a good language, include/require[_once] should all be reduced to the same one statement, e.g. Python's import. Don't you think it's a ridiculous notion that the distinctions between include and require (and the once variants) are meaningful enough that programmers should be able to express them?
- evan0202 15y agoPHP using __autoload and namespaces looks and feels exactly like Python using imports. You see, the PHP developers have been actively improving a lot of aspects of the language recently, and the latest release, 5.3, had a ton of really nice improvements and features, such as namespaces. I'm not going to say PHP is the greatest language every invented, and in fact I am a huge fan of Python. But I do not think PHP deserves the "In a good language..." treatment. It is a language that is getting better everyday, with a strong and vibrant development community and massive user adoption. It is a good language.
- ooh456 15y agoamen. nobody chooses to use php on new projects but at least it's easy, fast, and pays the bills.
- harisenbon 15y agoReally? I choose it every time I have a choice. Especially with a Rails-like framework like CakePHP, I find that my programing time is lessened dramatically because of the framework, and my processing time is much lower than Rails because most of the servers I work on are optimized out the wazoo for PHP instead of Ruby. But your mileage may vary.
- jessedhillon 15y agoSorry, I have to disagree with you. A language whose maintainers decided that, in the fifth major release, `goto` needed to be added is not getting better. Nor is one whose maintainers rationalize the choice of backslash as a third, distinct scope resolution operator -- instance-attribute, class-attribute, and now namespace-member. The sheer number of fails with PHP warrants the 'good language' treatment. The fact that, 08 === 0 alone is enough to make it deserving of this treatment.
- randallsquared 15y agoDon't you think it's a ridiculous notion that the distinctions between include and require (and the once variants) are meaningful enough that programmers should be able to express them? Not at all. They mean different things, and they're used for different things. Import-if-it's-available is include, import-or-error-if-missing is require, and they're both quite handy. The once variants do what most programmers would expect, but the non-once ones do what most template users would expect. Should the "once" have been a flag? Yeah, why not? But that doesn't mean the functionality shouldn't even exist.
- jessedhillon 15y agoThe `once` distinction is a product of bad design and it only exists when you have a language that is both the templating (view) language and the processing language. To those of us accustomed to good languages, it's like saying "the language allows me to call render_once() so that I don't re-render a template I've already rendered." When the problem is framed thus, most people would recognize that the solution to that problem is a better understanding on the part of the programmer of the flow of control inside his/her application. The error handing should be done with exceptions. As it is, there are many errors in PHP which are recoverable, but they don't throw exceptions but instead emit other kinds of non-catchable failures. In Python, you would simply `try` to import a module and `catch` a failure to do so, e.g. if that module wasn't installed.
- wvenable 15y ago> The `once` distinction is a product of bad design and it only exists when you have a language that is both the templating (view) language and the processing language. PHP takes it's cues from C -- that's where the idea of include() and require() come from. These functions pre-date the existence of OOP in PHP. There was a time when even the _once() functions didn't exist and you had to manage that yourself. It's best to think of these functions as low-level building blocks you can use to build on your own abstraction layer. I never call those functions directly. > The error handing should be done with exceptions. PHP supports many styles of development. If you prefer errors, you can have those. If you prefer exceptions, you can convert all errors to exceptions with only a few lines of code (there is even a built in exception type for this purpose).
- troels 15y ago"Remember to always use do_something() instead of dosomething() or else something will suck for some reason." I'd say that is the case for any language.
- uriel 15y agoReally, every time I hear of PHP I honestly ask myself: "why on earth would anyone want to be using PHP in this day and age?" It is like seeing people trying to cure cancer with leeches.