PHP Tour Lyon - Benjamin Clay & Mathieu Darse - Juin 2014
PHP Tour Lyon - Benjamin Clay & Mathieu Darse - Juin 2014
C'est facile
Rapide à apprendre
Disponible pratiquement partout, et souvent très facilement
Belles choses à faire avec ? :)
Inconsistances "haystack / needle"
PHP c'est de l'HTML avec de la logique
Pas de standards
Pas de librairies de qualité
Des erreurs de conception
==
==
Ils auraient dû tout réécrire en utilisant un vrai langage, du [python|ruby|java|...]Marcel Patulacci - Brigadier chef, et agent de la paix avant tout.
Ils auraient dû tout réécrire en utilisant un vrai langage, du [python|ruby|java|...], mais plus tôt.Marcel Patulacci - Brigadier chef, et agent de la paix avant tout.
Languages don't scale. Architecture does.
Abraham Lincoln
Réécriture pas à pas
Beaucoup moins de développeurs disponibles
Obligation d'apprendre l'API Zend

a + b * 3
assetic codeigniter composer doctrine2 drupal facebookphpsdk fastroute guzzle hhvmquickinterp idiorm jshrink json_schema laravel lessphp mediawiki mockery monolog mustache paris phpbb3 phpmyadmin phpunit ratchet reactphp slim stash twig
brew tap mcuadros/hhvm mais pas très à jour
#golang, utilisez #hacklang ;)<?hh // Strict
<?php
$href = 'http://www.estcequecestbientotleweekend.fr';
echo <a href={$href}>Facebook</a>;
?> non disponiblePHP est dynamiquement typé !
Flexibilité
Erreurs possibles?type<?hh
class Poney {
private int $weight;
public function __construct(int $weight) {
$this->weight = $weight;
}
public function addWeight(int $delta)
: Poney {
$this->weight += $delta;
return $this;
}
public function getWeight(): int {
return $this->weight;
}
}
?type<?hh
class Poney {
public function __construct(
private int $weight
) {
}
public function addWeight(int $delta)
: Poney {
$this->weight += $delta;
return $this;
}
public function getWeight(): int {
return $this->weight;
}
}
$ hh_client pour voir l'état<?hh
class List<T> {
public function __construct(
private T $data
) {
}
public function insert(T $data)
: void {
// Stuff
}
public function count()
: int {
// Stuff
}
}
$map = Map{'pony' => 5, 'unicorn' = 42};
$vector = Vector{'pony', 'unicorn'};
$set = Set{'pony', 'unicorn'};
$pair = Pair{'jolicode', 42};
==> : Syntaxe plus courte<?hh
$poney = $x ==> $x + 1;
$poney(41); // 42
$squared = array_map($x ==> $x*$x, array(1,2,3));
var_dump($squared); // $squared is array(1,4,9)
async et await keywords<?hh
async function getPage($url) {
$fp = fopen($url, 'r');
await $fp;
return stream_get_contents($fp);
}
$pages = await [
getPage('http://www.jolicode.com'),
getPage('http://www.perdu.com'),
getPage('http://www.mangercoder.fr')
];
Variables globales, goto, if ... endif;, break N, ...
hackificatorhh_server convert
| PHP 5.5 | PHP 5.5 + opcache | HHVM | HHVM + Hack | |
|---|---|---|---|---|
| Concurrence = 1 | 8 | 20 | 23 | 26 |
| Concurrence = 100 | 35 | 70 | 78 | 146 |
༼ つ ◕_◕ ༽つ THE POWER OF HACK ༼ つ ◕_◕ ༽つ
4000 requêtes - The higher the better ;)

pour 
... une motivation énorme pour faire bouger les choses !
<?hh
function getAnswer(Speaker $speaker, Vector<Question> $questions)
:?Answer
{
foreach ($questions as $question) {
if ($speaker->canAnswer($question)) {
return $speaker->giveAnswer($question);
} else {
// OMG, $speaker->getName(), YOU SUCK!
return null;
}
}
}