2019-08-13

P++: 静的型付けをめざすPHP

PHP: pplusplus:faq

PHP 8から、PHPは「PHP」と「P++」という2つの言語を提供するようになる。P++はPHPとの下位互換性を削りながら除々にPHPを静的型付け言語にする試みだ。

PHP開発者の中には2つの流派がある。PHPの源流であり現在の形である動的型付け言語としてのPHPを良しとする流派と、PHPをより強い静的型付け言語へと発展させたい流派だ。良い悪いの問題ではない。どちらの流派も正当な理由がある。しかし、ゆるふわな動的型付け言語とガチガチの静的片付け言語は同じ一つの言語として同居できない。

そこで、コードネームP++として、PHPを静的型付け言語に発展させる新しい言語の開発が提案された。P++はforkではなく、PHPと同じコードベースを共有する。PHP 8のバイナリはPHPとP++を同時に実装する。言語の切り替えは何らかの宣言によって指定する。

P++はPHPの厳格な下位互換性を諦め、少しずつ下位互換性を切り捨てつつ、PHPを静的片付け言語にしていく。

これはPerl 5/6やPython 2/3という過去の失敗に学んだのだろう。

PHPとP++は同じコードベースであり、ほとんどのコードは共有するので、PHPの開発リソースが2倍必要になることはない。

PHP 7.4をLTSにしてPHP 8から介護感性を切り捨てるのは良いアイディアではない。言語を分断させてしまう。Python 2/3がすでに犯した失敗だ。

PHP 8はPHPとP++を含むので、PHP 8をインストールするとP++もついてくる。同じコードベースでPHPとP++を共存させることもできる。

PHPの開発が止まるわけではない。ただし静的型付け機能はPHPには入らずP++に入る。PHPは下位互換性を重視する。

Hackとはどう違うのか。Hackは一企業による開発であり、コミュニティの意見によって設計されなかった。またHackは流通や知名度の問題で難がある。P++はPHPと共存するので、PHP 8をインストールしたならばもれなくP++もついてくる。

PHPに静的型付けは必要か? 現在、PHPを仕事で使っているプログラマーの中には、本来ならば静的型付け言語を好むが、仕事なのでPHPを使っている人もいる。PHPが静的型付けを提供する意義はある。

11 comments:

Anonymous said...

介護感性

Anonymous said...

介護感性 www

UD said...

https://qiita.com/tadsan/items/80cd844ee612c6cadabf

Anonymous said...

お久しいぶりですね。
自分はPHPは知りませんが古い動的型付けを「BASIC TYPE」としてC++のanyのように投げておけばいいのではないかと思います。

ところで、最近のC++の動向はいかがでしょうか。
7月にペーパー集でなかったんですけど、ペーパーの掲載場所変わったのでしょうか。

C++好きですが、動向が解らなくて困惑しています。
いかがですか?

Anonymous said...

2つの言語を提供するようになる?
酷いミスリード記事。決まった事は何も無いのに。

Monika said...

Thanks for provide great informatic and looking beautiful blog, really nice required information & the things i never imagined and i would request, wright more blog and blog post like that for us. Thanks you once agian

birth certificate in delhi
name add in birth certificate
birth certificate in gurgaon
birth certificate correction
birth certificate in noida
birth certificate
birth certificate in ghaziabad
birth certificate in india
birth certificate apply online
birth certificate in bengaluru

Web development training center Dhaka said...

At first thanks for this article. A very interesting blog on the other hand PHP is my favorite language.

Outsourcing Training institute In Dhaka said...

Interesting stuff to read. Keep it up.

Web Development Company In Bangladesh said...


Thanks for provide great informatic and looking beautiful blog,

Salman Nur said...

At fist i want to thanks to you for sharing this article .Online shopping Market

Muthu said...

A debt of gratitude is in order for the enlightening article. mejor abogado inmobiliario cerca de míThis is one of the best assets I have found in a long while. mejor abogado de planificación patrimonialPleasantly composed and incredible data.