Live data from Hacker News

PHP 8 to Add a JIT

blog.krakjoe.ninja

91–100 of 190 posts

Re: PHP 8 to Add a JIT

#91
Love what they've been doing on PHP lately :)

> However, this in fact opens the door on things such as machine learning, 3d rendering, 2d (gui) rendering, and data analysis, to name just a few.

Shouldn't we get decent threading built in before we consider most of those? I've hit that wall many times when processing larger amounts of data w/ php scripts. I know about the pthreads plugin but nothing beats a first class citizen like goroutines for go or similar.

Re: PHP 8 to Add a JIT

#92
post #71
post #28

Earlier quoted context omitted.

I haven't found PHP documentation to be better or worse than the documentation of other languages I've used. What I dislike about it is the comments that every page includes. Most of them are very poorly written snippets of code from 15 years ago. If you dislike those comments too, consider adding this to your ad blocker: php.net###usernotes

I've actually found many of the comments rather useful over the years, and although I'm not crazy on how old and random they often are, I find them at least worth a quick look.

I've also found that the comments sometimes have very useful notes.

There is the issue of bad advice, but recently I've noticed that there seems to have been a voting system introduced at some point (not sure how long that's been there, I was away from PHP for a good chunk of the last decade), and I think the moderation system is older, so in theory, some of the worst advice should be filtered down/out and some of the best should be filtered up.

Re: PHP 8 to Add a JIT

#93
post #72
post #45

Earlier quoted context omitted.

and now you see why "serverless" is misleading. "serverless" now means you don't run your own web server, you use someone else's.

That's not what serverless means. It means that your code isn't running on a specific server, and between requests it isn't in any kind of running state whatsoever. It's effectively in cold storage until it's needed, then it's pushed to a frontend/edge server and run. Serverless doesn't mean that there's no servers anywhere, but rather that you don't have a webserver or set of webservers that your code is on; it goes…

serverless and compute-on-edge are different things.

Re: PHP 8 to Add a JIT

#94
post #72
post #45

Earlier quoted context omitted.

and now you see why "serverless" is misleading. "serverless" now means you don't run your own web server, you use someone else's.

That's not what serverless means. It means that your code isn't running on a specific server, and between requests it isn't in any kind of running state whatsoever. It's effectively in cold storage until it's needed, then it's pushed to a frontend/edge server and run. Serverless doesn't mean that there's no servers anywhere, but rather that you don't have a webserver or set of webservers that your code is on; it goes…

Which is what the earlier poster was alluding too. PHP code is stateless and sits there not taking up any resources until it is needed.

Re: PHP 8 to Add a JIT

#95
post #62

This is the RFC with more technical details https://wiki.php.net/rfc/jit . I believe their plan is to emit low-level code directly via DynAsm, without their own intermediate representation. This kind of approach has been tried again and again and again and every project doing this either not got the results they wanted and given up or has had to go back and add a proper intermediate representation. Examples include R…

I respect that the PHP maintainers recognize that it is not enough to accept a working JIT implementation - they have to understand and maintain it. Speed is one thing, but long term maintenance is more important. > use DynAsm (developed for LuaJIT project) for generation of native code But at the very least, this exercise will ensure that DynAsm will be actively used by a few people. So even if this PHP JIT effort f…

True, however I would argue that having an IR in general makes the code easier to understand and maintain. Especially if you add more optimizations.

Re: PHP 8 to Add a JIT

#96
post #26

Earlier quoted context omitted.

Not sure if this qualifies as intermediate representation in the LLVM sense, but PHP has opcodes already, it is not fully interpreted anymore (like it was in PHP 3). These opcodes are used for optimizations and cached for the lifetime of the PHP process (across multiple requests).

That's probably too low-level. Usually an AST is needed that is void of all syntactic sugar, yet can express the required data flows and dependencies so the trivial substitutions/replacements/caching and refactorings can be done at this level. Lower level bytecode lacks these higher level references (it usually has a lot of indices that index into raw lookup tables, but no real symbols that refer to results of comput…

Not sure why you think this is the case: there are numerous JITs/VMs that optimize starting from bytecode e.g. all JVMs, WebAssembly, V8, JSC,...

Can you point me to some paper/reference about this? AFAIK it doesn't matter whether you have an AST or bytecode. Optimizations are done on an IR anyways.

Re: PHP 8 to Add a JIT

#97

Earlier quoted context omitted.

Well, you can do $moo = "hello"; $zork = "moo"; echo $$zork; // hello It doesn't get much more dynamic than that.

It can. Python, for example, builds up classes at runtime. PHP builds up classes at compile time. There are plenty of other examples. PHP is really dynamic through eval() but that's more rare. Although PHP does support the above syntax, it's actually pretty rare in production code. PHP can be optimized like JavaScript is: perform direct variable/member access but provide a slow path for these kinds of dynamic lookups…

You can't just wave away the impact of having eval though. Just the fact that it exists means you need to keep around some supporting state like variable names. You can't do full constant folding and eliminate all intermediate steps for example if there a chance a runtime-created code will reach into your frame and want them back.

Re: PHP 8 to Add a JIT

#98
post #11
post #2

There is something to be said about PHP's staying power. The early versions of the language weren't considered "right". Except maybe they were right for the problem at hand. The way I see it was PHP captured the vector of change , and left ample room for future developments. Both internal changes (hello, bytecode; hello, JIT), language level features (hi there, namespaces), and runtime level features (oh hai, countle…

Part of its staying power is also due to Wordpress. If you're looking for an off the shelf CMS you'll almost certainly be considering Wordpress, Drupal, Joomla, et al.

Similar for self hosted shopping carts. Magento, PrestaShop, OpenCart, etc. There are very few complete shopping cart platforms that aren't PHP.

Re: PHP 8 to Add a JIT

#99
post #22
post #10

Earlier quoted context omitted.

I think PHP had a couple of obvious advantages - it almost had a "first mover" advantage in that it happened to be installed alongside CGI-BIN on shared webhosts way back in the way - plus Drupal and WordPress being PHP projects. But to me, one of the most significant advantages PHP has is that its documentation is terrific . PHP.net is simple, clear about parameters and return values (as clear as PHP lets it be anyw…

Things may have changed since v7 but historically I’ve not found PHPs documentation any better than any other language. In fact I remember a few occasions where I’ve ended up going by the advice of the comments rather than the documentation itself because the documentation was either out dated or just plain wrong.

Maybe this is true, but by virtue of its popularity and ease of use, PHP has one of the largest selections of tutorials on everything, so that it’s possible to write code by just copy-pasting example snippets.

Re: PHP 8 to Add a JIT

#100
My feelings about PHP are stuck in what I remember from 2004. If I’m starting a new backend web project in 2019, should I be considering PHP over Ruby, Python, or TypeScript? Why or why not? I’m curious to hear from anyone who’s used it professionally in the last couple years.
Post reply on HN