10 ms·
I've always liked PHP. You wouldn't pick it for your job interview's coding test if you had a choice (Python all the way there), but it's so intertwined with th
by jalapenos 3y ago
I've always liked PHP. You wouldn't pick it for your job interview's coding test if you had a choice (Python all the way there), but it's so intertwined with the internet and what we've learned about programming over the years. First mover advantage kind of deal.
And I've never had to deal with ESM/CJS/AMD whatever module nonsense with PHP. No transpiling anything, just edit and refresh. And so many useful functions out of the box (array_column anyone?).
I think its bad rap comes from its ubiquity. Pretty much any existing website I've had to work on has been a putrid mess. That's just the way codebases go unless you're a SaaS with a CTO who's hell bent on preventing that.
And since most of these putrid messes have been based on PHP, due to it's age and ubiquity, people blame it, due to observation bias.
- gleenn 3y agoBad rap comes from the inconsistency of the early APIs. The ability to interleave code and HTML was also tacky and never taken seriously but I think touted highly by some as a killer feature. The language is very unplanned, go look at an equality chart for PHP, it makes JavaScript blush as well.
- iLoveOncall 3y ago> The ability to interleave code and HTML was also tacky and never taken seriously And yet people would take a bullet for React and the JSX templates.
- jalapenos 3y agoFunny how "server side rendering" became a hot new thing too. I was so confused when I heard that, "like... a HTML file?". Keep going at this rate and we'll be using frames again.
- jiggawatts 3y ago> using frames again. That’s pretty much what htmx is…
- sublinear 3y ago> "like... a HTML file?" Serving a static HTML file is not server-side rendering. It's much dumber than that. The people advocating for SSR want the server to respond with HTML generated based on whatever is in the request.
- fjfuvucucuc 3y agoSo like PHP? This thread is so cope.
- deleted 3y ago[deleted]
- trilbyglens 3y agoI too find this hilarious. Not because I want to defend PHP, but moreso that I personally sort of despise react and it's whole ecosystem. I've never liked writing code less than when dealing with a spaghetti monster react app.
- omnimus 3y agoWell React was born in Facebook which was famously PHP codebase. It makes sense.
- parminya 3y agoJSX and PHP are actually seriously different. When you break out of PHP, you're just outputting text to standard output. When you're using JSX syntax, you're constructing Javascript objects that can be manipulated using standard javascript techniques. Anyone who believes they're comparable seriously doesn't understand the task that is before them.
- fjfuvucucuc 3y agoOh please, I professionally use both daily (enjoy them both), but even I can see JSX is just PHP with extra steps.
- thewix 3y agoThough not JSX, with TSX you get type checking with your markup.
- wildrhythms 3y agoMy reading of this thread is that people are comparing JSX as a templating language to PHP as a templating language, splicing PHP <? ... ?> into HTML like how we have { ... } in JSX. At the end of the day React lets you write a function that returns HTML just like a PHP file.
- bennyp101 3y ago"The ability to interleave code and HTML was also tacky and never taken seriously" - That was the whole point of it! The day I found PHP and could leave behind the cgi-bin and SSI it became my favourite thing - and has paid me well for the last 20+ years :)
- techsupporter 3y agoPutting HTML inside of scripted code blocks was legendary back in the day and every web-oriented language did it. I guess people have already forgotten about ASP and ColdFusion. Being able to for each an array into table rows? Game changing.
- n3storm 3y agoI have been coding in coldfusion (openbluedragon) on 2012. Still lurks in my dreams. I refactored to components (objects) some functionalities as a POC, it did not fit well with the main programmer.
- chx 3y ago> The language is very unplanned, go look at an equality chart for PHP, it makes JavaScript blush as well. This has been fixed in PHP 8. https://wiki.php.net/rfc/string_to_number_comparison https://wiki.php.net/rfc/string_to_number_comparison
- xigoi 3y ago> make non-strict comparisons more useful and less error prone, by using a number comparison only if the string is actually numeric. Otherwise the number is converted into a string, and a string comparison is performed. That… makes it even worse.
- slim 3y agowhy?
- xigoi 3y agoBecause now the behavior of comparison depends on whether the string looks like a number.
- chx 3y agoArguably 48 == "48" should be true. If this doesn't work for you, stick to ===.
- xigoi 3y agoThank you, I'll stick to languages where you can't just compare numbers and strings without an explicit conversion. Also, should 48 == "48.0" be true? How about "048", "48.", "0x30", " 48 ", "48foo", "3*16", "XLVIII", "forty-eight"?
- chx 3y agoOnce again: just use === If you decide languages based on minutiae like this, I can only pity you.
- tonyedgecombe 3y agoI'd love to see a modern PHP without the language quirks and with a decent standard library.
- phyrex 3y agohttps://hacklang.org/ https://hacklang.org/
- bawolff 3y ago> The ability to interleave code and HTML was also tacky and never taken seriously but I think touted highly by some as a killer feature. And yet people seem to keep inventing variations of this as "templating" languages.
- pwdisswordfishc 3y agoThat presumably take care of the escaping rules and grammar of the output language, unlike the giant string concatenator that is PHP.
- plorkyeran 3y agoYeah, a big problem with the traditional PHP-in-HTML approach to generating web sites is that it's one of the areas where PHP hasn't dramatically improved since the early days. Later templating engines learned from the problems people encountered with PHP and were built to be aware of the output format, and PHP never did that. A lot of work was put into writing templating engines in PHP that in retrospect really should have instead been a language mode for PHP itself. We would have seen dramatically fewer bugs and injection attacks over the years if PHP had made <input value="<?=$value?>"> a perfectly safe and normal thing to write back in 2005.
- bawolff 3y agoThere are actually shockingly few context-sensitive templating languages for php and those that exist don't seem that popular (Latte is the main one I'm aware of). Most of them are more of the giant string concatenation type, maybe with escape by default semantics (e.g. Smarty, Mustache).
- tinus_hn 3y agoThe bad original library, the original lack of features that help against bad coding practices and the fact that it is so accessible to beginner programmers that you’ll find a lot of beginner code. The ability to mix html and code means it’s extremely easy to get started which is the big strength.
- kxrm 3y ago> You wouldn't pick it for your job interview's coding test if you had a choice (Python all the way there), I do actually pick it for several reasons. 1. I want to know if the environment I am going into is pragmatic about languages. If you are going to refuse to continue working with me over something so minor as PHP then we aren't a culture fit. 2. I want to showcase my best. I know this language in and out. It's the first language I learned and I have the greatest ease of building algorithms with it. I've had interviews where I was asked to do something with PHP that PHP did not support and I found ways to make it work. 3. In some ways I love the conversation that comes with positive interviews when using it. Oftentimes the interviewer isn't very familiar and it sparks discussion on the languages benefits and drawbacks further showcasing my skillset. Sure as we progress along in the interview process I will switch to whatever language the company uses primarily but if I get a choice I always choose PHP.
- deleted 3y ago[deleted]
- jalapenos 3y agoThat's a good point, I imagine doing that would screen out companies run by language snobs. My go to for this is to say "I don't think Typescript is needed most of the time". The snobs look at you like you just farted in their face. But having done some coding interviews where time and space complexity were a factor, I found it easier to succeed with Python.
- JuanPosadas 3y ago> "I don't think Typescript is needed most of the time This is a terrible example, typescript (especially in 2023) is basically free with most setups (including vanilla) and easy to ignore for velocity then optionally enforce typechecking later. A much better hill to die on would be large frameworks/tooling like react/angular/webpack.
- jalapenos 3y agoExactly. If the interviewer responds like that, they've told me the company culture, and I know to stay away.
- deleted 3y ago[deleted]
- tommica 3y agoI've gotten a lot of value by being able to go to a library in my vendor folder, and add some var_dumps in there to figure out where my code is going wrong. The way the dependencies works is magnificent.
- djbusby 3y agoXdebug?
- danmur 3y agoI haven't used it for a long while, but I did a LOT of PHP5, several years. In my opinion PHP4 was horrific (from a language/standard library perspective, most languages you can get what you want done regardless of that), a lot of it carried over into PHP5 despite being a lot better (e.g. see phpsadness). Then the fiasco that was 6/7/whatever made it really hard to have confidence in the future of PHP. No idea how recent PHP is. It's hard to escape those opinions that formed fairly widely in the industry is, though.
- matthiaswh 3y agoPHP is akin to, I don't know, the Subway (fast food restaurant chain) of programming languages? You don't hear too much about it. You almost never notice it unless you're actually looking for it, unlike McDonald's with its ostentatious golden arches. It's popularity is waning. But it's still everywhere. [0] There are a hundred other sandwich chains that have tried to do it better but none have managed the ubiquity of Subway. People like to look down on it and espouse the alternatives, but when it comes down to it fast food can only ever be so good. I guess that means that JavaScript is McDonald's? [0] https://en.wikipedia.org/wiki/List_of_the_largest_fast_food_restaurant_chains https://en.wikipedia.org/wiki/List_of_the_largest_fast_food_...
- nolok 3y ago> It's popularity is waning. I don't think that applies though. If anything, laravel is pushing PHP into another "golden age" not seen since code igniter 2, with again a framework that does things not quite how they should be under the hood, but definitely how people need them to be to be fast and efficient, except this time backed up by a proper package management system, a much better and stronger language and an ecosystem based on reusable modules. Does it have the favor of the modern hype or new language seeker or anything like that ? No, absolutely not, but when has PHP ever had that ?
- b112 3y agoThere will be no golden age for anything using node.
- lproven 3y agoThat's a fun list. Of over 100 I have only heard of 1/3: 35 in total. I have only ever been into and eaten anything from half of those. So fully 2/3 of the list I've never even heard of. Interesting.
- outofpaper 3y agoWith this analogy python would be the Ikea. You can go for the fast food (site scripting) or you can get really invested and build out your ML modules with it at scale ( remodeling a decking out your kitchen)