Live data from Hacker News

Announcing a specification for PHP

hhvm.com

21–30 of 263 posts

Re: Announcing a specification for PHP

#22

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

Hoping to tide you over until a better answer comes along...

Generally when complex programs (like an entire programming language) are made, there is usually a "specification" of its behaviors. This way, you can communicate to people, hey, my program does ABC and does NOT do XYZ.

Also, it helps you delineate between bugs and what not. My program does AB DEF. Is that a bug? Or a feature? What does the specification say?

Not all programs have a specification. It's a bit formal and unnecessary. Except in a specific scenario where you have multiple/competing implementations of the same programming language. Now that there are multiple players, we need to know exactly which behaviors are per the spec and which behaviors are per the implementation.

All coffee makers must make ABC XYZ. This is the spec.

Sony CoffeeMate makes ABC DEF XYZ. It matches the spec and throws in some extra features.

Samsung Coffee Xtreme makes ABC PQR XY. This also throws in extra features but is actually missing one from the spec.

TL;DR it helps a language evolve independently of its implementations (come the day that a language != its implementation)

Re: Announcing a specification for PHP

#23
After recently having to work with modern PHP, I have to say a lot of the criticism of the language is unfounded. It's changed a lot since I first used it.

But the stdlib is still hard to manage. Different naming conventions, different order on the parameters for functions that do almost the same thing, and every function is global. Couldn't they keep all that for backwards compatibility, but create more sane wrappers and include them as part of the stdlib? For starters, group them by what they work on (arrays, strings, numbers etc.) as static functions on some relevant class ( String::str_replace(...) ), and later have more methods one can call on the objects themselves ( myStr.replace(...) ).

Is this being worked on? Can this spec help with that?

Re: Announcing a specification for PHP

#24
post #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.

I agree, but there are many with a large investment in PHP, and since it isn't going away, it's very much worthwhile to make it better.

Re: Announcing a specification for PHP

#25
post #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.

Perhaps time to revisit PHP some time then? It also has become more mature :) Much of PHP's old built-in functions are crap (side effects, inconsistent parameter order, wierd naming), but you can't really (and shouldn't) compare those parts with another language as there is no correlation.

Re: Announcing a specification for PHP

#28

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

Hoping to tide you over until a better answer comes along... Generally when complex programs (like an entire programming language) are made, there is usually a "specification" of its behaviors. This way, you can communicate to people, hey, my program does ABC and does NOT do XYZ. Also, it helps you delineate between bugs and what not. My program does AB DEF. Is that a bug? Or a feature? What does the specification sa…

Another way to answer this question is that a programming language specification tells what the language does in the case there's no stack overflow answer for the question.

Re: Announcing a specification for PHP

#29

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

A language spec is roughly analogous to the definitions of scientific units of measurement[1]. They among other things, allow us to verify something independently of a specific kind of measuring device.

[1] http://physics.nist.gov/cuu/Units/current.html

Re: Announcing a specification for PHP

#30

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

For one, a language specification is mandatory if you want to standardize it (ECMA, ISO, JIS, ...).

Secondly, it paves the way for competing implementations. Having more implementations automatically means more performance, because they compete with each other.

And finally, a language specification is also super useful to people who create tools such as IDEs, linters, or compilers/transpilers.

Post reply on HN