Slide 1

Slide 1 text

HHVM & PHP 7 The Next-Generation PHP Engines

Slide 2

Slide 2 text

David Zuelke

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Slide 5

Slide 5 text

@dzuelke

Slide 6

Slide 6 text

PHP 1 - 5

Slide 7

Slide 7 text

http://xkcd.com/208/

Slide 8

Slide 8 text

PERSONAL HOME PAGE TOOLS PHP 1

Slide 9

Slide 9 text

PHP/FI PHP 2

Slide 10

Slide 10 text

PHP 3 Zend gets involved

Slide 11

Slide 11 text

PHP 4 Zend Engine 1

Slide 12

Slide 12 text

PHP 5 Zend Engine 2

Slide 13

Slide 13 text

Slide 14

Slide 14 text

decent OO PHP has started to stop sucking

Slide 15

Slide 15 text

PHP 6

Slide 16

Slide 16 text

~2005: Unicode!

Slide 17

Slide 17 text

UTF-16 is hard

Slide 18

Slide 18 text

PHP 5.3 & 5.4

Slide 19

Slide 19 text

~2008: PHP 6 is taking forever

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

GC! FPM! Namespaces! Lambdas! LSB!

Slide 22

Slide 22 text

suddenly: PSR-0, sharing components, Composer

Slide 23

Slide 23 text

no PHP 5.4 until three years later!

Slide 24

Slide 24 text

(fixes: RFCs and a release process)

Slide 25

Slide 25 text

PHP 6 dies, PHP 5.4 gets the remaining goodies

Slide 26

Slide 26 text

Traits, removal of lots of deprecated old junk

Slide 27

Slide 27 text

PHP has almost become pleasant

Slide 28

Slide 28 text

HIPHOP

Slide 29

Slide 29 text

~2010

Slide 30

Slide 30 text

Facebook's faster PHP, much lower RAM/CPU usage

Slide 31

Slide 31 text

transpile PHP to C++, let g++ handle the rest

Slide 32

Slide 32 text

hard

Slide 33

Slide 33 text

compile times, no eval support, ...

Slide 34

Slide 34 text

HHVM & HACK

Slide 35

Slide 35 text

HHVM

Slide 36

Slide 36 text

~2013

Slide 37

Slide 37 text

JIT: source to bytecode to ("just in time") native x86 code

Slide 38

Slide 38 text

faaaaaaaaaaaaaaaaaaaaaaaaaaaast

Slide 39

Slide 39 text

and a complete nightmare to build (at least right now)

Slide 40

Slide 40 text

lots of work ahead (extensions, Mac/Windows, ...)

Slide 41

Slide 41 text

Version name Intended release date LTS? End of support 3.3 11 Sep 2014 yes 13 Aug 2015 3.4* 6 Nov 2014 no 3.5* 1 Jan 2015 no 3.6* 26 Feb 2015 yes 28 Jan 2016 3.7* 23 Apr 2015 no 3.8* 18 Jun 2015 no 3.9* 13 Aug 2015 yes 14 Jul 2016 3.10* 8 Oct 2015 no 3.11* 3 Dec 2015 no 3.12* 28 Jan 2016 yes 29 Dec 2016 3.13* 24 Mar 2016 no 3.14* 19 May 2016 no 3.15* 14 Jul 2016 yes 15 Jun 2017

Slide 42

Slide 42 text

HACK

Slide 43

Slide 43 text

class  MyClass  {
        const  int  MyConst  =  0;
        private  string  $x  =  '';
        public  function  increment(int  $x):  int  {
            $y  =  $x  +  1;
            return  $y;
    }
 }

Slide 44

Slide 44 text

class  Mailbox  {
        private  ?T  $data;
 
        public  function  __construct()  {
                $this-­‐>data  =  null;
        }
 
        public  function  put(T  $mail):  void  {
                $this-­‐>data  =  $mail;
        }
 
        public  function  check():  ?T  {
                if  ($this-­‐>data  !==  null)  {
                        return  $this-­‐>data;
                }
                return  null;
        }
 }

Slide 45

Slide 45 text

$z  =  11;
 $foo  =  $x  ==>  $y  ==>  $x  *  $z  +  $y;
 $bar  =  $foo(5);
 var_dump($bar(4));  //  outputs  59

Slide 46

Slide 46 text

PHP 7

Slide 47

Slide 47 text

a new engine!

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

bench.php and Wordpress: ~twice as fast

Slide 50

