Live data from Hacker News

PHP is worth learning and using

bulletproofphp.dev

421–430 of 468 posts

Re: PHP is worth learning and using

#421
post #61

Earlier quoted context omitted.

For people of a certain age and job history, the worst code they've ever inherited was written in PHP. I think JS can be worse. There are things that are possible with dynamic languages that are literally impossible with static ones. So think of PHP less as a "bad language" and more of a code smell.

I don't think any JS code can be worse than old PHP code. I've had to deal with legacy software written with PHP4. I was to port it to PHP7 since it was not compatible with PHP5.4+. The code used "register globals", meaning that variables were created on the fly from the parameters in the URL, the POST form data, and the cookies. Requesting `index.php?something=X` implied `$something = "X";` in the global scope at th…

I don't know man, cleaning up legacy PHP can be kinda fun, but when I work with some batshit insane piece of JS I feel like I'm going psychotic.

Re: PHP is worth learning and using

#422

A simple sniff test thats tried and true still holds. ANY programming language that requires you to use a framework to actually be productive fails the test. PHP is doing very poorly in this realm. How many PHP websites out there are actually using a few libraries and the stdlib only? Not many. Its frameworks, frameworks frameworks. In the PHP case its actually even worse, as there are a multitude of CMS sysytems tha…

Php can be immensely productive to develop web apps in, it has all the things u need out of the box no libraries needed. Infact that is how most of the old php was written. Nowadays people use frameworks bcz they find themselves more productive

Re: PHP is worth learning and using

#423
post #366

Earlier quoted context omitted.

While I primarily program in python these days I have two major open source PHP projects (millions of downloads each). I was also part of the standards group that tried to modernize some aspects of PHP (to various degrees of success). In general I would never bring them up on this site. It's just not worth my time or effort. I've even gone so far as to ask people who have posted my blog posts here to take them down.…

> Hacker News has one of the worst groupthink cases in tech, where if you speak against various core beliefs you get absolutely hammered with trolls both on the site and off of it. Aside from PHP, can you think of any other topics that can be problematic in this regard? So far i haven't personally run into any that would get me disproportionate amounts of negative votes, however i find myself curious about it. The on…

Answering this question is tricky because any answer is essentially inviting trolling. This community has both extremely technical people as well as a variety of people who basically live on 4chan (and there is quite an overlap between the two) so things can get dicey in that regard.

Just some hivemind topics-

* Free Speech. This community tends to be extremist about this, which in turn means anything that can be construed as limiting free speech will, somewhat ironically, not result in a productive conversation.

* Corporate Libertarianism. This community also tends to be extremely pro-corporate, and there's a lot of "if you don't like it work somewhere else". That being said I've seen some push back against this lately.

* Meritocracy. If you challenge the idea that silicon valley is a meritocracy people seem to get really upset.

I would definitely say that there are reddit communities that are worse, and some that are better.

Re: PHP is worth learning and using

#424
post #387

Earlier quoted context omitted.

You hit the nail on the head, this is exactly why I fell in love with PHP. I learnt it back in the PHP4 days, and it just seemed like the perfectly straightforward way to do web. In a similar fashion, I abstracted away the database connection, query and returning of results into one lazy-inited function, so talking to the database really was just like I worked a lot with other languages, none feeling as natural to me…

Be careful as this syntax can potentially introduce SQL injections. PHP's parameterization features in PDO can be abstracted so you can turn this into: $vars = array(":userid" => $userid); q("select name from users where id = :userid", $vars); It's still pretty concise and is much safer.

Parameterized queries and statements are great. They solve problems where the paramaterized queries are used. However care must be taken, a script running on the database after information has been entered can still inject long after the initial parameterized statement put it into the database if that script itself does not use parameterized queries, making a SQL injection still work, in a delayed way.

Re: PHP is worth learning and using

#425

Earlier quoted context omitted.

No doubt there are people reading this message who speak Japanese who will correct me, but ... 30 years ago I studied Japanese a little bit. One interesting feature of the language was that once a subject was introduced, there was no need to restate the subject if it hadn't changed, resulting in paragraphs like the one which intrigued you. "I have used PHP for years." The first sentence establishes the subject is "I"…

This is called pronoun dropping [1] and happens in quite a few languages, including Japanese as noted. I had a friend in college who would always point it out (in English, where it's not very common). I still notice it often years later and I'm pretty sure it's thanks to her making me aware of it. [1] https://en.wikipedia.org/wiki/Pro-drop_language

Interesting. The Chinese examples on the wiki page sounded completely natural to me and are in accordance with how I speak/interpret the language, but I never realized I was dropping pronouns due to their inference.

Thanks for the insight!

Re: PHP is worth learning and using

#426
post #423

Earlier quoted context omitted.

> Hacker News has one of the worst groupthink cases in tech, where if you speak against various core beliefs you get absolutely hammered with trolls both on the site and off of it. Aside from PHP, can you think of any other topics that can be problematic in this regard? So far i haven't personally run into any that would get me disproportionate amounts of negative votes, however i find myself curious about it. The on…

Answering this question is tricky because any answer is essentially inviting trolling. This community has both extremely technical people as well as a variety of people who basically live on 4chan (and there is quite an overlap between the two) so things can get dicey in that regard. Just some hivemind topics- * Free Speech. This community tends to be extremist about this, which in turn means anything that can be con…

Thank you for your input! While the SV bit probably isn't relevant to any of the topics that i might touch upon, I'll keep that in mind.

That said, in regards to freedom of speech, i feel like some of Bryan Lunduke's (just as an example) arguments wouldn't necessarily invite hostility, despite their delicateness - such as the idea of de-anonymizing the internet and what implications that could have and what it'd look like.

Of course, it might invite prolonged discussions with no clear conclusion, because there are just societally complex topics with layered tradeoffs where no one can definitively cover all of them, but in my eyes that's not necessarily bad, as long as everyone remains civil.

I know I've certainly been wrong about a lot of things, though thankfully people so far have corrected me and let me better myself.

Re: PHP is worth learning and using

#427

Hmmm... Most points in this article are shouting "yeah we have those too!!" but it didn't give any convincing arguments why I (or anybody who doesn't already know PHP) would like to learn and use PHP over other decent modern languages and ecosystems, which happen to have those points as well.

