Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>The bad rep is totally deserved. PHP, for most of its existence, has been a profoundly bad language per se.

Javascript too, so what? In the end it's another tool with specific pros and benefits, and it got many things right (ease of deployment, no shared state, batteries included, etc).



JavaScript was a bad language though, if not just from it’s messy origins. There’s been a ton of work put into the language and lots of thought put into the ’good parts’ to use and expand upon.

I’d be interested in learning more about php’s evolution, and possibly even a follow-up to that article.


I have written both PHP and JS for a living since about 2005 (for my sins) and I can tell you PHP has gone through at least as much of an evolution as JS. Neither one feels anything like its 2005 ancestor.


I started programming with PHP back in 2001, I think. I moved to C# when dotnet was released shortly after, but still have a personal website that's built with PHP, and a couple of years back I updated it (from something like PHP 4/5, I forget) to the latest version PHP. I was pleasantly surprised - it wouldn't be my first choice by a long shot, but I can see why others would choose it today. And there's always been a good community around it too.

I also started with JavaScript a long time back, maybe something like 1998-1999. I've always found it a most loathsome language, and the anaemic standard library a huge barrier. It's not entirely the language's fault, of course - being the language of the web was always going to mean glacial progress. Recently I worked on a vanilla ES6 project (since browser support is finally there), and at long last I wouldn't quite describe it as "loathsome" anymore! Still, it's a far cry from the nicities of Typescript, and the tiny standard library remains an issue.

Having seen both PHP and JavaScript evolve over around 2 decades, I'd probably argue that PHP has evolved more as a language than JavaScript has.


Unlike JS, Google doesn't endlessly push PHP. Having written in both of them (and prefer neither) they're equivalent outside the marketing budget.


JavaScript even in 1996 was much saner language than PHP. Surely there were bad parts, but in JS you could just ignore them. In PHP on the other hand one had to build on top of bad parts since there was no good alternatives.


In JavaScript you still have to deal with all the bad parts. That’s why we pretty much require monstrosities like babel, webpack and whatever other build tools you can imagine.

If you want PHP, you install php, and you’re done.


>In PHP on the other hand one had to build on top of bad parts since there was no good alternatives.

What exactly was so bad in PHP that you couldn't also ignore?


Someone posted an article above [1], but citing from it, there is a function called mysql_real_escape_string. Although early JS also has quite odd language choices, it follows a consistent philosophy. To me it boils down to LISP in C syntax with weak typing. Past PHP feels more like a collection of stuff. But I assume modern PHP can be a viable choice if used with a modern framework, linter etc.

[1] https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/


PHP follows a consistent philosophy as well. The PHP functions are usually named after the C functions they wrap. And in fact: The MySQL C client library contains a function called mysql_real_escape_string.

see: https://dev.mysql.com/doc/c-api/8.0/en/mysql-real-escape-str...


this code is blowing my mind -

$arg = 'T'; $vehicle = ( ( $arg == 'B' ) ? 'bus' : ( $arg == 'A' ) ? 'airplane' : ( $arg == 'T' ) ? 'train' : ( $arg == 'C' ) ? 'car' : ( $arg == 'H' ) ? 'horse' : 'feet' ); echo $vehicle;

can someone explain to me why it should print out 'horse'? (what the article above says)

on edit: oh I get it, the false of the ternary statement here is on the left so when $arg == 'T' the true does ( $arg == 'H' ) which is false, hence printing out horse.

Well there's no reason true has to come first, but it is a c-flavored language so sort of weird it doesn't.


I haven't used PHP is a professional project for probably 10 years, aside from needing to poke around in Wordpress occasionally. When I see modern PHP, I barely recognize it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: