Live data from Hacker News

Coding Horror: The PHP Singularity

codinghorror.com

291–300 of 341 posts

Re: Coding Horror: The PHP Singularity

#291

Earlier quoted context omitted.

It read like a pretty vanilla rant to me.

Probably because you did not read the last part of the article where he says that he's trying to build a better alternative.

Except I did. I read every word.

Re: Coding Horror: The PHP Singularity

#292

Earlier quoted context omitted.

I actually clicked on several of those failed tests and there doesn't seem to be anything critical there. Looks like some access problems (test setup) and at least one needed the test to be updated. I'm not sure when these where run but it would be easy for someone went through all of them and give them a pass. A failed test doesn't necessarily mean that deployment should be held up. 700 failed tests is a different s…

The fact that the tests would be easy to fix makes it worse, no better. The problem the tests and the security hole was not that the tests indicated severe problems, but that all these simple failing tests masked the presence of a new, serious failure. If your test output is filled with junk due to failing tests because of minor bugs, it makes it much harder to notice when your tests uncover a major regression.

> The fact that the tests would be easy to fix makes it worse, no better.

Somebody has to fix them; these things don't happen instantly.

Given the fact that they had hundreds of failed test cases and now they only a few is a significant improvement -- and this is while development has continued. They realized the problem just as you describe; there isn't much more to say about it except they're working to fix it.

Re: Coding Horror: The PHP Singularity

#293
post #289
post #125

Earlier quoted context omitted.

Just needs a bit of type system magic. Don't use the same type for escaped and unespaced strings. (And don't use the same type for user generated input before and after it's scrubbed / escaped of any nastiness.) Ask any Haskell weeny for details. Also in your example, you'd probably be better of, if your language knew about the HTML structure, e.g. something like P($var), instead of putting the tags in as strings.

> Just needs a bit of type system magic. I like this, although when you concatenate strings, does it actually concatenate them (and loose the type info)? Does it escape them, and then concatenate? Or does concatenation actually make a closure, which is only executed upon output? (And does doing that make things memory heavy.) Haskell is on my next language to learn list. > something like P($var) Ugh. I hate that. I'v…

How about just:

$foo =

$textvar

; $foo->append(Hello!); // etc.

Mozilla proposed to add XML literals to JavaScript at one point, which didn't take off for security reasons, but server-side it's a different ballgame... maybe it could be worked out? Hmm.

Re: Coding Horror: The PHP Singularity

#294

Earlier quoted context omitted.

require 'net/http' puts Net::HTTP.get(URI.parse('http://news.ycombinator.com')).gsub('Hacker', 'Interwebz') I'm confused. Where's the edge? Or, even simpler, require 'open-uri' puts open('http://news.ycombinator.com').read.gsub('Hacker', 'Interwebz')

I knew I was going to get some code golf responses. Simple and short are two different things. I value PHP over Ruby here because it's much clearer to the layman what's going on. To explain the PHP, all I have to explain is functions, variables, and the echo statement. To explain the Ruby, I have to explain functions, variables, Objects (everything is an object), Libraries, I/O, and method invocations. Also, in class…

And to Jeff Atwood's original point, you cannot copy-paste the file onto basically any http webhost on earth and have it run out of the box. I don't think that's appreciated in the threads thus far, is that web hosting companies have really done a lot of work for you for PHP and Perl that you have to do yourself with other web programming platforms. They might be better, but they aren't as universally available and supported. (For some value of "supported" which is usually "enough")

Re: Coding Horror: The PHP Singularity

#295
post #279

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…

I stopped reading the blog article when I read the complaints around "private" and "static". The behavior is exactly what they were intended to. If he doesn't want that, he shouldn't use them. It also implies that he doesn't have much experience with languages like C#, Java or C++. Otherwise he would have learned this already.

Or I think they're misfeatures everywhere.

Re: Coding Horror: The PHP Singularity

#296

Give me a non-PHP alternative to Drupal, and I'll switch in a second.

I found this one to be the better of Python's, IMO anyway. http://www.merengueproject.org/

Merengue isn't that great. Save the headache and stick with Drupal.

Re: Coding Horror: The PHP Singularity

#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 and even the original manual claims that separate operators for strings and numbers are confusing.

> I'm not sure if I understand this but all objects are passed-by-reference in PHP (since 5) and PHP references act appropriately when used as function parameters, etc.

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

> You can declare constants in classes and namespaces with the const keyword.

Okay. Why not at top-level?

> You can cast scalars to single element arrays and objects to arrays with the same structure. Both are actually very useful.

You've practically invented a bug right there: 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.

> PHP is interpreted -- namespaces and autoloaders are PHP's module system.

What does being interpreted have to do with anything? Python and Perl are bytecode-interpreted (not positive about Ruby) and they both have rich module systems that don't require any fussing around. Heck, shell is interpreted, but zsh manages something almost like modules.

> Empty is equivalent to the not operator but will also work on undefined variables -- that's why it requires a variable.

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

> Useful inside of templates where matching { } is much more difficult.

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

> Sometimes you don't care if a function succeeds; like with the unlink() function which will raise an error if the file you're trying to delete doesn't exist.

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

> Not true. Debug_backtrace() will give you a stack trace in an error handler.

I said "PHP errors don't provide stack traces", and you aren't disputing that. Your own code can muck around to give you a stack trace (in most cases), yes, but the runtime doesn't do it for you.

> Assuming, of course, the programmer doesn't do anything to handle errors.

