Upgrade to Pro — share decks privately, control downloads, hide ads and more …

HHVM, PHP7 & co

Webconf Riga
November 15, 2015

HHVM, PHP7 & co

PHP 7 is on track, 1st test releases are out, everyone work hard to get the next php major version out. Dozen of patches have reached the branch,amazing RFCs have been worked on and commited. Are you ready to migrate? Hopefully yes! If not and you still need to improve performances, then let take a look at the alternatives. Be full stack alternative PHP implementations like php or small additions to speedup the critical parts of your apps.

Author: Pierre Joye
WebConf Riga 2015

Webconf Riga

November 15, 2015
Tweet

More Decks by Webconf Riga

Other Decks in Programming

Transcript

  1. PHP 7, HHVM & CO 14 – 15 NOVEMBER, 2015

    #WebConfRiga @Webconfriga Riga Pierre Joye
  2. PHP7, hhvm & co Pierre Joye @pierrejoye [email protected] http://www.slideshare.net/pierrej PHP

    Core developer Contributors to numerous OSS projects Portability fan
  3. PHP7, hhvm & co Features • Rewamped Engine • True

    64bit support • Large string and LFS (Large file support) • Consistent variables syntax • Error exception instead of fatal error • Scalar type declarations • Zero cost asserts
  4. PHP7, hhvm & co Features • Secure RNG • PHP4

    constructors deprecated • JIT enabled PCRE • Removed ext/mysql, ext/ereg and more • New ?? and spaceship operators • New JSON parser • Many other features, a lot already target 7.1
  5. PHP7, hhvm & co Error exception https://wiki.php.net/rfc/catchable-call-to-member-of-non-object <?php try {

    $x = null; var_dump($x->method()); // The exception class name is EngineException // in alpha1 } catch (Error $e) { // pass } echo "Alive\n";
  6. PHP7, hhvm & co Scalar Type Declarations <?php declare(strict_types =

    1); function add(int $a, int $b) : int { return $a + $b; } $x = add(1, 2); // The exception class name TypeException // in alpha1 $y = add(0.1, 0.2); // TypeError exception https://wiki.php.net/rfc/scalar_type_hints_v5
  7. PHP7, hhvm & co Null Coalesce Operator (??) <?php $username

    = $_GET['user'] ?? 'nobody'; $username = isset($_GET['user']) ? $_GET['user'] : 'nobody'; // Method/function call $model = Model::get($id) ?? $default_model; if (($model = Model::get($id)) === NULL) { $model = $default_model; } // Chained $x = NULL; $y = NULL; $z = 3; var_dump($x ?? $y ?? $z); https://wiki.php.net/rfc/isset_ternary
  8. PHP7, hhvm & co QB <?php class OilPaintFilter { /**

    @var int32 */ public $levels = 25; /** @var int32 */ public $filterSize = 5; /** * @engine qb * * @param image $dst * @param image $src * * @local float32[*][r,g,b,a] $bin * @local float32 $max_intensity * @local int32 $(current_index|max_index) * @local int32 $(filter_x|filter_y|filter_offset) * @local int32 $(x|y|x_limit|y_limit) * @local int32 $(width|height) * @local float32[r,g,b,a] $pixel * @local float32 $multiplier */ public function filter(&$dst, $src) {…
  9. PHP7, hhvm & co QB <?php function calc($n, &$a) {

    $b = 18; while($n) { $a = $b * $b * $b * $b; $n--; } } $n = 5000000; $a = 0; calc($n, $a); $end = microtime(true);
  10. PHP7, hhvm & co Zephir namespace MyLibrary; class Filter {

    public function alpha(string str) { char ch; string filtered = ""; for ch in str { if (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') { let filtered .= ch; } } return filtered; } }
  11. PHP7, hhvm & co PHP Alternative Implementations • HHVM (native

    code) • Recki-ct (native code) • Phalanger (.net engine)
  12. PHP7, hhvm & co Recki-ct php 5.5 Recki-CT hhvm 3.2

    hippy-c qb simple() 139.63357 1.00000 8.30447 7.65693 8.35018 simplecall() 38.99476 FAIL 1.32552 1.00000 FAIL simpleucall() 54.02041 1.00000 3.52439 1.51072 47.91090 simpleudcall () 52.14534 1.00000 3.75936 1.41614 47.55259 mandel() 21.26249 1.00000 2.03372 2.11208 FAIL mandel_typ ed() 23.16553 1.00000 2.11128 2.09212 3.00061 mandel2() 24.43275 1.00000 2.57704 1.87802 FAIL mandel2_ty ped() 23.79989 1.00000 2.90105 1.57193 7.11054
  13. PHP7, hhvm & co Recki-ct php 5.5 Recki-CT hhvm 3.2

    hippy-c qb ary(50000) 1.39338 FAIL 1.00000 4.47888 FAIL ary2(50000) 1.26952 FAIL 1.00000 2.28231 FAIL ary3(2000) 5.96015 FAIL 1.70997 1.00000 FAIL fibo(30) 39.48440 1.00000 1.60647 16.40883 FAIL hash1(50000) 1.70014 FAIL 1.00000 3.27314 FAIL hash2(500) 2.23648 FAIL 1.00000 1.30044 FAIL heapsort(2000 0) 3.67800 FAIL 1.00000 4.96699 FAIL
  14. PHP7, hhvm & co Future • Extend PHP in php

    (a la hhvm) • Go, Rust, .net extensions
  15. PHP7, hhvm & co Resources • http://wiki.php.net/rfc/ • http://zephir-lang.com/ •

    http:// www.slideshare.net/ircmaxell/high-performance-php -phpnw • http://talks.php.net/fluent15#/ • https://github.com/google/recki-ct • http:// blog.ircmaxell.com/2014/08/introducing-recki-ct.html • https://github.com/chung-leong/qb/wiki/Introduction
  16. PHP7, hhvm & co Resources • https://edit.php.net/ • https://wiki.php.net/rfc/phpng •

    https://wiki.php.net/rfc/abstract_syntax_tree • http:// hhvm.com/blog/6323/the-journey-of-a-thousand-b ytecodes • https:// github.com/php/php-src/blob/master/UPGRADING • https:// github.com/php/php-src/blob/master/UPGRADING .INTERNALS
  17. PHP7, hhvm & co Resources • http://phpdbg.com/ • http://windows.php.net/qa/ •

    http://qa.php.net/ • http://ongr.io • http://aka.ms/AzureCodeManiac2015