Slide 50 text

https://wiki.php.net/rfc/abstract_syntax_tree !

Slide 51

Slide 51 text

echo  "Does  1+2  equal  3?";
 if  ((1+2)  ==  3)  {
    echo  "Yes  it  does!";
 }  else  {
    echo  "No  it  doesn't...";
 } EchoStatement      ConstantExpression("Does  1+2  equal  3?")   IfBranchStatement      BinaryOpExpression(EQUAL)          BinaryOpExpression(ADD)              ConstantExpression(1)              ConstantExpression(2)          ConstantExpression(3)      EchoStatement          ConstantExpression("Yes  it  does!")      EchoStatement          ConstantExpression("No  it  doesn't...")

Slide 52

Slide 52 text

(this is where HHVM optimizes, too)

Slide 53

Slide 53 text

EchoStatement      ConstantExpression("Does  1+2  equal  3?")   IfBranchStatement      BinaryOpExpression(EQUAL)          ConstantExpression(3)          ConstantExpression(3)      EchoStatement          ConstantExpression("Yes  it  does!")      EchoStatement          ConstantExpression("No  it  doesn't...") EchoStatement      ConstantExpression("Does  1+2  equal  3?")   IfBranchStatement      ConstantExpression(true)      EchoStatement          ConstantExpression("Yes  it  does!")      EchoStatement          ConstantExpression("No  it  doesn't...") EchoStatement      ConstantExpression("Does  1+2  equal  3?")   EchoStatement      ConstantExpression("Yes  it  does!")

Slide 54

Slide 54 text

https://wiki.php.net/rfc/uniform_variable_syntax !

Slide 55

Slide 55 text

$$foo['bar']  ==  ${$foo['bar']};   $$foo-­‐>bar  ==  ${$foo}-­‐>bar;   $$foo::$bar  ==  ${$foo}::$bar;   global  $$foo-­‐>bar  ==  global  ${$foo-­‐>bar};

Slide 56

Slide 56 text

that needs fixing!

Slide 57

Slide 57 text

$foo()['bar']();
 [$obj1,  $obj2][0]-­‐>prop;
 getStr(){0};
 $foo['bar']::$baz;
 $foo::$bar::$baz;
 $foo-­‐>bar()::baz();
  
 foo()();
 $foo-­‐>bar()();
 Foo::bar()();
 $foo()();
  
 (function()  {  ...  })();
 ($obj-­‐>closure)();
  
 [$obj,  'method']();

Slide 58

Slide 58 text

                                             //  old  meaning                      //  new  meaning
 $$foo['bar']['baz'];      ${$foo['bar']['baz']};      ($$foo)['bar']['baz'];
 $foo-­‐>$bar['baz'];          $foo-­‐>{$bar['baz']};          ($foo-­‐>$bar)['baz'];
 $foo-­‐>$bar['baz']();      $foo-­‐>{$bar['baz']}();      ($foo-­‐>$bar)['baz']();
 Foo::$bar['baz']();        Foo::{$bar['baz']}();        (Foo::$bar)['baz']();

Slide 59

Slide 59 text

https://wiki.php.net/rfc/isset_ternary !

Slide 60

Slide 60 text

//  old:
 $user  =  isset($_GET['user'])  ?  $_GET['user']  :  'nobody';
 //  new:
 $user  =  $_GET['user']  ??  'nobody';

Slide 61

Slide 61 text

https://wiki.php.net/rfc/engine_exceptions_for_php7 ?

Slide 62

Slide 62 text

function  call_method($obj)  {
        $obj-­‐>method();
 }
 
 try  {
        call_method(null);
 }  catch  (EngineException  $e)  {
        echo  "Oops,  that  almost  was  a  fatal:  {$e-­‐>getMessage()}\n";
 }

Slide 63

Slide 63 text

https://wiki.php.net/rfc/bigint ?

Slide 64

Slide 64 text

tentative timeline: first RC in June GA in October (yes, 2015)

Slide 65

Slide 65 text

THE FUTURE'S SO BRIGHT I have to wear shades

Slide 66

Slide 66 text

competition is good

Slide 67

Slide 67 text

fragmentation would only hurt everyone involved

Slide 68

Slide 68 text

https://github.com/php/php-langspec

Slide 69

Slide 69 text

The End

Slide 70

Slide 70 text

HHVM & PHP 7 Thanks for listening! Contact: @dzuelke & [email protected]. rate my talk on joind.in!