Live data from Hacker News

Announcing a specification for PHP

hhvm.com

11–20 of 263 posts

Re: Announcing a specification for PHP

#11

This is great news for the PHP community, and I for one applaud their effort. Contrary to what many HN hipsters seems to believe, PHP is quite a capable language, and HHVM / Hack is really pushing things forward. * Hack introduces type hinting, imo the major lacking part in PHP. * HHVM introduces speed to php. On a personal project calculating perlin noise, I got about 8x speedup on HHVM. * The specification helps pa…

>Hack introduces type hinting, imo the major lacking part in PHP.

Hack extends PHP's type hints, it doesn't add them. It also makes PHP statically typed.

Re: Announcing a specification for PHP

#12

This is great news for the PHP community, and I for one applaud their effort. Contrary to what many HN hipsters seems to believe, PHP is quite a capable language, and HHVM / Hack is really pushing things forward. * Hack introduces type hinting, imo the major lacking part in PHP. * HHVM introduces speed to php. On a personal project calculating perlin noise, I got about 8x speedup on HHVM. * The specification helps pa…

>Hack introduces type hinting, imo the major lacking part in PHP. Hack extends PHP's type hints, it doesn't add them. It also makes PHP statically typed.

I stand corrected.

PHP does not have type hint for their internal datatypes (int, float, string). Only array is supported. Type hinting for your custom datatypes is supported, when used as function arguments.

Also hack introduces type hint for function return type.

Re: Announcing a specification for PHP

#13

Earlier quoted context omitted.

>Hack introduces type hinting, imo the major lacking part in PHP. Hack extends PHP's type hints, it doesn't add them. It also makes PHP statically typed.

I stand corrected. PHP does not have type hint for their internal datatypes (int, float, string). Only array is supported. Type hinting for your custom datatypes is supported, when used as function arguments. Also hack introduces type hint for function return type.

Scalar (int, float, string) type hinting may be added in a future PHP version, and there's currently an RFC for return types (I expect it'll pass myself). PHP already let you type hint for classses.

Re: Announcing a specification for PHP

#14
The PHP grammar in BNF starts at line 10354. It not that extensive as some may think and rather similar to what Java BNF looks like. The expression statement is a bit more extensive than in most languages, as PHP also supports the little known template-style (if elseif endif;): http://php.net/manual/en/control-structures.alternative-synt...

Thanks for the PHP spec.

Btw. GitHub says "Sorry, this blob took too long to generate.": https://github.com/php/php-spec/blob/master/spec/php-spec-dr...

Re: Announcing a specification for PHP

#16

Earlier quoted context omitted.

I stand corrected. PHP does not have type hint for their internal datatypes (int, float, string). Only array is supported. Type hinting for your custom datatypes is supported, when used as function arguments. Also hack introduces type hint for function return type.

Scalar (int, float, string) type hinting may be added in a future PHP version, and there's currently an RFC for return types (I expect it'll pass myself). PHP already let you type hint for classses.

Cool! I wasn't aware of the RFC. Must be this one then? https://wiki.php.net/rfc/returntypehinting

Re: Announcing a specification for PHP

#17

This is great news for the PHP community, and I for one applaud their effort. Contrary to what many HN hipsters seems to believe, PHP is quite a capable language, and HHVM / Hack is really pushing things forward. * Hack introduces type hinting, imo the major lacking part in PHP. * HHVM introduces speed to php. On a personal project calculating perlin noise, I got about 8x speedup on HHVM. * The specification helps pa…

I don't think many would claim that PHP isn't capable. It's that some of us just don't enjoy it and find it to ugly. Especially given how mature competing languages have become.

Re: Announcing a specification for PHP

#18
post #14

The PHP grammar in BNF starts at line 10354. It not that extensive as some may think and rather similar to what Java BNF looks like. The expression statement is a bit more extensive than in most languages, as PHP also supports the little known template-style (if elseif endif;): http://php.net/manual/en/control-structures.alternative-synt... Thanks for the PHP spec. Btw. GitHub says "Sorry, this blob took too long to…

I got the same message on GitHub. Did you checkout the repo in order to read it?

Personally, this is exciting news, but I'm not sure that PHP is ready for this after 20 years. There's plenty of cleanup that needs to be done to userland naming conventions and parameter orders that in all likelihood won't get done anytime soon to avoid breaking BC

Re: Announcing a specification for PHP

#19

Earlier quoted context omitted.

Scalar (int, float, string) type hinting may be added in a future PHP version, and there's currently an RFC for return types (I expect it'll pass myself). PHP already let you type hint for classses.

Cool! I wasn't aware of the RFC. Must be this one then? https://wiki.php.net/rfc/returntypehinting

Yep.

Re: Announcing a specification for PHP

#20

Can someone explain to a layman why this is significant? I'm genuinely curious.

As far as I know, this is providing a better answer to "How do we know this is valid PHP code?" Currently, the answer to that question is "Because it does/doesn't compile using the standard PHP interpreter." When this spec is finalized, the answer will change to "Because it does/doesn't follow the rules laid out in the PHP specification."

In practice, there is a PHP spec, it's just an "unwritten" spec that is defined in the code of the PHP interpreter. With an official "written" spec, it will open the door to alternative PHP interpreters (like HHVM), since they will be able to say that they also support "PHP" as defined in the spec.

Hope this helps!

Post reply on HN