> I'm not a real programmer. I throw together things until it works then I move on. The real programmers will say "yeah it works but you're leaking memory everywhere. Perhaps we should fix that." I'll just restart apache every 10 requests.
> I was really, really bad at writing parsers. I still am really bad at writing parsers. We have things like protected properties. We have abstract methods. We have all this stuff that your computer science teacher told you you should be using. I don't care about this crap at all.
(from http://axonflux.com/5-quotes-by-the-creator-of-php-rasmus-le...)
Seriously, the PHP hate gets old. It started off very much as a scratch to one man's itch. That man wasn't the best programmer ever (wouldn't even say top 10%, or even close), but he had an idea and executed it to make one of the most successful free products ever that has generated billions and billions of dollars for the world economy.
Can you say the same?
We tend to overvalue good design just for good design's sake.
You're completely correct, but at the same time, PHP also stands as a stark warning not to throw things together with no design, lest your misshapen child end up being immortalized.
PHP is simultaneously the best-case outcome and the worst-case outcome for a badly designed language.
A popular DB had an intentional feature that lost data on 32-bit builds. You might not get bitten until you've gotten plenty of data in it - it's still a terrible design that hurts everyone.
I'd say PHP is and has been popular more because it's easy to hire an army of self-trained "php developers" for peanuts than because it is a "good" language.
It being a "bad language" is irrelevant for someone who's end result requirement is a functional page over technological purity.
Disclosure: I develop mainly in C#
Informal fallacies don't automatically invalidate the argument either. Informal fallacies are rhetorical red flags: they predict problematic logic, because they're generally used in place of actual logic: but unless you're talking about formal fallacies, the argument can still be valid.
In this case, it depends entirely on whether or not you accept popularity as a valid metric for success or quality or whatnot: you're arguing whether or not the "P -> Q" premise is true or false, not whether or not the argument itself is valid. Because P is true.
That's an interesting thought. Has it? I wonder what a lot of websites would have used if PHP has not been around. I wonder if, overall, PHP existing has actually generated billions and billions of dollars in value.
It comes installed because it is easy to install. Someone had to install it and PHP is sure easy for any SysAdmin to get installed. It is easy to start because the PHP folks made it easy to get started.
Look at the steps to get PHP installed versus other languages. Then look at what "Hello World" and a simple form take.
Not much different to getting CGI working. If you need it working well, FastCGI is as much effort as PHP-fpm. SUexec is as much effort as SUPHP.
Any language could supplant PHP in terms of ease of deployment, there's little out there that doesn't have some CGI library to handle the mucky parts.
Not that I am advocating use of CGI for anything non-trivial.
That's really just not true. Installing anything capable of CGI is as easy to install as PHP.
If you want your favorite language to replace PHP, then you have to make it easy for the sysadmin to install (preferably 1 line) and for new programmers to be able to use the language by just uploading a file.
sudo apt-get install apache2 php5 libapache2-mod-php5
Boom, I just installed PHP5 on Apache on Ubuntu, now I just upload a file to my project root.Let me know when you find any way easier than that.
php5
installs apache, by default.I am not a fan, so I am biased. But I've never quite seen the appeal of such a superficial attribute as "it's already on my cheap server." Are we not programmers? How hard is it, really, to install a JVM, Python, Ruby, Go, or any other platform? It's never taken me more than scarce minutes. To my mind, it seems widespread delirium prioritizing such a non-priority over peace of mind and performance. It's akin to selecting an operating system based on the fonts it ships with.
Most people who start out programming PHP aren't programmers. (I think that's a good thing FWIW.) The ease to non-programmers explains the wide spread which is what the discussion is about.
Nope, I install PHP and then upload a page with PHP embedded and it works. It is not that easy with python. That's why all these hosting accounts had LAMP and not something else.
I'm not discussing headaches, I do nit particularly like PHP. My point is just that Python is not very easy to get started with for beginners.
import web
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals())
class hello:
def GET(self, name):
if name:
return 'Hello, ' + name + '!'
else:
return "<form><input name='name'></form>"
if __name__ == "__main__":
app.run()
upload into your web server's cgi-bin folder, or have the server configured to exec all *.py files as pythonED> yeah, this is a few more lines of code than PHP and it requires a teeny tiny amount of knowledge about how the web works - and that "takes 5 minutes to get started" vs PHP's "takes 2 minutes to get started" is a big difference for someone who doesn't know what they're doing but wants results immediately :P
EDED> Actually now that I think about it, that's how /I'd/ start a simple webapp as it has the structure in place to grow easily and elegantly -- if you're willing to do things the quick and dirty way, you can go without a framework and just print an HTTP response to stdout - in which case the only difference with PHP is that the python version requires "print 'Content-type: text/html\n'" at the top
But this web framework is much newer than PHP, isn't it? And this does not look better or easier than PHP: https://wiki.python.org/moin/CgiScripts
That has tracebacks on error and HTML escaping, so I'd say it's considerably better for a tiny increase in difficulty (but you're right that no matter now tiny the difference, PHP is still easier)
Any other language that has dedicated .INI files to determine its behaviour, maybe. PHP caught on because of "Hello world" in a web browser, and smart people didn't realize the value of novelty.
Many of us "web devs" were running desktop windows and had never even used a *nix command line or studied programming beyond BASIC. CGI (perl) scripts were absolutely painful to install, much less write. Dealing with stdin just to get post variables? Python and Ruby were rarely supported as CGI, and there were likely no web frameworks back then that you could manage to install on a shared account. Besides, a lot us back then weren't programmers to being with, we just wanted a web site to scratch an itch. Programming was a means to an end, and I think the rasmus quotes support that.
Enter PHP(&mod_php). Open up your FTP client, rename index.html to index.php, edit to add Hello <?=$name?>, load up index.php?name=Bob in IE, see "Hello Bob", MIND BLOWN! PHP was easy to use, learn, and it came with a huge function library built in. It was a sandbox to play in. The barrier of entrance difference between cgi/perl and PHP was like GIMP to Windows Paint.
The number of web scripts available to use exploded after PHP hit the scene. Message boards, calendars, photo galleries, shopping carts, etc. Sure, a lot of the code written was horrible by today's standards, or even CS standards of then, but that's not the point. Websites were launched, communities were formed, products were sold. Sure phpBB, wordpress, and others code was not properly engineered, but where would the web be without the communities and blogs they allowed to form?
Facebook started on shared PHP hosting. The mediawiki script was created because Magnus Manske wanted to try out PHP. Yahoo actually chose PHP to replace their in-house scripting language over ASP, Coldfusion, and other proprietary options when using open source was a huge risk. Python and ruby were not even on the web radar when yahoo chose PHP. [1]
Now today we may look at the code derived from the era before python, ruby, svn, github, cheap easy VPS/VM access, when shared web hosting was the only PaaS, and look in horror, but the fact remains that PHP powers 75% or more of all websites on the internet today.[2][3]
To ask if PHP has generated value, is to ask if Windows has generated value. They may have been ugly, but they got us where we are today, and the PHP of today is not the PHP of 2000.
[1] http://public.yahoo.com/bfrance/radwin/talks/yahoo-phpcon200... [2] http://venturebeat.com/2013/05/17/google-app-engine-finally-... [3] http://w3techs.com/technologies/overview/programming_languag...
A nice language makes for shorter, more expressive code, sure, but that's like having a fast car that handles well; it still matters more where you're driving it. If someone is making a trip with a caravan of a million rust buckets to a nice place, why would they care about some Porsche owner moaning about how that is all so very wrong?
If PHP developers complained all the time about how programming sucks, then you could maybe tell them to use a better language. But the PHP devs aren't really complaining, rather people who aren't even using it.
People use Wikipedia. I dare say Wikipedia improved a lot of lives a lot. Meanwhile, a gazillion static blog generators written in hip language of the day prove no real benefit over notepad, or this textarea right here. It's like making a trip with a handful of people to a place that's been explored by others decades ago, and then being bitter that nobody cares, and hating on the roaring party going on next door.
If you want to make language A or B more popular and better accessible when it comes to web hosting, write the killer app in it that nobody can do without, and which can't be implemented in PHP. That should be simple, since PHP sucks so much, right?
Lastly, is the HN code nice? I wouldn't even know, it's that irrelevant. The HTML it puts out sure is atrocious, but even that doesn't matter.
Anyone who has to maintain bad PHP code, for starters.
Also, if PHP is really just sucky and offers no advantages, why not simply rewrite it in a better language? Surely the costs would ammortize quickly.
I also am not claiming that PHP offers no advantages. Certainly it has some good things about it. The choice to allow you to easily interleave PHP code with HTML is an example of a simple feature which makes life really easy when you're setting up a site.
But rewriting in a better language is not necessarily a viable option. It's generally not the call of the person tasked with maintaining it, and even if it is, "cost will amortize quickly" isn't necessarily good enough on a large project with limited funding.
Actively discouraged for years, and removed completely over a year and a half ago.
And that's another part of the problem: the incorporation of really bad ideas that end up poisoning code bases for years to come, simply because they weren't properly vetted before being released.
>I spent a good portion of my early career completely rewriting shitty PHP code to be good PHP code.
I'm curious what you think maintenance is.
An f1 racer driving an f1 car will always beat another f1 racer driving a beetle.
Plenty of killer apps use other languages- Instagram, Pinterest, Quora, and Youtube, for example. Google certainly wasn't written in php.
Matter of fact is, facebook has spent millions of dollars trying to change languages, trying to make php behave, trying to make php faster. Wikipedia is nice, but I bet they'd be able to serve even more people if they based used a better language.
HN code is probably nice. The HTML is just the surface of the architecture sites like these run upon.
Which is nice when you're having a race, but rather useless when you don't.
> Plenty of killer apps use other languages- Instagram, Pinterest, Quora, and Youtube, for example. Google certainly wasn't written in php.
Those are't apps in the sense that you can install and modify them, are they. The fact that youtube exists does nothing to drive Python adoption. Sure the same can be said for Wikipedia, but not for MediaWiki.
> Those are't apps in the sense that you can install and modify them, are they. >The fact that youtube exists does nothing to drive Python adoption. Sure the same can be said for Wikipedia, but not for MediaWiki.
If you're gonna say that about youtube, the same should be said about Facebook. With python, at least we have Django, Pyramid, Bottle, Flask. All of which are good open-source platforms that allows you to quickly get a web project going(not just a wiki), and which do a lot to drive Python adoption.
> There are... Just so many open source web applications that aren't written in PHP. So, so many. That was just an example of apps written in python. The comprehensive list is much, much larger (though I thought that was implied).
I don't have an estimate, but it's an interesting question if you're going to argue in terms of economic impact.
As for its popularity, well, that would be the "got out of hand" part.
Those sites are popular in spite of PHP, not because of it. If Mark had been proficient in ASP instead of PHP, FB would probably be running .NET. It's not like anything early FB did was particularly impressive and relied on special language features. (Correct me if I'm wrong.)
A Windows 2000 server with IIS/ASP installed had the same time-to-market advantage as PHP.
You have to watch out for arguments from popularity, they don't prove or even suggest anything other than popularity.
Never belittle other's work, especially when striving to discover that magic formula to success. All the posts on HN about "How we made X successful" and we brush off the obvious ones in front of our eyes? Ever stopped to think why a crappy X is popular? Maybe there is something to it.
Also not to mount on irony but keep in mind, you are commenting on a site that has the HTML syntax from the Geocities era (it has its reasons though).
2. ...
I'm no fan, but that's going a bit far, don't you think? What's a rickety syntax and inconsistent naming have to do with page design?