Live data from Hacker News

Ask HN: Why not PHP?

news.ycombinator.com

21–30 of 33 posts

Re: Ask HN: Why not PHP?

#22
I must be a lunatic because despite all its warts, I love PHP. There are a fair number of gotchas with PHP, but I think the docs are generally great, mostly thorough and usually easy to find what you are looking for, everything is in one central place and user comments/examples can be incredibly helpful. I'm able to write fast, efficient code in PHP quickly. It's not going to win a race against C any time soon, but for what it is it's pretty quick, and of course there are a large number of extensions available for it that are written in C. I'm sure it's not the same for everyone, but the amount of time it takes me to write code in PHP is significantly less than any other language I've messed with.

Note: While the vast majority of my work these days is done in PHP, previously I worked almost entirely in C++. I've also used/dabbled in Perl, COBOL, BASIC, VBA, Java, Javascript, Python, AS3, Lisp. I've also looked at some Ruby code, maybe changed 3 lines of it in my entire life. ;)

Re: Ask HN: Why not PHP?

#23
post #13
post #7

The standard gripes about PHP: - PHP's syntax is very random. There are over 5000 builtins and no consistency among them. - PHP lacks (or lacked until relatively recently) many programming niceties such as objects, types, closures, lambdas, and namespaces. To do anything interesting, PHP developers rely on globals or dubious innovations such as using a string as a function name. - PHP relies on a web-serving model wh…

"until relatively recently" if by recently you mean 6 years. almost everything else you said is also wrong. op - use what you are most comfortable with and don't force yourself into whatever is cool or latest groupthink (Edit: ok you got me.: * PHP's syntax is very random you are confusing syntax with the standard lib, which was inherited from C func for func (which if you come from an OO stdlib can seem 'random' - b…

   "relatively recently"
PHP 5.3 came out in June 2009. Quoting from the readme:

   The key features of PHP 5.3.0 include:
 
    * Support for namespaces
    * Late Static Bindings
    * Lambda Functions and Closures
I don't know what you are even arguing about.

PHP has a sort of support for types, but while you can say that a function accepts a certain kind of object, you can't express that a particular function takes an int or a string. That's really pathetic. It's fine if you don't want a language with types -- many great languages don't have them -- but only PHP thinks that stupid half measures are acceptable.

PHP has had objects for some time, but it arguably didn't work well enough until their second try.

It's true that PHP makes it very easy to get at elements of the web request, but what I meant was that it is trapped in the content-generation phase. The Apache API is very sophisticated and gives you full control over the HTTP response cycle, but PHP throws all that way, and turns Apache into a dumb teletype. So every PHP script that needs to do authorization is written in this silly inside out way; first you start to deliver content, and then you check if you're allowed to actually do so. Whereas the right thing is to check authentication and authorization first, and then never even call your content script if the user's credentials didn't check out. Apache nicely separates this out with their Authentication, Authorization, and Content phases, but nobody told PHP. Other web frameworks don't have this problem either (I've used some web servlet engines written in Java, and they too avoid the brain-damage of doing it all in the content-generation phase.)

