lainchan / λ
PHP vs JavaScript
Boris Grishenko · 2022-11-23 06:27
Why I see many tech-savvy (imageboards, private trackers etc.) websites use PHP instead of JS, shouldn't JS be way faster then PHP, and isn't PHP just a prototyping language?
if · 2022-11-23 06:31
>>33441
Speed is negligible for the applications you describe. You could get by with handling less than 2k requests per second, and PHP beats that by a long shot. JavaScript is simply not that nice on the backend, so a lot of developers still like PHP.
H.R. Giger · 2022-11-23 09:19
>>33442
There is also the factor that a lot of the "tech-savvy website" users block javascript.
vector · 2022-11-23 09:25
>>33444
Can't PHP track and fingerprint you just as well as JS can?
Iverson · 2022-11-23 09:30
PHP is good for those small things you want to just work
Also it's very convenient thanks to all the tooling available, particularly for small servers when the provider can just automate you the installation of a whole forum like phpbb or things like that.
Lady Jessica · 2022-11-23 09:53
PHP was the goto server-side scripting language for decades, but JS (as a server-side language) is relatively new (node.js came out only in 2009 and didn't see widespread adoption for a few years). A lot of web software is derived from older software that used PHP. 4chan is a fork of fork of some old PHP imageboard software from the early 2000s for example.
PHP is supported by virtually every non-static site host. I don't know what node.js's support is now, but 10 years ago, if you paid for a cheap shared host, it was definitely going to support php and mysql, but no guarantees for anything else. So many projects were written in PHP to guarantee they can be used on the maximum amount of hosts with minimal setup.
All of this also means there are plenty of developers who are comfortable with PHP, as much as they may hate it. Javascript is also a highly hated language, so I'd also guess that many competent PHP developers who want a break from PHP wouldn't choose JS as their first choice for their passion projects.
>isn't PHP just a prototyping language?
no
null · 2022-11-23 10:00
>>33445
JS tracking is usually referring to how client side JS (the JS that gets executed in your browser) can be used to collect information about what/how you're browsing. PHP is never executed by the browser, so it doesn't have nearly as much access to that information.
But any site, regardless of backend language, can deliver pages with JS on them. Whether the site uses php or js on the backend is irrelevant for that.
Zhora · 2022-11-23 10:40
>>33448
Client side is a lot scarier seeing as it can in real time figure out if you're browsing, what your mouse is hovering, etc.
Anonymous · 2022-11-23 13:07
Node theoretically scales better for real-time applications than Zend. Those sites often aren't real-time. JS is also quirkier than PHP and you can't update code for the site without restarting the web server or doing a complicated blue-green deployment approach. If all you cared about was speed then you'd use Rust. But using Rust for web development is like getting pegged by a cactus. Speed of development and ease of maintenance are critical for most people.
Case · 2022-11-26 06:47
Because Node speed is just a meme. If you ask about boards, it's not highload anyway, the most slow thing here is DB connection. So, why PHP, not JS? I think because of PHP developers amount and tones of currently written code and libraries on it.
John Doe · 2022-11-26 09:48
>>33478
>Because Node speed is just a meme.
Is it? While doing a CL version of are-we-fast-yet, I've found that Node is extremely fast (as fast or faster than luajit/SBCL). It pays to put so much money and manpower (Google) in a JiT compiler (v8).
And you can probably use Typescript instead of Javascript to lessen the pain.
https://github.com/q3cpma/are-we-fast-yet/blob/common-lisp/benchmarks/Common-Lisp/results.tsv
Jean Dupont · 2022-11-26 22:44
>>33481
I dunno about lua or something else, only about node and php. And yes, even Google and all others corporations can't make something real fast from soykafty spec as ecmascript because it must work in browsers.
word · 2022-11-27 01:24
>>33483
Show me your numbers, then. And please notice that are-we-fast-yet isn't just pure number crunching.
Delilah · 2022-11-27 13:34
>>33441
I vote for Ruby. But if you want to use JS, use TypeScript, if you can.
>and isn't PHP just a prototyping language?
No, but it used to be used as one.
JARGON · 2023-01-21 14:16
>>33441
>PHP instead of JS
have a look at php8.2 and tell it's bad