News for hackers. Stuff that matters.
Re:Hack: a new programming language for HHVM by wambotron on Thursday March 20, 2014 @12:51PM (#7436803)
Why use

public string $x = '';

instead of

public $x:string = '';

It seems inconsistent to me, probably because I've used AS3/Haxe.

Re:Hack: a new programming language for HHVM by wvenable on Thursday March 20, 2014 @01:01PM (#7436875)
PHP is based on C. It's way more consistent with C, Java, C# , etc to do the former. So the real question is why

    function foobar() : int { .. }
instead of

    function int foobar() { .. }
Re:Hack: a new programming language for HHVM by amenghra on Thursday March 20, 2014 @01:18PM (#7437030)
1. function foobar() makes it easier to grep for. 2. if I recall correctly, it made some parts of the grammar easier.
Re:Hack: a new programming language for HHVM by wambotron on Thursday March 20, 2014 @01:37PM (#7437196)
Yeah, you could go either way on it really. It seems weird to mix them, though!
Re:Hack: a new programming language for HHVM by Rican7 on Thursday March 20, 2014 @01:03PM (#7436893)
Its not just inconsistent with other languages, its consistent with their own language.

Property types are declared before the property name, while function return types are declared after (and with a colon).

Very strange.

Re:Hack: a new programming language for HHVM by fzltrp on Thursday March 20, 2014 @01:38PM (#7437204)
If you look at the original C syntax for function types, it is also a bit weird: part of the type (the return type) is placed before, and part (the parameters) after.

That syntax in hack seems more "functional" to me. That said, I must admit that I kind of like the C syntax, because of its oddity.

Re:Hack: a new programming language for HHVM by fauigerzigerk on Thursday March 20, 2014 @03:38PM (#7438035)
But inconsistency is consistent with PHP's philosophy ;-)
Re:Hack: a new programming language for HHVM by kreek on Thursday March 20, 2014 @12:57PM (#7436848)
I too programmed for a long time in AS3/Haxe, and while I prefer variable:type as I think it's more readable, most static languages (java, C#) do it the other way.
Re:Hack: a new programming language for HHVM by wambotron on Thursday March 20, 2014 @01:39PM (#7437216)
Yeah, I'm just not sure why they have public function get_name(): string but use public string $x = '';

The incosistency drives me a bit crazy.