Live data from Hacker News

Coding Horror: The PHP Singularity

codinghorror.com

171–180 of 341 posts

Re: Coding Horror: The PHP Singularity

#171
post #124

Earlier quoted context omitted.

Hey. I work on Facebook's PHP toolchain, HipHop, which these days includes a debugger, interpreter, JIT compiler, and the ahead-of-time compiler. The fact that the AoT compiler uses C++ as a target doesn't change the input language, which really is PHP. E.g., $i = 0; $a[$i] = $i++; makes a different array than $i = 0; $a[$i + 0] = $i++;. We have to get all the nooks and crannies right because we use significant open…

I have to ask, because it's really been getting at me for a while honestly. How do your developers react to that? I mean, you guys are known for going after the best and the brightest. People who have worked hard to perfect their craft. These people tend to have strong opinions when it comes to language design. How do you get them from that point to "ok, now write some php code" ?

The best and the brightest appreciate the technical, product, and engineering challenges of Facebook and certainly don't waste their time whining about a language or feeling entitled.

Re: Coding Horror: The PHP Singularity

#172

PHP got Facebook up and running, so it has that to its credit. And that's a huge credit. As a result, Facebook engineers developed things like this: http://en.wikipedia.org/wiki/HipHop_for_PHP Which is an impressive piece of technology, but makes you wonder if Facebook engineers wish their website wasn't written in PHP.

It surprised me, considering the original developers of facebook (Zuckerberg, Moskovitz) were doing Computer Science degrees why they chose PHP to build it in initially. Did they consider other languages, or frameworks. I'd be surprised if they chose PHP because of future hireability / scaling up. I'd guess they didn't give it much thought and PHP was just there.

I'm pretty sure it was solely because Zuck happened to have a LAMP host at his disposal at the time.

Re: Coding Horror: The PHP Singularity

#173
Anyone have a full article on how to build a site with just Python and not using Django? This would be more helpful than bashing PHP.

The article would have to show us how to install Python, configure it, get it working on the server, what to upload, how to deal with forms, cookies, etc. I've yet to see this kind of article. I wouldn't mind learning Python for web use, but every book I've seen suggests you just use a framework or has a very small chapter composing of a few pages. Such an article or even a book, would get more people off PHP, if that's what people want. Until then PHP gets stuff done and that's all clients care about, no one cares if I use Windows, Linux or Mac OS X when I work. Granted I'm not a l33t programmer like most on here, I'm just here to learn from better coders.

Re: Coding Horror: The PHP Singularity

#174
post #159
post #73

Ok, so here it goes. I haven't commented on this site for over a year. Full disclosure: I am an average programmer compared to many here. I come to this site to improve my self and read about what brilliant and amazing things you all do. Now you have a reference. I use PHP on a daily basis, have been for years. I am a freelance developer who has been able to carve out a living with a lot of hard work and a lot of luc…

It's not ivory tower for all of us. In my case it all boils down to simple discomfort. Writing PHP code is painful. Reading PHP code is painful. Fixing bugs in PHP code is painful. I don't write rants about it but that's just because I left the language behind years ago and never looked back. But if I had to write for my job? Yeah I'd write a rant every other month probably. I would need some kind of outlet for all t…

Spot on.

Re: Coding Horror: The PHP Singularity

#175
post #73

Ok, so here it goes. I haven't commented on this site for over a year. Full disclosure: I am an average programmer compared to many here. I come to this site to improve my self and read about what brilliant and amazing things you all do. Now you have a reference. I use PHP on a daily basis, have been for years. I am a freelance developer who has been able to carve out a living with a lot of hard work and a lot of luc…

"Finally, let's use his tool analogy. PHP is a double-clawed hammer. What if your job was to remove nails from wood all day?" Brilliant.

IOW, the double-claw "hammer" is just what you may need if your job is to pull nails out of houses that are unsafe because they were built by carpenters who used double-claw "hammer"s to hammer in the nails. Got it.

The analogy is almost perfect! Except that PHP doesn't pull out nails very well.

Re: Coding Horror: The PHP Singularity

#176
post #114
post #85

