Live data from Hacker News

Coding Horror: The PHP Singularity

codinghorror.com

301–310 of 341 posts

Re: Coding Horror: The PHP Singularity

#301
post #297

I wish bloggers would stop quoting that fractal article. At least 50% of what's written in there is totally wrong/false. Other information is terribly out of date. And even more information is merely half-truths and lack of understanding of the language. The article author clearly scanned through PHP bashing articles and took material from them verbatim; mistakes and all. I'm not going to argue that PHP is a great la…

> Strict-equals on objects compares the references; but regular equals compares the contents of the objects. Two objects compare equal if the contain exactly the same fields and values. Seems pretty reasonable to me. The line you quoted is talking about ordering, not equality. > This is a good thing; JavaScript gets this wrong. It IS a good thing, but it stands out when most of the language is extremely weakly-typed…

> It IS a good thing, but it stands out when most of the language is extremely weakly-typed

You only need distinct operators if your language is weakly typed. If you language is strongly typed like Python, Java, or C# then there is never any conflict between addition and concatenation. VB/VB.NET is also weakly typed and has separate operators.

> So some things (objects) are passed by reference implicitly, and some (all else) are not. Yikes!

Yes, like most ever other language in existence. You know, Java, C#, Python, etc.

> Okay. Why not at top-level?

Because all code should be contained within a namespace going forward. Constants should not be defined in the top-level.

> if I write a function that can take either one value or an array of items, and you pass in a single object, I'll get a useless keyed array of its attributes.

No, it doesn't work that way. You have to explicitly cast. If you use an array type-hint you can only pass an array.

> Python and Perl are bytecode-interpreted (not positive about Ruby) and they both have rich module systems that don't require any fussing around.

PHP is also bytecode-interpreted. I'm not really sure what point you're trying to make. It's super easy to integrate code from different libraries with namespaces and autoloading.

> Why does it need to look like a function when it clearly isn't one? return and echo don't.

Because it's used an expression not a statement like return and echo. The fact that is or is not a function is insignificant; you use it the same way.

> In theory, but I've never seen any actual PHP code that uses them.

In templates you see it all the time.

> That's what exception handling is for -- unfortunately, PHP errors are an entirely separate beast from PHP exceptions.

If you convert all errors to exceptions, you could catch it. It's just an additional feature. If you handle your own errors, you can even ignore the error suppression operator if you choose.

> I said "PHP errors don't provide stack traces", and you aren't disputing that... but the runtime doesn't do it for you.

Oh, you're saying if you don't provide any of your own error handling and let it spill out the terminal -- yes, you're right -- no stack trace by default. Not that you should be doing that. If you really want that though, it can be provided by the XDebug extension.

> it's clearly not for compatibility with just PHP4

The lack of E_STRICT helps you run PHP4 code on PHP5. That's why it's not included in E_ALL. For example, I have an application that runs unmodified on PHP4 and PHP5.

> Yet I can't be sure on what parts of the language actually ARE deprecated without reading the entire manual looking for mentions of E_STRICT.

Turn on E_STRICT and it'll tell you.

> A bogus object attribute gets a warning, but a bogus class attribute is a fatal error.

Yes, one is defined and one is not.

> A string value stored in a variable can be called, but the same string value as a literal cannot.

Calling a string literal is pointless! 'test'() is test()!

> Neat, though my understanding is that this still doesn't work with fatal errors, which are shockingly common.

Fatal errors are not that common but I won't argue the point too heavily because they are a bitch. PHP developers are trying to reduce the number of fatal errors. Most IDE's will notify you of fatal error as you type.

