Live data from Hacker News

Making PHP Safer

tech.blog.box.com

21–30 of 53 posts

Re: Making PHP Safer

#21

I hate annotations in PHP. They feel very tacked-on. I'd much rather see actual enforced typing in the language. This is a step in the right direction, but it doesn't go far enough, in my opinion.

PHP doesn't have annotations.

The framework you are using may be emulating them, though. By parsing docblocks. Hence why it feels like that.

Re: Making PHP Safer

#22

I sure had no idea Box uses PHP.

Does anyone have a rough census of what top websites use? I've had this same reaction, but more than once with PHP: I know now that at least Box, Wikipedia, and Facebook use PHP.

Re: Making PHP Safer

#23

Reading this, wishing Facebook's Hack lang was OSS so I could really have a chance to sink my teeth in and compare/contrast these tools. Edit: Clarity

Facebook's Hack lang is open source, though not publicly documented. This commit points out a lot of the implementation and test files: https://github.com/facebook/hhvm/commit/db9577b1409b74293fd9...

Re: Making PHP Safer

#24
post #19

Earlier quoted context omitted.

In a very literal sense, everything in PHP is tacked on. It's a conglomeration of crap. You could replace "crap" with something more politically correct in that sentence, but it could not possibly be more literally correct. Annotations. Namespaces. There is nothing in PHP that was not an afterthought. While it could technically be considered "unfair" to criticize the language in that respect, the total failure to pus…

While I agree with nearly every assertion you make, I'm still hazy on what 'good' is. Surely the fact that so many people find PHP the most productive language they could've worked with, and produce mountains and mountains of working code that is at least mostly reliable - don't those qualities alone make it in some sense good? Then again I think some pop music is good, so I'm starting from a point where I don't nece…

There can be elegance found in writing well-formed code of any language. It may be tougher in PHP, but it's certainly possible.

To use a car analogy, I have more respect for the guy running an old Mustang he tunes up and runs a 11 second quarter-mile than the jackass who drops 200 large on an exotic that pulls a 10.

Re: Making PHP Safer

#26

I sure had no idea Box uses PHP.

Does anyone have a rough census of what top websites use? I've had this same reaction, but more than once with PHP: I know now that at least Box, Wikipedia, and Facebook use PHP.

Facebook doesn't use PHP the way other companies do. They ship & run binaries via HipHop/HipHop Virtual Machine (HHVM) in production. Other companies which use Facebook as an excuse (justification) to use PHP in production ship standard PHP scripts into Production and think they are doing the same thing Facebook does.

Re: Making PHP Safer

#27
post #26

Earlier quoted context omitted.

Does anyone have a rough census of what top websites use? I've had this same reaction, but more than once with PHP: I know now that at least Box, Wikipedia, and Facebook use PHP.

Facebook doesn't use PHP the way other companies do. They ship & run binaries via HipHop/HipHop Virtual Machine (HHVM) in production. Other companies which use Facebook as an excuse (justification) to use PHP in production ship standard PHP scripts into Production and think they are doing the same thing Facebook does.

True, although didn't that happen only after many years of them using regular PHP in production? IIRC, HipHop dev only really got going in the 2010s.

Re: Making PHP Safer

#28

Earlier quoted context omitted.

In a very literal sense, everything in PHP is tacked on. It's a conglomeration of crap. You could replace "crap" with something more politically correct in that sentence, but it could not possibly be more literally correct. Annotations. Namespaces. There is nothing in PHP that was not an afterthought. While it could technically be considered "unfair" to criticize the language in that respect, the total failure to pus…

Thank goodness there are people in this world who care more about shipping than about perfection. Thank goodness there are people who have thicker skin than I, and release FOSS to the world despite comments like yours.

And if others listened to people like you, we would all still live on trees.

Re: Making PHP Safer

#29

I hate annotations in PHP. They feel very tacked-on. I'd much rather see actual enforced typing in the language. This is a step in the right direction, but it doesn't go far enough, in my opinion.

Facebook is doing something similar, but instead of annotations they are breaking syntax compatibility (for the better, I think). This talk is unfortunately the only reference i can find: http://www.infoq.com/presentations/php-history relevant part starts around minute 22.

Re: Making PHP Safer

#30
post #18

I hate annotations in PHP. They feel very tacked-on. I'd much rather see actual enforced typing in the language. This is a step in the right direction, but it doesn't go far enough, in my opinion.

Yes I dislike the use of 'annotations'. Would it not be better to catch the recoverable error that "function foo (integer $a)" gives, then use your error handler to check that $a is an integer?

This does not satisfy the requirement of low performance implications. Augmented Types works by wrapping zend_compile and adding opcodes to to the compiled PHP to check the types of the arguments. This way Augmented Types can be run once at compile time (yes, PHP is compiled) and ensure type safety of all subsequent invocations.
Post reply on HN