Defaults are important. I sure have a lot of people telling me it's great that PHP does web stuff out of the box -- why is it not then bad that PHP doesn't help you fix errors out of the box?

> E_STRICT (or lack of it) is for compatibility with PHP4. When enabled it will "warn you about code usage which is deprecated or which may not be future-proof." -- quote from the manual.

Yes, and that doesn't describe what it does. You can't tell what it's for, either: it's clearly not for compatibility with just PHP4, because even the PHP 5.4 release notes mention the addition of a new E_STRICT. 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.

> This author is confused why syntax errors would be parse errors but logic errors are not.

Read more carefully; the two lists are written roughly in parallel. A bogus object attribute gets a warning, but a bogus class attribute is a fatal error. (Not an exception, either, so you can't catch it with the exception handling that the OO system is supposed to be using.) A string value stored in a variable can be called, but the same string value as a literal cannot. And so on.

> This is sort of true; PHP errors and exceptions exist in different universes but it's easy to unify them and PHP even provides a built-in exception ErrorException to do so. You can turn every PHP error into an exception with 4 lines of code complete with stack traces.

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

I have the same kind of complaints about Perl's exception handling -- it's entirely possible to hack it into something more useful, but why on Earth should I have to mess around just to make something as fundamental as errors be developer-friendly?

> PHP supports both procedural and OO programming styles -- this is not a bad thing.

Exception handling isn't inherently OO. Perl has its own flavor of try/catch that requires zero objects whatsoever.

> PHP is reference counted with a cycle-detecting GC. That would not leak memory.

I believe it used to, but I removed this due to the short window during which it was a bug. I see this list of counter-arguments hasn't been updated in a while.

> This is true, but it's an ongoing discussion on how to correctly handle scalar type hints. For all the discussion about how PHP isn't designed the author takes issue with the thing they're taking their time on.

My issue isn't that they're taking their time, 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).

> Because of the dynamic abilities of PHP, there is simply no way for the interpreter to ever figure out the variable to close over.

Every other dynamic language ever sure seems to be able to get this right.

> C++ does it. $obj::foo doesn't make any sense, if you're accessing class attributes then you use the class name Class::foo.

Then why not use Class->foo? Why does this need two operators? $obj::foo is perfectly reasonable if I want the foo attribute of whatever class $obj is; that's half the reason I ever use class attributes.

> This is personal taste not a valid critique.

Yes, which is why I said it's personal taste. Regardless, it's still wildly inconsistent with the rest of the language and poorly bolted on.

> That is, in fact, the point. PHP is supposed to be a thin scripting language layer over C. It's expanded beyond that. Many of the poor naming conventions are not because of PHP but rather are the exact API of the underlying C library.

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

> Both the C API and PHP have both these functions for backwards compatibility reasons.

No. The C API has two functions because one takes only a value to escape, and the other takes both a value and a connection pointer. Both functions in PHP can be called with merely a value, and the "real" one will use the current global connection. 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.

> Most of these are provided by frameworks just as they are in Python, Ruby, C#, etc.

PHP is praised for its web features, but is missing a whole pile of functionality instrumental for actually writing nontrivial web applications. Either judge PHP only by the core language, or judge everything else by what you get with frameworks.

Re: Coding Horror: The PHP Singularity

#298
post #248
post #237

Earlier quoted context omitted.

The aspects of PHP that are bad (and there are more than a few) are easily tooled around. We have a review-time tool that parses your PHP, symbolically executes it, and looks for dubious idioms, flagging them for you and your reviewer. Meanwhile, PHP gets a number of things very right. For instance: * State: there is none across requests. Oh sure, there's APC, and the filesystem, and databases, etc., but those are al…

>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.

Re: Coding Horror: The PHP Singularity

#299

Oh great. Another PHP article, where we get to watch all of the defenders of Rasmussen's misbegotten spawn come out from under their rocks... "PHP works great for me! It runs tons of websites! I don't know what you're complaining about..." To address the article's point somewhat - there are already easy to deploy frameworks and languages for the web, and everybody who cares about development is already using them.

Who's Rasmussen? > there are already easy to deploy frameworks and languages for the web, and everybody who cares about development is already using them. And yet, amongst your rhetoric, you've conveniently managed to name none of them. Is this an appeal to the silent majority? I'm convinced that there are really good developers out there who just keep building great products in PHP. Good developers write good code l…

> Who's Rasmussen?

Brainfart. I meant Rasmus.

A programming language is a tool to get the machine to do what you want. A good tool will help you get the job done faster, and with fewer problems (like, say, security holes). It's not a "mere artificial interface", and if you think so, feel free to go write a web server in Brainfuck.

Re: Coding Horror: The PHP Singularity

#300
post #37

Oh great. Another PHP article, where we get to watch all of the defenders of Rasmussen's misbegotten spawn come out from under their rocks... "PHP works great for me! It runs tons of websites! I don't know what you're complaining about..." To address the article's point somewhat - there are already easy to deploy frameworks and languages for the web, and everybody who cares about development is already using them.

everybody who cares about development is already using them. Even if we take that statement as given, what about everybody who doesn't care about development? Most modern frameworks take it as given that you are (or at least aspire to be) a fairly serious web developer interested in serious web development and are willing to learn a bunch of fairly abstract concepts up front about structuring and deploying apps. Unti…

HTML. Or some sort of managed CMS.

Something that doesn't involve any programming. Because getting all of the bits of web development together is hard work, and you're not likely to end up with anything decent at the end if you don't know what you're doing.

Post reply on HN