Earlier quoted context omitted.

> > default to HTML escaping on output > ??? Is that a joke? Don't do that! That's just as bad as magic quotes. Microsoft's Razor and Python's Django templates have both shown that HTML-escaping-by-default can be cleanly done in a way that is not magical and that is highly reliable. I'm not honestly sure what you're protesting here.

If I make a string: ' ' . $var . ' ' - does it know to encode the variable, and not the entire string? What if I assign that string in a variable, and then output it later? I'm not convinced this can be done well. Maybe if all you do is make some templates and fill them in you could do it. But I do a lot more than that, I output dynamically built html all the time. Just give people a very easy and shortly named funct…

> If I make a string: '

' . $var . '

'

I'd say don't do that, refactor into templates instead. With your preferred approach to generating markup, you're largely on your own in protecting against XSS. Hopefully all the developers using your code are awesome at spotting and pro-actively dealing with XSS issues.

Still, with a HTML escape everything default, either turn it off, or use a raw "I know what I'm doing" method instead.

Re: Coding Horror: The PHP Singularity

#177
Here we go again...

Maybe it does suck. You can certainly tell it was not designed by computer scientists. In many ways, it throws away years for programming language best practices.

This being said, what are the practical alternatives? JSP? Servlets? ASP? Python/Django? Ruby/Rails? What?

I am sorry but JSP, Servlets, ASP, Python/Django, Ruby/Rails are just shit of a different kind. But they do not deserve that holier-than-thou aura.

I suggest bad programmers keep blaming their tools for their own shortcomings. I suggest that when bad programmers have produced enough horrors to sully a tool, they blame the tool and move on to the next tool.

Re: Coding Horror: The PHP Singularity

#178
I'm a long-time PHP programmer and have been programming with Lua (for gaming) for the past year and Python for command-line (NumPy) based scripts for the past two years. Obviously, in comparison, the syntax in Lua and Python are a thing of beauty as are the data structures (Lua tables FTW), but I always fall back to PHP for web projects since I haven't had the chance to completely grok the Python deployment process.

Is there a simple guide to deploying Python web applications (preferably with Flask)? I know there are quite a few options (WSGI, FastCGI, mod_python), but what is the best way to do it.

Re: Coding Horror: The PHP Singularity

#179
post #124

Earlier quoted context omitted.

Hey. I work on Facebook's PHP toolchain, HipHop, which these days includes a debugger, interpreter, JIT compiler, and the ahead-of-time compiler. The fact that the AoT compiler uses C++ as a target doesn't change the input language, which really is PHP. E.g., $i = 0; $a[$i] = $i++; makes a different array than $i = 0; $a[$i + 0] = $i++;. We have to get all the nooks and crannies right because we use significant open…

I should have expected someone with more knowledge of the system on HackerNews :) What I mean is that whilst you guys at Facebook are using PHP you're not using it in the sense of 'we write code anywhere and deploy it anywhere'. There's an additional build step in between the developers and the final product, rather than just straight up serving PHP as is which is one of the biggest PHP recommendations. Although HipH…

> ... 'we write code anywhere and deploy it anywhere'. There's an additional build step in between the developers and the final product, rather than just straight up serving PHP as is which is one of the biggest PHP recommendations.

According to him there's no explicit build step the devs have to perform and they're just writing PHP and using open source packages--meaning they are in fact making use of the "write once run anywhere" ideal at least in some places since the open source packages were made to run on Zend and now they don't. The "write once run anywhere" ideal is kind of a myth anyway since there's always configurations to do, and language-wise was even more of a myth when PHP 5.3 was new. (Some hosts still don't support it, and I'm sure a lot of us remember hosting services who dragged their feet just getting off PHP 4.)

It seems like you think the Zend backend is the One True PHP runtime and anything else isn't PHP. This is like saying PyPy isn't Python. It's just a bad argument.

Re: Coding Horror: The PHP Singularity

#180
I can't remember who said it, but the best language is the one that surprises you the least.

To frame that statement into the context of this post and its rebuttals, working daily with the language in question has led to many surprises for myself.

Post reply on HN