3 ms·
> Do serious PHP developers use PHP's built-in template language? No. However, my template engine compiles to PHP's built-in template language. > In exchange
by wvenable 17y ago
> Do serious PHP developers use PHP's built-in template language?
No. However, my template engine compiles to PHP's built-in template language.
> In exchange for not having to understand abstraction or OO
My PHP code is just as object-oriented as my C++, Java, or C# code. As for the functions, you memorize what you need and have a good IDE for the rest. One of the benefits of PHP is that there's a function for just about every common task and using them is really easy. Other languages may have the same functionality in a library, but the setup and calling is far more complicated.
PHP is a get-things-done language and it always has been. You can dick around with all the abstractions, frameworks, and meta-programming you want but often that's just more complicated and a waste of time.
- wvenable 17y agoSo I've been voted down for having an opinion -- way to be open minded hacker news.
- strlen 17y agoI think your close minded attitude ("I don't want to learn anything outside of my comfort zone, as it isn't clear whether it will get me from point A to point B") and vulgarity ("dick around") is what got you the down votes.
- wvenable 17y agoGiven that I already stated a wide range of skills beyond PHP (and I use more languages than I even listed there) I hardly think my closed minded attitude is the problem. There are a lot of complaints about PHP from people who've never even used it. They have bullet-point list of features lacking or strangeness and think they can make an informed comment. But I have built several large scale projects in PHP and at the time I started them most everyone's pet language here was too immature in the web space to consider. Look at Ruby, the tools of choice for deploying it and serving it up are constantly changing. I don't have time for that fire and motion. Maybe for the next project I will choose something else. But I think developers here would rather fawn over the pet language of the week than hear from someone using PHP effectively.
- jrockway 17y agoLet me say that I have used PHP extensively, and found it to be incredibly painful. It basically allows the expressiveness of C with classes. It is possible to write working applications like this, but that's about all I can say. Given the choice, I would pick absolutely any other language. Even a tiny bit more expressiveness makes me happier and more productive. The only reason I can see for picking PHP for one's own internal applications is ignorance. Any language is better.
- wvenable 17y agoWhen I started my last big project it was several years ago and PHP5 had just been released. I had been doing PHP for many years before that (since PHP3 -- moved from Perl to ASP to PHP). At the same time I've been doing desktop and mobile development in C++, VB, and C#. I also keep up with Python and other tools to see how things are progressing. So I needed to start up a new project those years ago and it really wasn't the best time to learn another language. Ruby and Python were still a bit lame in the web space at that time. I'm not even sure Rails was out at the time; and if it was it was really new. I definitely didn't need to start a massive project on something that was very much untested. Performance and stability are also factors. You are entitled to your opinion, but I don't find PHP to be all that painful. I've built up a large body of code and, more specifically, a coding style that makes PHP as productive to me as most other languages. For example, all my objects inherit from a root Object class that provides automatic properties: declare a method as setFoo and you use $object->foo = 'hello' to call it. My framework library is very modular and uses the autoload facility. I have a template library that is like smarty only less weird (and much less code). I have a few different database abstractions for different needs. Entity objects that can be loaded and saved. Classes for quick inline queries (similar to what you've used in other examples). An an abstraction for larger more complex SQL queries. In addition to basic templating for the UI, I also have something akin to ASP.NET user controls so I can built up complex forms just by adding tags to the template. The UI is connected end-to-end with the database so load, save, and validation is automatically generated (including client-side javascript) from a description of the data. I can push about a CRUD page in minutes. So really, I have lots of reasons besides ignorance to stick with PHP at this point. Now, if I had to start the project again now, I'd have re-evaluate all my options but it would have to weighted against the body of code and knowledge I already have. I won't claim that PHP is better than any other language -- but it's really not as bad as you make it out to be. Just look at all the things that are possible in it!
- 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?
- jrockway 17y agoYou can dick around with all the abstractions, frameworks, and meta-programming you want but often that's just more complicated and a waste of time. PHP is itself an abstraction. CPU instructions don't generate HTML, after all... It is interesting that you assume PHP is the perfect level of abstraction. I think that is called "blub". You should try deeper abstractions some time. Today I wrote a complicated database query joining by saying "$securities_rs->find({ security => 'USD', month => DateTime->new( year => 2009, month => 1 )})->messages->users->count" to see how many users looked up data on the USD for 2009/1. It is one SQL query, and there is no speed hit for writing it this way. A bit of abstraction made my app infinitely flexible; any query I can imagine is just a line of Perl. Abstraction is good. Don't think that pounding on your keys as fast as possible makes your productive -- it doesn't. Thinking about your application's needs and designing your code to be easily tweaked to fit those needs is what you really want to do. When you have a mess of SQL, HTML, and PHP all in one file, you are stuck with what you wrote forever. When you abstract things, big changes only involve a small amount of code.
- wvenable 17y ago> It is interesting that you assume PHP is the perfect level of abstraction. It's interesting you assume I said that, but I did not. In PHP you can have all kinds of levels of abstraction (and I use a multitude of levels). It is just as interesting that you assume most levels of abstraction are not possible. If you call that a complicated a database query, we're clearly working at different levels. Get back to me when you hit 100 lines of SQL. > I think that is called "blub". You should try deeper abstractions some time... Don't think that pounding on your keys as fast as possible makes your productive -- it doesn't. The self-righteousness and ignorance here is absolutely astounding.
- jrockway 17y agoIt's interesting you assume I said that, but I did not. In PHP you can have all kinds of levels of abstraction (and I use a multitude of levels). It is just as interesting that you assume most levels of abstraction are not possible. Your initial post called this "a waste of time". That is why I assumed you didn't do it. If you do do it and think it's a waste of time, you are probably doing it wrong, as the rest of the programming community disagrees with you. Also, you have 100 line SQL statements embedded in your PHP programs? That is the wrong level of abstraction. The point of my abstraction is that a quick one-liner is the same mental complexity as your supposed 100-line statement. The idea is that most of the complexity is abstracted away by specific names. You compose the specific names into something that ends up being physically complex, but mentally simple as you are reading your code. Anyway, probably not worth arguing with you, since you are quick to make personal attacks, aren't consistent with your own ideals, and won't discuss anything specific. (Well, I guess you will discuss how many lines of code something is.)