Live data from Hacker News

Ask HN: Why not PHP?

news.ycombinator.com

31–33 of 33 posts

Re: Ask HN: Why not PHP?

#31
post #30

Earlier quoted context omitted.

"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 threadin…

Evidently you haven't read or used WSGI, Tornado, or Twisted in any significant form. So Python sucks at multithreading, which doesn't mean that there aren't some very good workarounds, and that multiprocessing works as good as any other place.

Btw, if you HAD tried to use Python on any significant way, you would have known that WSGI on Apache recycles the VM for multiple requests, which is the reason why it's suggested to do static file serving outside of Apache within the same server.

And, oh yeah, I have yet to hear from anyone except people doing CPU-intensive processing have the programming language be the bottleneck. Congratulations if your system is CPU or network-limited, in which case I'd hope that you're writing something in a lower-level language to handle the situation, but in 99% of large site installations, even if you cache all your IO, it's still going to be the big bottleneck of your system. Seriously, opening a remote socket and sending shit through it is almost always a bigger issue than pushing HTML.

Finally, it still doesn't change the fact that some of the biggest web sites are running Python in the back end and they couldn't be happier.

Re: Ask HN: Why not PHP?

#32
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…

the syntax seems regular but the grammar for php isn't.

this is why you can't do $a = foo(1,2,3)[0] in php.

also why this won't happen any time soon.

Re: Ask HN: Why not PHP?

#33
here is a quick outline of some issues in php through the years:

http://phpxmlrpc.sourceforge.net/#security early and naive implementations of xml parsers in php used eval, and as such were terribly insecure and hacked en masse

http://php.net/manual/en/security.magicquotes.php -- man, if only we wrapped string on a ini file setting, it wouldn't prevent injection attacks at all, really all it means is that the standard library isn't portable any more as the semantics and return values can change on a site basis.

http://php.net/manual/en/security.globals.php 'you know what would be good if we could trash variables from the browser' 'we've turned it off now, good thing that people won't turn it back on for older scripts, and it will affect every script'

http://php.net/manual/en/language.oop5.late-static-bindings.... - a dynamic language with an early bound oo implementation? sure we'll fix it, we'll just make the keyword for dynamic dispatch 'static'

http://php.net/manual/en/language.namespaces.php - the namespace character is the string escape character. I mean that will never backfire if people don't use 'variable functions', or using a string to lookup a function http://us.php.net/manual/en/functions.variable-functions.php lets hope we never have to put old code that uses this into a namespace.

http://php.net/manual/en/control-structures.goto.php man, should we implement a subset of goto or, should we do named breaks. nah goto is far more awesome.

http://use.perl.org/~Aristotle/journal/33448 - how do we fix a security vulnerability? why checking to see if an int is bigger than INT_MAX

www.trl.ibm.com/people/mich/pub/200901_popl2009phpsem.pdf - the implementation and semantics of php don't match up. it doesn't do what it says on the tin.

http://en.wikipedia.org/wiki/PHP_accelerator - php by default doesn't cache bytecode, unlike, nearly everything ever, for commercial reasons, as zend sell one as a product.

http://www.phpcompiler.org/doc/phc-0.2.0.3/representingphp.h... - the grammar is terribly broken, so much so it is nearly impossible to do obvious and useful things like foo(1,2,3)[0]

http://blog.php-security.org/archives/61-Retired-from-securi... the development team is toxic and reluctant to provide actual solutions for security

there are many php builtins which have vague return values which change indeterminately between releases and arguments, which forces you to use == over === for some comparisons unless you want your code to break unexpectedly.

the moral is: for everything they've fixed, they've often fixed by duct taping over the original errant feature. the standard library needs to be wrapped to be consistent. security or performance isn't a priority for the open source versions.

this won't bite most web applications as many of them are simple templates around a database.

with larger applications or frameworks, php struggles

Post reply on HN