News for hackers. Stuff that matters.
Re:An Internet of PHP by gleenn on Saturday September 09, 2023 @03:21AM (#37443020)
Bad 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.
Re:An Internet of PHP by iLoveOncall on Saturday September 09, 2023 @03:32AM (#37443085)
> 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.

Re:An Internet of PHP by _rm on Saturday September 09, 2023 @03:37AM (#37443114)
Funny 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.

Re:An Internet of PHP by jiggawatts on Saturday September 09, 2023 @04:44AM (#37443399)
> using frames again.

That’s pretty much what htmx is…

Re:An Internet of PHP by sublinear on Saturday September 09, 2023 @07:13AM (#37444070)
> "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.

Re:An Internet of PHP by fjfuvucucuc on Saturday September 09, 2023 @07:30AM (#37444176)
So like PHP?

This thread is so cope.

Re:An Internet of PHP by trilbyglens on Saturday September 09, 2023 @04:17AM (#37443282)
I 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.
Re:An Internet of PHP by omnimus on Saturday September 09, 2023 @08:29AM (#37444551)
Well React was born in Facebook which was famously PHP codebase. It makes sense.
Re:An Internet of PHP by parminya on Saturday September 09, 2023 @07:15AM (#37444080)
JSX 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.
Re:An Internet of PHP by fjfuvucucuc on Saturday September 09, 2023 @07:28AM (#37444163)
Oh please, I professionally use both daily, JSX is just PHP with more steps.
Re:An Internet of PHP by thewix on Saturday September 09, 2023 @03:34PM (#37449432)
Though not JSX, with TSX you get type checking with your markup.
Re:An Internet of PHP by wildrhythms on Saturday September 09, 2023 @09:46AM (#37445343)
My 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.
Re:An Internet of PHP by bennyp101 on Saturday September 09, 2023 @04:31AM (#37443337)
"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 :)
Re:An Internet of PHP by techsupporter on Saturday September 09, 2023 @05:18AM (#37443538)
Putting 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.
Re:An Internet of PHP by n3storm on Saturday September 09, 2023 @06:33AM (#37443881)
I 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.
Re:An Internet of PHP by chx on Saturday September 09, 2023 @04:34AM (#37443356)
> 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

Re:An Internet of PHP by xigoi on Saturday September 09, 2023 @07:17AM (#37444098)
> 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.

Re:An Internet of PHP by slim on Saturday September 09, 2023 @12:31PM (#37447189)
why?
Re:An Internet of PHP by xigoi on Saturday September 09, 2023 @12:44PM (#37447333)
Because now the behavior of comparison depends on whether the string looks like a number.
Re:An Internet of PHP by chx on Saturday September 09, 2023 @01:33PM (#37447868)
Arguably 48 == "48" should be true. If this doesn't work for you, stick to ===.
Re:An Internet of PHP by xigoi on Saturday September 09, 2023 @01:37PM (#37447927)
Thank 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"?

Re:An Internet of PHP by chx on Sunday September 10, 2023 @06:41AM (#37454605)
Once again: just use ===

If you decide languages based on minutiae like this, I can only pity you.

Re:An Internet of PHP by xigoi on Sunday September 10, 2023 @06:43AM (#37454619)
=== works for equality (if you actually remember to use it), but how about comparison? There's no strict version of <.
Re:An Internet of PHP by chx on Sunday September 10, 2023 @11:39AM (#37456869)
strcmp
Re:An Internet of PHP by tonyedgecombe on Saturday September 09, 2023 @05:23AM (#37443565)
I'd love to see a modern PHP without the language quirks and with a decent standard library.
Re:An Internet of PHP by phyrex on Saturday September 09, 2023 @05:48AM (#37443682)
Re:An Internet of PHP by bawolff on Saturday September 09, 2023 @05:24AM (#37443573)
> 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.

Re:An Internet of PHP by pwdisswordfishc on Saturday September 09, 2023 @08:31AM (#37444566)
That presumably take care of the escaping rules and grammar of the output language, unlike the giant string concatenator that is PHP.
Re:An Internet of PHP by plorkyeran on Saturday September 09, 2023 @01:29PM (#37447822)
Yeah, 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.

Re:An Internet of PHP by bawolff on Saturday September 09, 2023 @07:21PM (#37451277)
There 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).
Re:An Internet of PHP by tinus_hn on Saturday September 09, 2023 @06:33AM (#37443878)
The 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.