Skip to content

Comment on PHP Is A Husk

Comments

It's a crappy title, but the article is pretty good.

PHP is a niche language, the niche is probably best described as "for want of something else that seems so easy to use and has such a low barrier to entry we are forced use it for web development".

The interesting thing here is that apparently the difference between PHP and the 'rest' of the languages out there is not large enough to supplant PHP in the WWW domain.

It's close enough to C that a whole generation of C programmers is intuitively at home in PHP, until they start using its advanced features.

But as long as you have to do simple stuff and get paid for that it almost always works. The few times that it doesn't you wished you never knew about the language though.

Just imagine, a language where the default 'scope' is global but globals are not available to functions and silently get replaced with empty variables. Who came up with that gem ?

The default scope within a function is not global, and all global variables are available within a function by using the keyword "global". You can also access the superglobals, but that of course is optional.

hacking the procrast to be able to answer you...

The default scope is global, I did not say 'within a function'.

I know about the 'global' keyword, as does everybody else that has used PHP for more than 5 minutes.

If your language has a C like syntax and you have a default scope (which means that you can start executing code right from the first line without being in a function definition) then the default behaviour of a variable should be that it either does not exist inside a function (different scope) and throws an error or it should refer to the global variable.

To have a 'third option', which silently creates empty variables is very (no, make that extremely) poor design.

And no, I'm not telling how to break noprocrast :)

And that's where PHP truly fails. On the surface, it appears to have many nice, advanced features. But they're implemented so poorly. They're not thorough about use cases or testing.

The interesting thing here is that apparently the difference between PHP and the 'rest' of the languages out there is not large enough to supplant PHP in the WWW domain.

Very astute observation. PHP doesn't have to be the best. It just has to be good enough to maintain it's place.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.