As for daemon scripts, I have no direct knowledge, but there aren't a lot of people who would suggest it's a great language for a daemon. Even fork() can be problematic in PHP. I wrote a system that tried to use it that way and we ran into all sorts of reliability problems (none of which I've ever encountered writing similar programs in Perl).

I may be more behind the times than others, since I happen to have worked on three different PHP projects that all started around 2003-4 or earlier (and are still chugging along). After being bitten in the ass by various broken features over the years, most of them have adopted a very limited subset of PHP (some even refuse to use objects, to this day), and I can see why.

I mean, PHP can be confused by something as simple as loading libraries from different script files. Rasmus' official advice to us was to have one "loader" script that included all the libraries in one shot. I find it hard to respect a language that has difficulties with things like this.

Re: Ask HN: Why not PHP?

#24
I heard at a seminar once that PHP is easy to write horrible code and get away with it. I think that's true.

Having said that, I think you're more likely to see bad code coming from really, really bad programmers who started out with PHP 4. This, and the fact that my first PHP codebase came from a setup where register_globals was enabled which allowed for strange variables to pop out of thin air, made my experience with PHP one I am happy to leave behind.

I would be surprised if the code quality of recent PHP projects is as bad as the older ones. From memory, I can advise you to stay clear of Joomla and phpBB - although circumstances may have changed.

Learn OO in PHP first, then pick a framework over a CMS to cut your teeth on, and you should have a good start.

EDIT: And please, oh please, whatever you do, don't mix your business logic with print/echo instructions.

Re: Ask HN: Why not PHP?

#25
post #2

Python may be the best language to learn if you've never done any coding before. Clean syntax, straight to the point, etc. However, I'd say Ruby fills the RAD a bit better than Python, and Python is is not a language that scales, so aside from little scripts it's not exactly a language that's conquered a niche. Go with Ruby or Java if you plan on making something useful right away.

Python is used by Google, Youtube, NASA, and Reddit. It scales, it's faster,uses less RAM, and is much saner than PHP.

Woah. Do you know what Google, youtube, and Nasa use it for? Not for powering their applications. You might as well say Google and youtube use bash scripting, it'd be just as accurate.

And Reddit is having a ton of scaling problems. The thing can't even support multicore . I'ts 2010 and you're telling me a langauge that can't handle multicore properly scales?

Oh. and don't mistake my python smack talk for defending PHP. PHP is the devil. I'm just not a fan of python.

Re: Ask HN: Why not PHP?

#26
post #5

why is PHP considered so inferior to Ruby/Python? When I studied English in college, I discovered that the English language is a very poor choice for writing poetry because it is a very rhyme-poor language. For that, look to French or Italian. English is such a mess of a language, with irregular forms and inconsistent pronunciation. But if you're not writing poetry, English is your best bet, because more people speak…

To be fair (I'm a native french speaker), I feel english is a very utilitarian type language. It's fast and efficient, simple, no frills or anything. I've been trying to teach my wife french and some things in french aren't that useful, why does every word need a gender?

On the other hand, I have to say, I always felt french to be a better language for songs and writing.

Re: Ask HN: Why not PHP?

#27
post #5

why is PHP considered so inferior to Ruby/Python? When I studied English in college, I discovered that the English language is a very poor choice for writing poetry because it is a very rhyme-poor language. For that, look to French or Italian. English is such a mess of a language, with irregular forms and inconsistent pronunciation. But if you're not writing poetry, English is your best bet, because more people speak…

I think it was Cocteau, who asked to name France's greatest poet replied "Victor Hugo, helas." No question, if you're looking for rhymes, English gives you a tougher task. But if you think it's about the rhymes, maybe you should be doing something else.

Re: Ask HN: Why not PHP?

#28
Unfortunately, the question is harder to answer when put naively. How is a beginner supposed to evaluate what somebody says about closures, lambdas, type checking?

I would recommend learning Python. Python for Windows is a very handy environment; you can fool around with Google App Engine if you care to, or run Django or whatever locally.

I would recommend rephrasing your questions along these lines: I am a beginner interested in starting with web applications. What languages and frameworks do you think most promising to learn on, and where can I find good examples to illustrate the principles?

Re: Ask HN: Why not PHP?

#29
post #25

Earlier quoted context omitted.

Python is used by Google, Youtube, NASA, and Reddit. It scales, it's faster,uses less RAM, and is much saner than PHP.

Woah. Do you know what Google, youtube, and Nasa use it for? Not for powering their applications. You might as well say Google and youtube use bash scripting, it'd be just as accurate. And Reddit is having a ton of scaling problems. The thing can't even support multicore . I'ts 2010 and you're telling me a langauge that can't handle multicore properly scales? Oh. and don't mistake my python smack talk for defending P…

"Python is fast enough for our site and allows us to produce maintainable features in record times, with a minimum of developers," said Cuong Do, Software Architect, YouTube.com.

"Python enabled us to create EVE Online, a massive multiplayer game, in record time. The EVE Online server cluster runs over 50,000 simultaneous players in a shared space simulation, most of which is created in Python. The flexibilities of Python have enabled us to quickly improve the game experience based on player feedback" said Hilmar Veigar Petursson of CCP Games.

So, yeah, you're completely wrong on all counts. And if you think multicore is the only way to do multiprocessing, you should probably go back to Operating Systems 101, or study the actual reasons why Python is or is not good for multiprocessing. The correct answer would have been the GIL and multiprocessing limited only to blocking IO calls.

At any rate, if you had actually used this for a real scaling problem, you would have realized that you spend 95% of your time waiting for IO on most web processes, so the choice of language is almost irrelevant so long as RAM usage doesn't get exceedingly high.

Re: Ask HN: Why not PHP?

#30
post #25

Earlier quoted context omitted.

Woah. Do you know what Google, youtube, and Nasa use it for? Not for powering their applications. You might as well say Google and youtube use bash scripting, it'd be just as accurate. And Reddit is having a ton of scaling problems. The thing can't even support multicore . I'ts 2010 and you're telling me a langauge that can't handle multicore properly scales? Oh. and don't mistake my python smack talk for defending P…

"Python is fast enough for our site and allows us to produce maintainable features in record times, with a minimum of developers," said Cuong Do, Software Architect, YouTube.com. "Python enabled us to create EVE Online, a massive multiplayer game, in record time. The EVE Online server cluster runs over 50,000 simultaneous players in a shared space simulation, most of which is created in Python. The flexibilities of P…

Wow, you're talking about Stackless, something a lot different.

>he correct answer would have been the GIL and multiprocessing limited only to blocking IO calls.

I'm familiar with the GIL, however I don't think you are.

> you would have realized that you spend 95% of your time waiting for IO on most web processes

hahahaha. This is funny, because I know why you think this. See, because Python doesn't do multi threading, you spawn up a seperate process for every web hit. Then of course you have to hit your cache servers or DB, hence waiting on IO.

See, when you graduate to big kid programming you'll realize that 1997 called and they want their architecture back, and instead it's much better to have a mature platform that handle multiple concurrent web requests from one VM, hence they can share a cache, so no, I don't work on apps that spend 95% of the time in IO because if that is the case you're doing it wrong.

Post reply on HN