Live data from Hacker News

Announcing a specification for PHP

hhvm.com

41–50 of 263 posts

Re: Announcing a specification for PHP

#42

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…

> PHP is quite a capable language

I don't think anyone is complaining that it's not turing complete (or whatever), it's all the times php has dropped the ball in the std library, both with respect to being consistent with itself and just being plain broken. I don't think any sane person would switch from a language INTO php, given how many languages that are just as capable as php without having all of its various historical burdens (sigils, stdlib, mediocre type system).

Re: Announcing a specification for PHP

#43
post #31
post #6

Earlier quoted context omitted.

That's not uncommon for implementation-defined languages. Ruby didn't have a language specification until the community set up rubyspec as it started getting serious about alternative implementations. Facebook is apparently getting serious about its own alternative implementation (or at least intending to be taken seriously) and are thus stepping in with a spec.

Often I wonder if going without Spec is a good thing. Ruby doesn't want a Spec because Matz said Ruby is an always evolving languages. But the same could be said about HTML 5 where it does have a living spec.

Python has a spec[0] and Python is an always-evolving language as well[1], so I'll just go ahead and say that it's probably an excuse for laziness rather than an actual justification for not having a spec.

[0] https://docs.python.org/2/reference/

[1] https://docs.python.org/3/reference/

Re: Announcing a specification for PHP

#45
post #34

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…

> Contrary to what many HN hipsters seems to believe, PHP is quite a capable language, and HHVM / Hack is really pushing things forward. This attitude really frustrates me. I'm a developer with over 20 years of experience. I don't use PHP because (a) I have had poor experiences with it in the past, (b) I am enjoying my current stack (Java8/Clojure/Groovy), and (c) would go with stacks like RoR over PHP if I had to ch…

Not parent, but if you make those (completely reasonable) points when you criticize PHP he's not talking about you when he says "HN Hipsters." He's talking about the "What kind of idiot uses php?" crowd, which unfortunately hangs out here too much, and frankly doesn't understand which parts of php actually are good or bad because their entire opinion is based off blog posts not experience.

I don't think you're one of those.

Re: Announcing a specification for PHP

#46
post #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 wrapper…

If you want to order your program in a specific way, you introduce the appropriate level of abstraction. Same as with any other language. EDIT: i totally agree that the standard functions are a complete mess in PHP. But they have to stay around for backwards compatibility. Have a look at the SPL classes: http://php.net/manual/en/book.spl-types.php

This simply isn't possible in a way that would be convenient.

For example, how would I make a string abstraction? Create a class? Ok, so we have:

$str = new String("foo") $str->replace(...)

over

$str = "foo" str_replace($str, ...)

This is fine, if we ignore the fact it's much slower.

Where it really gets annoying is PHP's lack of operator overloading. That means to concatenate I'd need to do

$str->concat($str2)->concat(new String(" "))->concat($str3)

instead of

$str . $str2 . " " . $str3

There's things you can do to make the API a little bit more convenient (i.e. allow it accept PHP strings, etc.), but ultimately it becomes a huge pain, especially if you want to start interoperating with other libraries that are using a different abstraction or, more likely, using the regular PHP types and functions.

Re: Announcing a specification for PHP

#47
post #42

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…

> PHP is quite a capable language I don't think anyone is complaining that it's not turing complete (or whatever), it's all the times php has dropped the ball in the std library, both with respect to being consistent with itself and just being plain broken. I don't think any sane person would switch from a language INTO php, given how many languages that are just as capable as php without having all of its various hi…

Amen. I think this thread could use a little: http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/

It has never been about whether PHP can get shit done, it's that given languages that actually had formal design processes and make your days as a coder a joy, why would you move TO PHP.

There are simply so many other options.

Re: Announcing a specification for PHP

#48

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.

You can also hint on interfaces. If strict typing is important, I use the SPL primitive wrapper classes like SplString or SplInt http://php.net/manual/en/class.spltype.php

Re: Announcing a specification for PHP

#49
post #46

Earlier quoted context omitted.

If you want to order your program in a specific way, you introduce the appropriate level of abstraction. Same as with any other language. EDIT: i totally agree that the standard functions are a complete mess in PHP. But they have to stay around for backwards compatibility. Have a look at the SPL classes: http://php.net/manual/en/book.spl-types.php

This simply isn't possible in a way that would be convenient. For example, how would I make a string abstraction? Create a class? Ok, so we have: $str = new String("foo") $str->replace(...) over $str = "foo" str_replace($str, ...) This is fine, if we ignore the fact it's much slower. Where it really gets annoying is PHP's lack of operator overloading. That means to concatenate I'd need to do $str->concat($str2)->conc…

Well, it doesn't have to be slower. The generated bytecode can be the same. And there could still be syntactic sugar left to allow for easy concating.

Re: Announcing a specification for PHP

#50
post #46

Earlier quoted context omitted.

If you want to order your program in a specific way, you introduce the appropriate level of abstraction. Same as with any other language. EDIT: i totally agree that the standard functions are a complete mess in PHP. But they have to stay around for backwards compatibility. Have a look at the SPL classes: http://php.net/manual/en/book.spl-types.php

This simply isn't possible in a way that would be convenient. For example, how would I make a string abstraction? Create a class? Ok, so we have: $str = new String("foo") $str->replace(...) over $str = "foo" str_replace($str, ...) This is fine, if we ignore the fact it's much slower. Where it really gets annoying is PHP's lack of operator overloading. That means to concatenate I'd need to do $str->concat($str2)->conc…

Javascript doesn't have operator overloading, but it doesn't stop you from doing

    "foo".replace('oo', 'ood') + " tasty"
I don't see why PHP can't treat strings specially as well.
Post reply on HN