> but that they implement half of a feature and then decide to sit down and think about the other half (while now constrained by whatever hack job they've already done).

There's nothing controversial or difficult about object type hinting. Also since PHP is meant to be typeless there is some discussion over whether scalar type hints are even necessary. Giving you something you can use right now is not a bad thing.

> Then why not use Class->foo? Why does this need two operators?

I suspect historical reasons. They really did do very different things in PHP3/PHP4.

> Regardless, it's still wildly inconsistent with the rest of the language and poorly bolted on.

How so? It's PHP object system, there is nothing for it to be inconsistent with in the rest of the language.

> How many people using PHP today came from C, exactly?

It's not about whether they came from C -- it's the fact that PHP quickly implemented access to a huge library of existing C libraries (and tracked their changes). This was a huge deal back when PHP was younger.

> Zend could have merely switched the old escape function to have the new behavior, and all existing code would have been instantly fixed, not broken.

If you've ever complained about security in PHP, you need to give that up right now. Because you just gave everyone a false sense of security.

> Either judge PHP only by the core language, or judge everything else by what you get with frameworks.

Wait, why? That's ridiculous.

Re: Coding Horror: The PHP Singularity

#302
post #297

I wish bloggers would stop quoting that fractal article. At least 50% of what's written in there is totally wrong/false. Other information is terribly out of date. And even more information is merely half-truths and lack of understanding of the language. The article author clearly scanned through PHP bashing articles and took material from them verbatim; mistakes and all. I'm not going to argue that PHP is a great la…

> Strict-equals on objects compares the references; but regular equals compares the contents of the objects. Two objects compare equal if the contain exactly the same fields and values. Seems pretty reasonable to me. The line you quoted is talking about ordering, not equality. > This is a good thing; JavaScript gets this wrong. It IS a good thing, but it stands out when most of the language is extremely weakly-typed…

The real point here is that you're not a PHP programmer. You're complaining about a language you don't use and trolled the web for this material without even testing much of it out yourself.

And sadly your uninformed opinion is now the go-to article when talking about PHP flaws. You've won the Internet.

Re: Coding Horror: The PHP Singularity

#303

Earlier quoted context omitted.

Any major websites done on Lisp, Smalltalk or Haskell? Besides Viaweb? Now count > 1m visits per day websites done in PHP.

> Any major websites done on Lisp Does Hacker News count?

Note the use of the word "major"

Re: Coding Horror: The PHP Singularity

#304

Earlier quoted context omitted.

Any major websites done on Lisp, Smalltalk or Haskell? Besides Viaweb? Now count > 1m visits per day websites done in PHP.

You're measuring the success of a website in terms of traffic. The number of hits a website receives isn't the product of the language it's written in, but primarily a function of its marketing (and other factors that appeal to its users). There are also more websites with their foundations in PHP, so it's reasonable to expect a higher number of successes. You can't therefore logically conclude that the language infl…

>You're measuring the success of a website in terms of traffic.

Yes, me and all Analytics and SEO guys. You either sell ads or stuff. In both cases you want as many eyeballs and wallets as possible.

>The number of hits a website receives isn't the product of the language it's written in, but primarily a function of its marketing (and other factors that appeal to its users). There are also more websites with their foundations in PHP, so it's reasonable to expect a higher number of successes.

Yes, but your logic is circular. The question is WHY are there "more websites with foundations in PHP", and not just trivial amateur personal stuff but highly successful ones too.

You seem to assume PHPs expanse as just a fact of life, totally arbitrary, and thats why you say we must not draw conclusions based on it.

>You can't therefore logically conclude that the language influences success.

Sure I can. Here are some ways:

- Php is easy for newstarters, so got more adoption. - Php is trivial to deploy, so got more adoption. - Php was there, targetting the web specifically (with libs and features), in 199x, while Haskell, CL, what have you were not yet. - Php, because of the above, had amassed a huge ecosystem of projects and engines (Nuke, Wordpress, Drupal, EE, etc). - Php, because of that, has alo got huge adoption. - Because of th adoption it built a huge ecosystem of programmers, projects, tools, books, etc.

And, putting it all together, what makes PHP more likely to power most high ranking sites, is that you can easily find components and engines to base your site on, AND you can easily find tons of programmers to employ, AND you can easily find support for it, etc. All those make it a no brainer for a lot of uses.

And all of those are interdependent, based on some initial language attributes, not arbitrary like the US vs Canada population argument (which is not that arbitrary and size based itself, but thats another story)

Re: Coding Horror: The PHP Singularity

#305
post #64
post #48

I seriously groaned when I saw this post (title). I was expecting an elitist diatribe about PHP (because this is perennially popular amongst particular programmers) but that's not what this post is intended to be. Interestingly Jeff does take the usual potshots at PHP almost like he thinks he'll lose street cred if he doesn't but the basic message I agree with: if you want someone to stop doing something you consider…

I think you forgot an important feature of PHP: it just works. I can pretty much create and "deploy" a PHP web app within minutes of getting a run-of-the-mill hosting service.

It's not a feature of PHP, it's a feature of the world. Had hosting providers put the same effort to make deployment of Python, Ruby or Haskell web apps, this argument would be void.

Similarly, LPG is a great car fuel here where I live, because of a good price and abundance of gas station, but it's not the case in the US.

Re: Coding Horror: The PHP Singularity

#306
post #248

Earlier quoted context omitted.

>These three things turn out to be among the most important parts of a server-side language So the language does two of these three things by not doing them at all ? State: oh there's no state across requests. Concurrency: No shared resources, no threads, but we'll call it shared-nothing concurrency and then say it looks like Erlang!! Amazing. An Erlang actor holds mutable state and sends immutable messages. A web re…

Well, except that PHP has access to the database, sessions, cookies and the filesystem. There's a whole bunch of state right there.

It also has a variables and instruction pointer. The point is that this state is not preserved between different requests.

Re: Coding Horror: The PHP Singularity

#308

Earlier quoted context omitted.

You're measuring the success of a website in terms of traffic. The number of hits a website receives isn't the product of the language it's written in, but primarily a function of its marketing (and other factors that appeal to its users). There are also more websites with their foundations in PHP, so it's reasonable to expect a higher number of successes. You can't therefore logically conclude that the language infl…

> You're measuring the success of a website in terms of traffic. Yes, me and all Analytics and SEO guys. You either sell ads or stuff. In both cases you want as many eyeballs and wallets as possible. > The number of hits a website receives isn't the product of the language it's written in, but primarily a function of its marketing (and other factors that appeal to its users). There are also more websites with their f…

> You're measuring the success of a website in terms of traffic.

I wasn't disagreeing, and in fact I didn't even express an opinion regarding this. Success means a lot of different things to people; I was stating your definition of success for clarity.

The user doesn't care whether I write a website's back end in PHP, Ruby, Python, Haskell, C++, Ada, Clojure, or even Erlang. The success depends on how useful the site is and how well it's marketed. This isn't circular reasoning.

There are more websites written in PHP because PHP is an easy language for beginners and therefore more common compared to Ruby or Python, for example.

It's an absolutely untenable position to assert that the programming language itself affects how much traffic an site receives, which is what you originally defined as "success".

Re: Coding Horror: The PHP Singularity

#309
post #251

Earlier quoted context omitted.

So, you're calling people "childish", yet you 're the one tossing out coarse language, then dismissing people with trite memes like "cool story bro"? In a community that prides itself on its etiquette, meme-free nature, and other forms of maturity, no less? Yep, you lack self-awareness.

Back up there EvilTerran. Let's take a couple of steps back in this thread. I originally took issue with the OP because his piece was nothing short of a rant. I've spent the last 11+ years of my professional life developing with PHP. So I expect far more than what I read from someone like Jeff .. and was reasonable enough to let him challenge me to prove the errors of my way. I also took issue because he didn't point…

Okay, I think I see how this worked out.

Terms like "bigoted rant" and "fucking childishness" always give me the distinct impression the poster isn't interested in reasonable discussion -- particularly on HN, given the usual monocles-and-earl-grey manner of conversations here. In my experience, that sort of language only irritates whoever may disagree, and so lowers the level of debate, while achieving nothing of value. As such, angry words on the internet always feel immature to me, so the phrase "fucking childish" struck me as amusingly ironic.

Your challenge to Mr Atwood also came across as facetious; I find it very unlikely that a busy man like him has the time for a code-off, but I could see someone claiming his failure to accept a challenge as a victory by default; and even if he did take you up on it, it would prove very little.

As such, your first post read to me as little more than a troll itself, so I felt I was only being flippant in kind.

To be honest, I would have downmodded your first post and left it at that, had that button appeared to me yet. Instead, in hindsight, I guess I thought I was (from my perspective) "feeding the trolls"; itself far from the best way to improve the level of dialog, I freely admit. It wouldn't help that I very likely came to this thread spoiling for a fight with those defending PHP; it's been a conduit for many headaches since I finished my degree & got a job.

Peace.

Re: Coding Horror: The PHP Singularity

#310
post #306

Earlier quoted context omitted.

Well, except that PHP has access to the database, sessions, cookies and the filesystem. There's a whole bunch of state right there.

It also has a variables and instruction pointer. The point is that this state is not preserved between different requests.

The point is that it's still shared state, so it's possible in practice to take down your server if you manage to corrupt your database or a file on your filesystem.

About the only thing you're protected against is memory leaks, and that seems to be because you have to, otherwise PHP would fall over in a big heap: https://www.google.com/search?q=php+memory+leak

I haven't had any problems with memory leaks running things like Django or Bottle.

Post reply on HN