3 ms·
The dollar signs are not the problem with PHP's variables. Their global scope is. But anyway, well-abstracted PHP ends up looking like Java -- very verbose.
by jrockway 17y ago
The dollar signs are not the problem with PHP's variables. Their global scope is.
But anyway, well-abstracted PHP ends up looking like Java -- very verbose. Quick example; if you want to pass around a callback that has state, you have to make it a class, since there are no closures (instances of classes and closures are about equivalent). This is, however, a lot of typing to do something simple. Instead of a quick one-liner, you now have a new file and a new class, or, at the very least, an interface and anonymous class. Messy.
You can't abstract away that pattern, either, as there is no MOP (to auto-generate the classes as needed), or macros (to at least type in the code for you automatically).
Anyway, something that's just a few characters in other languages is now multiple files. Sure, it's well-abstracted and pretty easy to understand. But it's also massively over-engineered, and distracts from the task that you were actually trying to accomplish.
If you are going to write PHP code that looks exactly like Java, why not just use Java and get your 70x speed boost?
- wvenable 17y ago> The dollar signs are not the problem with PHP's variables. Their global scope is. I think you sort of have that backwards, all variables in PHP are local unless you go out of your way to make them global (or just start typing into an empty file without any functions). I pretty much surrender the global scope. None of my variables are global except for static class members. I don't have any global functions, except static class methods. > Quick example; if you want to pass around a callback that has state I don't pass around callbacks that have state very often. I tune my programming style to the language that I'm working on. Often there are different ways of handling the situation in PHP -- it's is actually quite dynamic in places. I prefer to keep my pages pretty KISS anyway -- I can do hell of a lot (see my other replies) without needing stateful callbacks. > If you are going to write PHP code that looks exactly like Java, why not just use Java and get your 70x speed boost? I don't know, why are Java sites so painfully slow and all PHP sites so fast?