4 ms·
> my template engine compiles to PHP's built-in template language No, PHP is a template language... just a very complete one. > PHP is a get-things-done langu
by mbreese 17y ago
> my template engine compiles to PHP's built-in template language
No, PHP is a template language... just a very complete one.
> PHP is a get-things-done language and it always has been
No, PHP is more of a spaghetti language. Sure, it's easy to get something working. Make a tweak here, a bug fix there. If you need a quick knock off, just copy the files, copy and paste a bit, and you're good to go.
But after going through that a few dozen times, you quickly end up with a tangled mess of spaghetti code. Speaking as someone who wrote and had to fix plenty of code (from myself and others) like that, it's not something that I'd like to do. PHP makes it very easy to get trapped like this.
Like any language, it is possible to write good, well abstracted code. Unlike others though, PHP makes is very easy to write bad code. I don't know why... perhaps it's that the learning curve is _too_ low.
The newer versions are definitely trying to elevate the language, but I think that ship has already sailed.
- wvenable 17y ago> If you need a quick knock off, just copy the files, copy and paste a bit, and you're good to go. That's a style of programming, it really has nothing to do with the language. I can cut'n'paste code in any language and I can write nicely abstracted modular code in PHP. Why are you confusing the two? > PHP makes it very easy to get trapped like this. Really? Why is that? What is so different about PHP than every other language in existence? You don't even know, do you? > Unlike others though, PHP makes is very easy to write bad code. I don't know why... perhaps it's that the learning curve is _too_ low. I'm not sure how the learning curve would have anything to do with it. If you already know how to program well, PHP isn't going to break your legs. You're not suddenly going to stop doing good design because of a few dollar signs, are you?
- jrockway 17y agoThe 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?