My favorite thing about PHP is the execution model. Every single request is brand new and runs the whole program start to finish. IMO that's extremely powerful in its simplicity and while you can get it in other languages, it feels like like a "core competency" for PHP (just like how async code is easier in javascript than in python, because JS kind of had it from day 1)

Isn't that exactly the same as most web frameworks except without a few lines of code saying something like "when this URL is accessed, run this function to handle it"?

Re: PHP is worth learning and using

#428
post #336

I'll be honest. I really don't like PHP. However when I was running a coding workshop, very frequently people would ask: "How do I make a web page talk to a database?" I'd say: Well, you know that HTML file? Rename it to become a PHP file and you're almost there! As pretty much all cheap hosting already offers support for PHP (and MySQL for that matter) this would almost always work. I would love to be able to do thi…

You need to try swoole/ openswoole - it brings golang style concurrency to php. you dont need to use nginx/apache and it beats node in performance tests.

https://www.swoole.co.uk/

Re: PHP is worth learning and using

#429
post #366

Earlier quoted context omitted.

While I primarily program in python these days I have two major open source PHP projects (millions of downloads each). I was also part of the standards group that tried to modernize some aspects of PHP (to various degrees of success). In general I would never bring them up on this site. It's just not worth my time or effort. I've even gone so far as to ask people who have posted my blog posts here to take them down.…

> Hacker News has one of the worst groupthink cases in tech, where if you speak against various core beliefs you get absolutely hammered with trolls both on the site and off of it. Aside from PHP, can you think of any other topics that can be problematic in this regard? So far i haven't personally run into any that would get me disproportionate amounts of negative votes, however i find myself curious about it. The on…

Just mention the chat program Telegram. You will have 200+ people immediately dissect everything that its creator ever said and did. Which I don't mind at all but you can see extremely anti-Russian sentiments straight from the middle of the Cold War. Very puzzling. There's not even good factual discussion most of the time.

For bonus points, do state one provable and visible fact: that Signal (the program that's always recommended as a replacement for Telegram in HN) is not completely open source either, and then suddenly even more people appear to explain to you how that's somehow okay for Signal but not for Telegram. Even more puzzling.

Another one: mention Rust, no matter how. Somehow you're suddenly a zealot, you work with a "flavor of the week" language apparently (nevermind that it's at least 10 years old), and you also feel the need to tell everyone about it everywhere you go, and let's also not forget that C++ can do everything that Rust can and you're a bad programmer for not realizing it. I learn so many new things about myself every time I mention Rust around here! (warning: this was sarcasm)

HN isn't as neutral and factual as you might be imagining it. I've seen ugly and shameless appeals to authority by very prominent and high-profile members of this community.

Re: PHP is worth learning and using

#430
post #315

Earlier quoted context omitted.

All shared hosts already come with LAMP pre-configured. You just plug already supplied credentials into the WordPress setup page and that's it.

So does ex. heroku for all the other languages, and that actually scales. As well as most shared hosters offering node and rails. Don't get me wrong, my whole point is that this 'simplicity' is given in any ecosystem these days. Except live coding via FTP is something you consider part of the simplicity, then you are stuck with PHP :)

This is not accurate. While some shared hosts offer node or rails you will be limited by memory and it might not even run your app. The reason PHP is so good for shared hosting is that it runs per request and when you have rarely visited PHP application it requires basically no resources. You can have 100s of small websites sharing resources that get few visitors a day on single server and it will be fine. Try doing that with node or rails which are application servers that need to run all the time.

Heroku is fine but imagine you are agency managing 50 small sites. Heroku is like 7usd month minimum? You can pay 350usd month for Heroku or put it all on 20usd VPS and result will be same.

That's why all self-hosted CMSes worth something are in PHP world and there are very few in python/rails/node.

Also its not like PHP devs have been living under a rock for 20 years and don't want nice things. Git deployment is offered even by many shared hostings, people use SFTP+rsync, or things like https://deployer.org/. And there is very active market of server management tools like https://forge.laravel.com/ https://ploi.io/ https://moss.sh/ that combined with attributes of PHP will give you your own little super easy heroku.

And scaling... well most people don't need scale, you scale CMSes by caching anyway. And you can run pretty big scale just on one machine. And if you want automatic extreme scaling it's not like you can't do that with PHP https://vapor.laravel.com/

Post reply on HN