Live data from Hacker News

Taking PHP Seriously

slack.engineering

641–650 of 673 posts

Re: Taking PHP Seriously

#641
post #616

Earlier quoted context omitted.

Most professional PHP developers I've anecdotally worked with use a Model-View-Controller pattern these days, where the SQL is abstracted away in the model under something like Doctrine2-DBAL, Propel2 or PDO. If I was hiring for a developer and they suggested putting raw SQL in the view layer, I would reject them. If I received a pull request from my team which did the same, I would reject it. You seem unnecessarily…

This exactly. Never been a PHP developer, but I did get handed a PHP webapp to copy some functionality out of for a replacement C# webapp. I was a little surprised to find out that it was written in a rather Rails-like architecture using some PHP MVC library, I think it was CakePHP. Rails was a hit, and a great step forward in web development, so naturally every other language copied as much of it as possible, includ…

Many/most PHP platforms these days do claim to be either MVC or Rails-based or both. CakePHP is not a bad example there. There are however a few other very large projects whose take on MVC is lacking to some degree. Drupal is not bad, Joomla is worse, and of WordPress the less said the better. Note also that those projects are listed in order of increasing popularity.

Modern PHP frameworks and tools are good, perhaps even excellent. Composer and the PSR-# efforts have spurred a renaissance in code quality and interoperability, and PHP7 brings some truly impressive speed improvements. For those of us who aren't stuck supporting legacy code, that is. One of these days I will be working with a language whose syntax I enjoy, but until then the language that puts the "sin" in "syntax" will (for better or worse) keep getting the job done.

Re: Taking PHP Seriously

#642

Earlier quoted context omitted.

PHP devs aren't expensive. Even good ones. It's easier to reroll in another language and retrain or recruit? No. So you probably mean for a new project. So now you've more maintenance and learning curve unless you just happen to have enough skilled in $NEWTHING. Not really easier. PHP is an inconsistent mess, everyone knows that, but it's cheap, widely understood, and it's perfectly possible to write decent maintaina…

> PHP devs aren't expensive. Even good ones. Would'nt the good ones logically move to a different language ( JS/Ruby etc ) where they could bill more?

Money past a certain point is not an incentive. Retraining takes time. It's harder to land jobs for which one does not have relevant work experience. The PHP job market is larger than most other web programming segments, so work is easier to find. But sure, if you're hiring, I'd certainly prefer working with Ruby.

Re: Taking PHP Seriously

#643

Earlier quoted context omitted.

C++ is a C-like language but C++ muddies up the difference between some operators due to operator overloading. This is an inconsistency. Do you support that? No one will ever be able to convince me that " >" make sense to be read and write.

It doesn't matter, we're talking about php not C++. But yeah, " >" are at fairly internally consistent within C++ and don't generally confuse programmers or cause significant bugs in my experience, so I don't find them problematic. They did seem a bit weird at first, but they didn't cause significant problems. Perhaps they do for you, and I accept your complaint about those operators as valid actually, but it's on a…

I'm saying neither of them suck. They both have small things "Wrong" with them that are only "Wrong" because I don't like them.

>they didn't cause significant problems

That's not a valid criticism of any feature. I'd say that the worst feature of any programming language yet has been pre and post -- and ++. Some of the nastiest bugs I've seen have come from there.

In both cases I avoid them. I only really use -- and ++ if I need to, just like ternary operators.

> Just because "other languages suck" doesn't mean php doesn't,

Ok what about other languages that are good? Python's ternary operator isn't the same as C-style languages but I still think of Python as being good.

Re: Taking PHP Seriously

#644
post #455
post #354

Earlier quoted context omitted.

I always wanted to do PHP this way as I have a Perl background but since PHP5 appeared in 2005 the psuedo-Java posse took over and it was PHP Design Patterns everywhere and suddenly procedural/functional PHP was un-idiomatic. I find this odd as Java's verbosity can be forgiven as it gets compiled away. Not so PHP5's verbose OOP which has to be fed to the interpreter.

I wonder if procedural/functional PHP will make a comeback, since functional programming is kind of the shiny right now.

Don't hold your breath. PHP suffers too much from Java envy. PHP5 was game set and match for the PHP Design Patterns crowd and now we have PSRs advocating a coding style in which blank lines and comment-based annotations outnumber lines of real code by a factor of about 10 to 1.

Re: Taking PHP Seriously

#645
We are using PHP7 at stomt. We decided to use PHP for several reasons.

- First of, it is the language i have the most experience with. It would have been stupid to start with some new fancy stuff that would postpone our MVP or getting market/idea/product validation.

Apart from that...

