Slide 1

Slide 1 text

By Thijs Feryn What's new in

Slide 2

Slide 2 text

Hi, I’m Thijs

Slide 3

Slide 3 text

I’m @ThijsFeryn on Twitter

Slide 4

Slide 4 text

I’m an Evangelist At

Slide 5

Slide 5 text

I’m a at board member

Slide 6

Slide 6 text

To know where PHP is heading, you have to know what happened in the past

Slide 7

Slide 7 text

PHP 7.0: December 3rd 2015 PHP 5.6: 2014 PHP 5.5: 2013 PHP 5.4: 2012 PHP 5.3: 2009 PHP 5.2: 2006 PHP 5.1: 2005 PHP 5.0: 2004

Slide 8

Slide 8 text

We've been using PHP 5 for 11 years

Slide 9

Slide 9 text

Why is there no PHP 6?

Slide 10

Slide 10 text

Windows 10?

Slide 11

Slide 11 text

PHP 6 did once exist

Slide 12

Slide 12 text

But was never released

Slide 13

Slide 13 text

A history lesson

Slide 14

Slide 14 text

First ideas in 2005 by Andrei Zmievski at Yahoo

Slide 15

Slide 15 text

PHP 6 was all about unicode support

Slide 16

Slide 16 text

And some extra language features

Slide 17

Slide 17 text

✓Namespaces ✓Late static binding ✓Goto labels ✓Object casting to primitives ✓Type hinting ✓APC ✓Non-fatal errors should become exceptions PHP 6 extra language features

Slide 18

Slide 18 text

Delays, delays, delays …

Slide 19

Slide 19 text

Most non-Unicode features were released in PHP 5.3

Slide 20

Slide 20 text

The rest was eventually shipped off to PHP 5.4

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

✓UTF-16 or UTF-8? Or even UTF-32? ✓Few people know intricacies of Unicode & ICU ✓Major performance penalty (300%) ✓Too much effort to port all code PHP 6 unicode difficulties

Slide 23

Slide 23 text

Controversy

Slide 24

Slide 24 text

In 2010 the core team concluded that Unicode support for PHP was too hard to implement

Slide 25

Slide 25 text

Ah, Jani went a little crazy today in his typical style to force a decision. The real decision is not whether to have a version 5.4 or not, it is all about solving the Unicode problem. The current effort has obviously stalled. We need to figure out how to get development back on track in a way that people can get on board. We knew the Unicode effort was hugely ambitious the way we approached it. There are other ways. So I think Lukas and others are right, let's move the PHP 6 trunk to a branch since we are still going to need a bunch of code from it and move development to trunk and start exploring lighter and more approachable ways to attack Unicode. We have a few already. Enhanced mbstring and ext/intl. Let's see some good ideas around that and work on those in trunk. Other features necessarily need to play along with these in the same branch. I refuse to go down the path of a 5.4 branch and a separate Unicode branch again. The main focus here needs to be to get everyone working in the same branch. -Rasmus March 11 2010

Slide 26

Slide 26 text

March 11 2010 PHP6

Slide 27

Slide 27 text

PHP 6 trunk PHP 6 branch PHP 5.4 trunk

Slide 28

Slide 28 text

The PHP 5.4 era sparked the PHP Renaissance

Slide 29

Slide 29 text

How did we end up with PHP 7?

Slide 30

Slide 30 text

Controversy

Slide 31

Slide 31 text

PHP Next Generation

Slide 32

Slide 32 text

To JIT or not to JIT?

Slide 33

Slide 33 text

PHPNG vs HHVM

Slide 34

Slide 34 text

Tackling misinformation

Slide 35

Slide 35 text

