5 ms·
I think you (and to be fair, many people) are missing a huge part of why PHP is still popular. Saying Ruby can replace PHP sounds to me like saying that Ruby ca
by nucleardog 5y ago
I think you (and to be fair, many people) are missing a huge part of why PHP is still popular. Saying Ruby can replace PHP sounds to me like saying that Ruby can replace Excel. It's fundamentally misunderstanding _why_ it's popular in the first place.
I have a HTML page. How do I add a hit counter to it with Ruby?
I can do it right now in PHP with zero dependencies and it'll fit in this comment:
<html><body>
<p>You are visitor number:
<?php
$count = file_get_contents('hit_count.txt');
$count = $count + 1;
file_put_contents('hit_count.txt', $count);
echo $count;
?>
</p>
</body></html>
Is it shit? Yep. Does it (mostly) work? Yep.
When you want to do something, you can just copy and paste a handful of lines of PHP into a file and rename it from .html to .php and it'll basically work anywhere. You don't need to worry about frameworks or anything. Routing is handled by the web server. Hosting is handled by someone else. Deploying is just FTP'ing a .php file off to a server somewhere and then requesting it.
But when you are ready to get into "real" programming, that's all there too. PHP has a true learning _curve_. Every bit of complexity is only a small step from the previous. Getting started does not require a ton of background or knowledge. You can start out copying and pasting some code into the middle of some HTML and a year later end up working within once of the nicer, more comprehensive frameworks managing your dependencies with a relatively decent package manager... and still hosting it all on your $3/mo shared hosting.
If every professional developer stopped using PHP tomorrow, we'd still end up back exactly where we are as a bunch of people found PHP as the most accessible and direct solution to the problem they have.
- Gigachad 5y agoThis example seems to be a great demo of why people do not like working with PHP. PHP makes the shit method the massively simpler way and the good method much harder. Now you open yourself up to risks like what happens if we accidentally let some user input change the file opened as well as the content written. While with rails, to do basically anything, you already have a full db ready and incrementing a counter using the ORM is even easier than opening a text file. So people avoid PHP because it most likely involves dealing with absolute crap code written with no understanding.
- wbercx 5y agoI don't find these kinds of what-ifs very useful. I haven't used Rails, but does it somehow prevent you from accepting user input and programming it to go where you say you want it to go? Isn't there an element of "holding it wrong" with any language or framework?
- Gigachad 5y agoRails actually does do a good job of treating user input as dangerous and it can often detect when user input is being used in the wrong places like directly in to sql. And with industry standard tools like brakeman, you can have CI alert you of most cases where user input is not safely handled.
- netzone 5y agoThat's way too complicated for the person just starting out and wanting to add a counter to his small website. Nobody starting out with programming today will start with Rails. They might start with Javascript, but more than likely they'll start with PHP. It's accessible and SIMPLE.
- simion314 5y ago>PHP makes the shit method the massively simpler way and the good method much harder. How it makes it harder? Or you compare PHP a language with Rails a framework? Maybe shut up if you have no idea or show us a pure Ruby code that does the same thing. Or install the most popular PHP framework, really learn that and then tell us that PHP made things harder. I don't know Ruby or rails so I can't shit on that like an idiot.
- paulryanrogers 5y agoPlease refrain from name calling and phrases like "shut up". They don't really add to the conversation.
- 5y ago
- flippinburgers 5y agoThis makes my eyes bleed.
- flir 5y agoInline PHP reminds me JSX. Everything old is new again. <? include '../menu.php' ?>
- Gigachad 5y agoExcept in-line JSX runs in the browser and is not very exploitable.
- helloguillecl 5y agoJSX certainly does not run in the browser.