r/PHP 5d ago

TypePHP is out

https://youtu.be/7vLvtM2conY?si=L_WN-prEVbPGSNhT
0 Upvotes

12 comments sorted by

17

u/Glittering_Bath3848 5d ago

PHP just changed forever

Great, Now lets abandon native PHP execution model and start writing code that looks PHP but actually just transpired itself to C++. It also forbid you from running top level code which incompatible to 100 percent of real world PHP projects out there. This is just another overhyped project that will eventually fade into obscurity.

6

u/allen_jb 5d ago

This is about Swoole's AOT compiler: https://github.com/swoole/typephp

(There's currently (at least) 2 active TypePHP projects around - I know naming things is hard, but really?)

5

u/Glittering_Bath3848 5d ago

FYI the other active TypePHP project: https://github.com/typephp-php/typephp

Which deserves the project name even more.

3

u/rydan 5d ago

Back in the day there was a thing called Hack. I used it because compiled code was faster and more memory efficient and the thing I was running was like thousands of threads per minute. But the problem is it wasn't exactly 100% correct. There were like subtle differences in the compiled binary vs native code. And some things didn't work at all. And then eventually PHP would add something but Hack had forked PHP and never added it or took forever to add it. So now my codebase was stuck behind this older version of PHP. I think Facebook eventually abandoned the project.

1

u/obstreperous_troll 4d ago edited 4d ago

Facebook still uses quite a bit of Hack, and has not abandoned it. Another prominent thing primarily using Hack would be Slack (rhymes nicely, doesn't it?). PHP did catch up to Hack's performance around 7.4, but Hack also added features like generics that are still lacking in PHP.

Hack is not AOT-compiled though, it runs on its own bytecode VM called HHVM. I think static compilation was an early goal, but was abandoned just as early.

6

u/onekorama 5d ago

If you want a compiled language... why not use one then?

2

u/Tomas_Votruba 5d ago

The naming is terrible. I thought it has something to do with types, but it seems it's PHP to C++ compiler, right?

2

u/rycegh 5d ago edited 4d ago

Come to think about it, it's backwards in a sense when we take TypeScript as the inspiration for the name.

TypeScript: TypeScript->JavaScript

TypePHP: PHP->C++

(↑ Edit: To clarify: That’s what the Swoole compiler does. Not what something called TypePHP would be expected to do. PHP should be the target, not the source. Thus why one might say it’s backwards.)

2

u/Tomas_Votruba 4d ago

TypeScript is better typed JavaScript

TypePHP should be int[], array<int, Type> etc.

2

u/rycegh 4d ago

…that compiles to PHP not from PHP to something else.

In the spirit of the TypeScript name, this Swoole compiler would be called… PHPFlavouredC++ or something like that. Maybe PHP++?

Let’s name it PHP 6 and call it a day.

5

u/MateusAzevedo 5d ago

Sorry, but I couldn't pass the 20s mark. I guess I'm to old for this type of video.

2

u/Ethan-Bris 3d ago

I think some of my brain cells died watching even a few seconds of this video. OMG!