When we aren't looking for pictures of kittens on the internet, internals developers are nearly always looking for ways to improve PHP, a few developers have a focus on performance. Over the last year, some research into the possibility of introducing JIT compilation capabilities to PHP has been conducted. During this research, the realization was made that in order to achieve optimal performance from PHP, some internal API's should be changed. This necessitated the birth of the phpng branch, initially authored by Dmitry Stogov, Xinchen Hui, and Nikita Popov. This branch does not include JIT capabilities, but rather seeks to solve those problems that prohibit the current, and any future implementation of a JIT capable executor achieving optimal performance by improving memory usage and cleaning up some core API's. By making these improvements, the phpng branch gives us a considerable performance gain in real world applications, for example a 20% increase in throughput for Wordpress. The door may well now be open for a JIT capable compiler that can perform as we expect, but it's necessary to say that these changes stand strong on their own, without requiring a JIT capable compiler in the future to validate them. The name "Next Generation" was optimistically presumptuous; in reality phpng is an internal project that we are working on, it is not a production ready branch that anyone should deploy, or judge as they would a release of PHP. The work on phpng, the doors it opens, the conversations it has started, the collaboration it is inspiring, are all worth getting excited about. But, we need to stay grounded, honest, and open; and say that there is much work to do in order to make the "Next Generation" a reality, this is only the start. May 27th 2014 by Joe Watkins

Slide 36

Slide 36 text

Backlash

Slide 37

Slide 37 text

Hi, Joe made a post about the introduction on phpng, what it is, and what it isn't. Some people (myself included) didn't liked that post for various reasons (some says it is opiniated, some doesn't like the tone and the wording, others feel that it is too early to made official announcement about phpng).. There were a couple of iteration on improving the text, but it is still not up to our standards imo: http://git.php.net/?p=web/php.git;a=history;f=archive/entries/2014-05-27-1.xml ; It is already on hackernews and reddit, so while some people suggested, I think it would be a bad move to just remove it. Would like to know what do you guys think about the best step, I see the following possible options: - keep it as is - remove it - rewrite it to be more formal and factual(only talk about what it is atm. not what it could be in the future). - create a post explaining that this post is controversional among the core-devs, so it is reflects more of the authors opinion than the projects official view on the topic. I'm mostly interested on the opinion of the core devs, but others also welcome to reply. -- Ferenc Kovács @Tyr43l - http://tyrael.hu May 28th 2014

Slide 38

Slide 38 text

Hackernews Reddit Blogs Social media

Slide 39

Slide 39 text

Sparked progress on the next major version of PHP

Slide 40

Slide 40 text

Controversy

Slide 41

Slide 41 text

PHP 6 or PHP 7? Or even PHP 5.7?

Slide 42

Slide 42 text

Decision was made: PHP 7

Slide 43

Slide 43 text

PHP 7 is all about performance

Slide 44

Slide 44 text

Healthy competition with HHVM

Slide 45

Slide 45 text

All this controversy

Slide 46

Slide 46 text

Old boys club vs Young guns

Slide 47

Slide 47 text

Balance between PHP as a easy-to-use scripting language and a mature future-proof programming language

Slide 48

Slide 48 text

New language features

Slide 49

Slide 49 text

✓Scalar type hints ✓Return type declarations ✓Anonymous classes ✓Closure::call() ✓Generator delegation ✓Generator return expressions ✓Null coalesce operator ✓Space ship operator ✓Throwables ✓Uniform variable syntax ✓… PHP 7 new language features

Slide 50

Slide 50 text

Controversy

Slide 51

Slide 51 text

Loosely typed vs Strict types

Slide 52

Slide 52 text

Compromise

Slide 53

Slide 53 text

declare(strict_types=1);

Slide 54

Slide 54 text

Slide 55

Slide 55 text

Fatal error: Uncaught TypeError: Argument 1 passed to add() must be of the type integer, string given TypeError: Argument 1 passed to add() must be of the type integer, string given

Slide 56

Slide 56 text

Slide 57

Slide 57 text

Fatal error: Uncaught TypeError: Return value of add() must be of the type integer, string returned TypeError: Return value of add() must be of the type integer, string returned

Slide 58

Slide 58 text

Type Errors

Slide 59

Slide 59 text

Throwables Errors Exceptions Type error

Slide 60

Slide 60 text

getMessage().PHP_EOL; }