- PHP allows you to write good code, it just does not force you to do it. Means if i need to prototype something really fast i can do so. At stomt we are really focused on writing SOLID code.

- PHP evolves great and became really fast in the last years.

- Economically it is cheaper to find PHP developers than developers in most other languages. And if you have a nice and clean software architecture in place, it is easy to also get more unexperienced developers to write good code.

Re: Taking PHP Seriously

#646
post #621

Earlier quoted context omitted.

> The Wordpress codebase [plugin api included], though, is utter garbage. I've always heard this and never actually used Wordpress myself. Has anyone ever studied WHY its garbage? and how did it get to that state? is it getting better or are the latest additions and changes still garbage code?

Popularity. WordPress is popular, php is accessible (you need notepad and an ftp client to start hacking) - combine the two, and you get a lot of "scratches my itch"-code. It probably doesn't help that WordPress is an ancient code Base with a goal of running on the cheapest webhosts (who are slow to update to newer php releases). So you get a lot of beginners that learn from messy old code, that generate more of the…

The part that I didn't really understand is people accepting pull requests should be gate keepers for code quality, so amateur or not hopefully this shouldn't pollute the codebase. But you've touched on the core being reasonably decent and the real mess being with third party plugins so that makes more sense.

Re: Taking PHP Seriously

#647

Earlier quoted context omitted.

> large often-changing content. This is where PHP is still king of the web. PHP is still widely used, but there's a myriad of other contenders: Java, ASP.NET, Python (Django,Flask,etc), Ruby (Rails), Perl, Javascript (Node,etc) and others. I'm not sure about PHP being the "king". PHP might be the most widely deployed thanks to either FB or the huge number of legacy bulletin boards and wordpress sites, but in terms of…

All of the languages you listed have a way steeper learning curve than PHP. PHP creates a lot of really small steps you can take getting from "I roughly understand HTML" to "I can build a full 3-tier MVC buzzword-of-the-day app.". For anyone not intending to become a full-fledged programmer, but instead just to add a little bit of interactivity/dynamism to their website, it's still the path of least resistance.

I'd argue that Javascript (sans all the frameworks and bullshit) will also get you there quicker, because of the intrinsic DOM connection. But yes, backend JS sucks.

I also made a start with PHP. Still, PHP has been slow to learn from other languages and frustratingly refused to change established behaviour. I found PHP to be far more "dangerous" for the amateur programmer than other languages. Finally, I switched and never looked back.

From teaching beginners, I actually think Python + Flask has a similarly shallow learning curve, but more room to grow and to "do it correctly" (e.g. the templating is much cleaner and the routing much more powerful). I recommend it.

Re: Taking PHP Seriously

#648

Earlier quoted context omitted.

I think you're overestimating how much effort it is to get a PHP dev or deploy environment up and running. This isn't preference and familiarity, it's 20 years more knocking the corners off to lower the barrier to entry.

There's zero work involved in getting a static page up and running. There's minimal effort in getting Node up and running, and I'd put it forward as the new "path of least resistance" especially because of the heroic work done to make Node run properly on Windows. Getting WAMP or whatever configured and installed, or loading the PHP module into Apache or Nginx and getting that working is a giant pain in the ass compa…

`apt-get install php` and you're done. Seriously. Xampp is trivial too.

Re: Taking PHP Seriously

#649
post #467

Earlier quoted context omitted.

I notice you conveniently ignored the meta-programming capabilities of Python which would allow your "nonsensical" improvisation to work just fine. Brush up on your Python skills before talking rubbish.

Classless object literals actually don't make sense in the Python model. It seems like you're the one who needs to brush up. In any case you're not actually providing any links or facts, so unless I dig through long articles on metaclasses in python, I can't verify anything you say. Please prove your point, or at least provide I link so I can verify.

Challenge accepted :-)

It should be interesting to see if I can actually abuse Python's meta-programming enough to make it work :-)

Re: Taking PHP Seriously

#650

Earlier quoted context omitted.

This benchmark shows things a little bit differently. http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan... But I think, what's important to note is that PHP 7 has improved in speed department by a great deal.

It's probably worth mentioning that the regex-dna test time is kind of incorrect and provides an inaccurate view of what's happening. Java-8 is using java.util.regex which is written in Java, PHP is passing the regex requests to it's own regex process which is actually a C package and performs a lot faster. What we're actually comparing here is: time(java.util.regex) > time(php compilation + c regex package)

PHP's execution performance is highly dependent on whether you are piggybacking the C implementations, or pure-PHP ones. That said, this is still a correct benchmark, if your use case involves a lot of regex.
Post reply on HN