Live data from Hacker News

Ask HN: Why not PHP?

news.ycombinator.com

11–20 of 33 posts

Re: Ask HN: Why not PHP?

#11
Think of a simple problem to solve... and then solve it in a few different languages. This way, you figure out what you like, because everyone is different.

You might even be more focused in your learning and select specific frameworks for each language - great exposure for you.

Re: Ask HN: Why not PHP?

#12
post #10
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…

>PHP is fast. Really fast Compared to WHAT? Ruby and Perl? Cause I hope you're not saying it's C fast, or even java or C# fast...

Amended.

Re: Ask HN: Why not PHP?

#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' - but it makes elegant sense in the old unix world where CamelCase object names didn't exist)

* PHP lacks (or lacked until relatively recently) many programming niceties such as objects, types, closures, lambdas, and namespaces

see php5 - 2004.

* Even if you can (with difficulty) use PHP libraries in command line programs

tons of daemon scripts run php - you are talking about a php3/4 problem (set_script_timeout etc.) see mailchimp post

* Although it is almost always built into a web server, PHP doesn't make it easy for you to do anything useful with web requests

this is what PHP excels at. want a function to retrieve the hostname from a URL? done. want to send a HTTP header? done. want to parse basic auth? done.

php.net/parse_url

$_SERVER

php.net/header

PHP was probably the first http/web aware language, you picked its strength as a weakness.

* Since it's a web templating language at heart, PHP practically begs you to do the wrong thing and mix presentation and data.

you can say that of any language, implementation-dependent. python and ruby also print to stdout which is just the web process as well. you think this because you have seen more php scripts that mix presentation and logic.

* Due to its ubiquity, PHP is the choice of script kiddies who can't program.

sigh

Re: Ask HN: Why not PHP?

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

This is a good summary of the common gripes. I would like to add to this list the history of things BREAKING even with minor version updates (although to be fair a lot of this has been due to radical changes in the object model over the past few years).

I also think there's a fundamental problem with this question. I think one must make the comparison between web development frameworks, rather than saying PHP/Ruby/Python - you need to say Symfony (or PHP framework X - I just happen to like Symfony), Rails or Django (or Spring or Grails or whatever).

In that case: the comparison is simple and personal. Go to the Symfony tutorial, go do the Django tutorial, go do the Rails tutorial. See which one clicks the best.

I personally find PHP enjoyable to use because I've used it for a while and I'm used to it's idiosynchracies. I've used it for web development but I've also used it for command line daemon processes that have run, without fail, for the past 3 years.

I've never had cause to benchmark those processes in terms of performance with any other language because I've never run into performance problems, but your mileage may vary.

In short: I think PHP gets a lot of bad press - but PHP also gets a lot of things done.

Re: Ask HN: Why not PHP?

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

PHP's syntax is very random. There are over 5000 builtins and no consistency among them.

This is one thing that really annoys me about PHP...for example there is stripslashes() to remove slashes but strip_tags() to remove html tags. Why couldn't they be consistent about using the underscore or not using it. Another one is array_push($array,$var) which takes the array as the first argument and the $var to push as the second, whereas array_search($var,$array) has it in reverse.

Re: Ask HN: Why not PHP?

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

As far as I'm concerned, php5 was still broken until 5.3. http://php.net/manual/en/language.oop5.late-static-bindings....

Re: Ask HN: Why not PHP?

#17
Security: depending on the framework PHP makes it easier to do the wrong thing. Your web development language and framework should make it much harder to be insecure than to be secure. For netsec the other day I was writing a deliberately insecure page so my students could practice session stealing and I actually caught myself almost creating a SQL injection vulnerability.

No one is perfect but some are better than others.

Re: Ask HN: Why not PHP?

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

Only vastly different programming language paradigms are comparable to different languages. PHP, Ruby and Python are all relatively the same the only real issue is being part of the 'community' of each language, if you are you understand what to use, where things are going and what not to use otherwise time is spent researching.

Re: Ask HN: Why not PHP?

#19
post #16
post #13

Earlier quoted context omitted.

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

As far as I'm concerned, php5 was still broken until 5.3. http://php.net/manual/en/language.oop5.late-static-bindings....

We just got bit on the ass by this one yesterday. (still deployed on 5.2)

Re: Ask HN: Why not PHP?

#20
post #15
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…

PHP's syntax is very random. There are over 5000 builtins and no consistency among them. This is one thing that really annoys me about PHP...for example there is stripslashes() to remove slashes but strip_tags() to remove html tags. Why couldn't they be consistent about using the underscore or not using it. Another one is array_push($array,$var) which takes the array as the first argument and the $var to push as the…

These complaints are valid, it is annoying but fortunately the docs are extremely easy to use.
Post reply on HN