Slide 61

Slide 61 text

Throwables

Slide 62

Slide 62 text

getMessage().PHP_EOL; } //Exception as Throwable try { throw new Exception("Bla"); } catch (Throwable $t) { echo "Throwable: ".$t->getMessage().PHP_EOL; }

Slide 63

Slide 63 text

getMessage().PHP_EOL; } catch (Exception $e) { echo "Exception: ".$e->getMessage().PHP_EOL; } //Type error try { function add(int $a, int $b):int { return $a + $b; } echo add(array(), array()); } catch (TypeError $t) { echo "Type error: ".$t->getMessage().PHP_EOL; }

Slide 64

Slide 64 text

Anonymous classes

Slide 65

Slide 65 text

foo());

Slide 66

Slide 66 text

Generators Since PHP 5.5 Iterator shorthand Less overhead

Slide 67

Slide 67 text

Yield

Slide 68

Slide 68 text

Slide 69

Slide 69 text

Slide 70

Slide 70 text

getReturn(), PHP_EOL;

Slide 71

Slide 71 text

Space ship operator

Slide 72

Slide 72 text

1" => 1 <=> 1, "1 <=> 2" =>1 <=> 2, "2 <=> 1" => 2 <=> 1 ]; var_dump($array); array(3) { '1 <=> 1' => int(0) '1 <=> 2' => int(-1) '2 <=> 1' => int(1) } Output

Slide 73

Slide 73 text

Null coalesce operator

Slide 74

Slide 74 text

'bar']; //PHP5 style $message = isset($array['foo']) ? $array['foo'] : 'not set'; echo $message.PHP_EOL; //PHP7 style $message = $array['foo'] ?? 'not set'; echo $message.PHP_EOL;

Slide 75

Slide 75 text

Closure::call()

Slide 76

Slide 76 text

foo; }; //PHP5 style $binding = $getFooCallback->bindTo(new Foo,'Foo'); echo $binding().PHP_EOL; //PHP7 style echo $getFooCallback->call(new Foo).PHP_EOL;

Slide 77

Slide 77 text

Uniform variable syntax

Slide 78

Slide 78 text

Uniform variable syntax

Slide 79

Slide 79 text

PHP 7 is fast

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

Speed depends on the your code and your case

Slide 82

Slide 82 text

Up to 300% speed increase with lower memory usage

Slide 83

Slide 83 text

Don't believe the banchmarks though

Slide 84

Slide 84 text

Why is PHP 7 so fast, even without the JIT?

Slide 85

Slide 85 text

ZVAL Internal variable representation Loosely typed variables in a strictly typed language

Slide 86

Slide 86 text

Typedef struct _zval_struct { union { long lval; double dval; struct { char *val; int len; } str; HashTable *ht; struct { zend_object_handle handle; zend_object_handlers *handlers; } obj; } value; zend_uint refcount; zend_uchar type; zend_uchar is_ref; } zval; Typedef struct _zval_struct { union { long lval; double dval; zend_refcounted *counted; zend_string *str; zend_array *arr; zend_object *obj; zend_resource *res; zend_reference *ref; void *ptr; } value; union { struct { zend_uchar type; zend_uchar flags; }; zend_uint type_info; }; zend_uint reserved; } zval; PHP 5 vs PHP 7

Slide 87

Slide 87 text

Remove pointers (to pointers) to ZVALs

Slide 88

Slide 88 text

Direct use of ZVAL in most cases

Slide 89

Slide 89 text

From heap to stack

Slide 90

Slide 90 text

Less refcounting Less garbage collection

Slide 91

Slide 91 text

New memory manager Less CPU time Less memory overhead

Slide 92

Slide 92 text

A lot of small optimizations

Slide 93

Slide 93 text

No content

Slide 94

Slide 94 text

https://blog.feryn.eu https://talks.feryn.eu https://youtube.com/thijsferyn https://soundcloud.com/thijsferyn https://twitter.com/thijsferyn http://itunes.feryn.eu