Live data from Hacker News

Things you should know about PHP 7

pages.zend.com

41–50 of 124 posts

Re: Things you should know about PHP 7

#41
post #40
post #21

Earlier quoted context omitted.

I thought that was rather odd as well. Are there many languages using this form of return type specifier?

It's fairly common in languages that determine (return) types themselves, e.g. Haskell, Scala and F# all use this syntax. Most languages that use a C-style syntax put (return) types in front. It makes very little sense for PHP. A function definition now even has both styles: `function foo(argtype arg) : rettype` instead of `function rettype foo(argtype arg)` or `function foo(arg : argtype) : rettype`.

Hack, ActionScript and TypeScript put the type after. Hack is most likely where this syntax came from.

Re: Things you should know about PHP 7

#42
Note this is just Zend's take on what's important in PHP 7: it's not a complete list.

A more comprehensive list:

- Dual-mode scalar type hints (weak by default, toggleable to strict via a per-file syntax) (https://wiki.php.net/rfc/scalar_type_hints_v5)

- Return type declarations (https://wiki.php.net/rfc/return_types)

- operator (https://wiki.php.net/rfc/combined-comparison-operator)

- Null coalesce operator (??) (https://wiki.php.net/rfc/isset_ternary)

- Closure::call (https://wiki.php.net/rfc/closure_apply)

- Abstract syntax tree (https://wiki.php.net/rfc/abstract_syntax_tree)

- Context sensitive lexer, allowing the use of reserved words in more places (https://wiki.php.net/rfc/context_sensitive_lexer)

- Unicode escape syntax in strings (https://wiki.php.net/rfc/unicode_escape)

- A uniform variable syntax (https://wiki.php.net/rfc/uniform_variable_syntax)

- Expectations (https://wiki.php.net/rfc/expectations)

- Use declaration grouping (https://wiki.php.net/rfc/group_use_declarations)

- Removal of a ton of long-deprecated features

- Massive speed improvements

You can see everything that's been added to PHP 7 on https://wiki.php.net/rfc (look under Accepted and Implemented - PHP 7.0)

Re: Things you should know about PHP 7

#43
post #6
post #4

Earlier quoted context omitted.

> 1. Scheduled to come out in Q4 2015 ... and available on general cheap webhosting sometime around 2020. If we're lucky. Thank god our company slowly moved away from building small PHP websites that have to run on the most fucked up PHP installations from the before-time. Now it's PHP 5.6+ everywhere :-)

>... and available on general cheap webhosting sometime around 2020. If we're lucky. Shared Hosting needs to die off anyway.

This is a ridiculous statement. For many small businesses Shared Hosting makes a lot more sense than a VPS. And for small personal sites as well.

This is like saying "Bicycles need to die out." just because you never ride one.

Disclaimer: I work for a web hosting company.

Re: Things you should know about PHP 7

#44
post #3

TL;DR: 1. Scheduled to come out in Q4 2015 2. operator, see https://wiki.php.net/rfc/combined-comparison-operator 3. Return Type Declarations & Scalar Type Hints 4. Speed improvements (25-70%) 5. Yep, speed improvements are for real. You're welcome.

> 1. Scheduled to come out in Q4 2015

Which won't happen, I can tell you. PHP's release dates always slip by at least a month, and that's without a very unstable master branch like PHP 7 has.

If it does happen, it'll take a few micro (7.0.x) releases until it reaches stability.

> 3. Return Type Declarations & Scalar Type Hints

Also strict scalar typing:

  
However, Zend not mentioning this is to be expected. The company's founders (Zeev Suraski, Andi Gutmans) and employees (Dmitry Stogov and some others) are some of the biggest opponents of strict typing in PHP.

-- disclaimer: I am a former PHP internals developer

Re: Things you should know about PHP 7

#45
post #32

"You can put lipstick on a pig but it's still a pig" - Barack Obama on PHP in 2008

Barack Obama? Do you mean the most famous of the most brilliant hackers? https://www.whitehouse.gov/blog/2014/12/10/president-obama-f...

The man himself ... The Hacker in Chief

    println('I\'m fly, super high');

Re: Things you should know about PHP 7

#46
post #17

Good to see PHP slowly improving, although I haven't used it for years now. On a side note, does anyone know why Drupal 8 is apparently so absurdly slow? I know it's not entirely fair to compare against D7 as it's still technically "under development" but it just seems insane to take that much of a performance hit for nicer OOP semantics...

D8's a work in progress, and if there's one thing I wouldn't be too critical of a wip for, it's performance. Frankly I don't really see drupal's place in the world anymore. It's so absurdly config-heavy, which may have made sense a decade ago but not now. Everyone will just install composer, put laravel/symfony on there, and be off to the races. The era of giant pages of drupal-managed plugins is over, and replaced b…

I'm a WordPress guy, so I am not a Drupal expert. But Laravel/Symfony and Drupal are targeting mostly different audiences (application developers vs website developers/website owners).

Re: Things you should know about PHP 7

#47
post #7
post #3

TL;DR: 1. Scheduled to come out in Q4 2015 2. operator, see https://wiki.php.net/rfc/combined-comparison-operator 3. Return Type Declarations & Scalar Type Hints 4. Speed improvements (25-70%) 5. Yep, speed improvements are for real. You're welcome.

So 1 is not a feature, 4 & 5 are the same thing (and maybe a consequence of 3) while 2 can be remplaced by a single function. Seems like the only new feature are type hints. Looks like Hack has been rebranded as PHP 7.

Actually, scalar type hint support makes PHP 7 marginally slower (more branches), though it could be used for future optimisations.

The speed boost is due to massive engine changes and internal refactoring.

Re: Things you should know about PHP 7

#48
post #23

Earlier quoted context omitted.

Well, maybe you should review your stack. Which C extensions are you missing? There are alternatives for the most part (barring GUI)

The ones I miss most frequently are a faster json parser (I use ujson), a faster msgpack parser and a faster database driver. The pure python versions (even on PyPy) don't make the cut :(

json parser on pypy is competitive, try it (or give us examples where it's not). msgpack needs a better impl, but can be done, database drivers seem to work over cffi at reasonable speed.

Re: Things you should know about PHP 7

#49
post #29
post #16

Earlier quoted context omitted.

Haxe uses the first syntax, as does AS3. So it's not like "other languages" are universally opposed to this order.

AFAICT both Haxe and AS3 consistently put types on the right, including argument declarations. Other languages consistently put it on the left. Most languages make a choice like that; PHP mixes things up a bit. But then, it wouldn't be PHP if it was too consistent ;).

To be fair, it's not the same as an argument type. The type of `foo()` isn't int, it's function. You're not specifying the type of the thing itself, merely the type of what it returns. Though this seems to have been lost on the creators of C. ;)

Re: Things you should know about PHP 7

#50

Earlier quoted context omitted.

It's also completely blank without javascript.

Why are you not running javascript? Is it a environment restriction, out of security concern or personal preference? Since tone can be tricky on the internet I'll just add that I am genuinely curious about this.

Last time it came up on Hacker News, it's because a large amount of people apparently believe that all sites should run without Javascript. I was told that as a web developer that I should "stop trying".

It tends to be a classic case of blaming the tools for the actions of the people using them.

Post reply on HN