Live data from Hacker News

PHP 8 to Add a JIT

blog.krakjoe.ninja

181–190 of 190 posts

Re: PHP 8 to Add a JIT

#181
post #57
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…

> There is something to be said about PHP's staying power. The only reason I use php for my own sites is because I don't want to administer any server and I don't want to be tied to a provider. PHP is a good fit for this, because it's available at practically all cheap hosting providers (I don't need to administer the server with shared hosting) and I'm not tied to a single provider, because I can switch to an other…

Same here, I used to wrestle with PHP, then I just accepted that the best path to make a productive use of my time was just to use it, the same way as you do.

Re: PHP 8 to Add a JIT

#182
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…

Usually an AST is needed that is void of all syntactic sugar,

That’s how I’ve always see “AST” used, but not the following:

yet can express the required data flows and dependencies so the trivial substitutions/replacements/caching and refactorings can be done at this level.

Is what you describe some flavor of ‘augmented’ AST? Does that have a name other than AST?

Re: PHP 8 to Add a JIT

#183
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…

the very first first mover advantage was that php was the free alternative to asp, jsp, and coldfusion. all of these languages were built around the simple premise that web devs wanted to inject code into html, which is the way beginners tended to think about coding. asp locked you into microsoft, jsp was laden with heavy/expensive java app servers and semantics, and coldfusion was a paid product (and eventually lock…

PHP started in 1994 and was released in 1995. It was the alernative to writing C code inside the web server (like CERN's httpd) and recompiling the server, or doing everything via CGI. (Yes, hacking servers was a thing. In 1994 I worked on a project in which I did exactly that. This was before Apache and modules.)

ASP 1.0 was released in 1996. The first Cold Fusion in 1995. JSP not until 1998.

Cold Fusion and PHP appear to be neck-and-neck, almost; it's plausible that if Cold Fusion had been free, it might have taken more mind share away from PHP.

Interpolating results into HTML dynamically isn't an idea that originated with any of this software. Prior art is the shell "here document", also implemented by imitation in Perl and other languages. "Here documents" were used in CGI scripting before PHP. (I'm not saying that the shell's "here document" is the ultimate prior art, either).

At your system prompt:

  $ cat 
  $(for x in 1 2 3; do echo "  $x" ; done)
  
  !

  
    1
    2
    3
  

Re: PHP 8 to Add a JIT

#184

Earlier quoted context omitted.

How does comments at the bottom make scrolling harder?

Not OP, but for me (as a potential example) there are websites that I want to scroll up and down on to view different things, but when you scroll down far enough websites have an annoying habit of auto-opening the comments at the bottom, suddenly tripling (or more) the length of the page, making me lose my spot on the page (potentially) and also making it harder to scroll with precision and/or need to scroll through…

Doesn't your browser scroll much faster when you swipe twice in quick succession? I mean while the scrolling is going on, you swipe again and in worst case a third time. I never need to swipe more than three times unless the page is gigantic.

Re: PHP 8 to Add a JIT

#185
post #110

Earlier quoted context omitted.

PHP hosters have been doing this for 20 years. You have 100s of customers on a single machine, running with a single Apache/PHP process (and child forks), and only if that Host+URL of a customer is requested that PHP code actually gets executed, then completely discarded from memory after its finished. PHP is very much comparable to serverless. All that talk about bootstrapping costs in serverless is something PHP de…

This is a very silly equivalence--you're just glorifying vhosts and method dispatch.

The mechanism isn't the point (and vhosts aren't really either). The point is what a developer (or ops) has to think about when deploying, and in this regard, the default PHP model has a lot in common with serverless.

Re: PHP 8 to Add a JIT

#186

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 do this in PHP:

    
or this:

    
Thus generating a class at runtime-ish.

Re: PHP 8 to Add a JIT

#187
post #184

Earlier quoted context omitted.

Not OP, but for me (as a potential example) there are websites that I want to scroll up and down on to view different things, but when you scroll down far enough websites have an annoying habit of auto-opening the comments at the bottom, suddenly tripling (or more) the length of the page, making me lose my spot on the page (potentially) and also making it harder to scroll with precision and/or need to scroll through…

Doesn't your browser scroll much faster when you swipe twice in quick succession? I mean while the scrolling is going on, you swipe again and in worst case a third time. I never need to swipe more than three times unless the page is gigantic.

>Doesn't your browser scroll much faster when you swipe twice in quick succession? I mean while the scrolling is going on, you swipe again and in worst case a third time. I never need to swipe more than three times unless the page is gigantic.

Yes, but then if I'm looking for a specific part it has scrolled way past and I need to then scroll back down, sometimes past it, and then scroll back up. Bearing in mind I have to scan the page as it flashes past too.

It's a frustrating experience.

Re: PHP 8 to Add a JIT

#188
post #177

Earlier quoted context omitted.

I think the problem with PHP is that it's a mature language that is aggressively incorporating modern features, yet still is a mess .

What are the messy bits? I know they are there but how is it a mess in your opinion? There seems to be a lot of "PHP is a mess/garabage/whatever else" hyperbole in this thread with no actual explanations why.

I for one would rather see common utilities move into proper naming and static classing with proper returns. For instance, strpos(string haystack, string needle) will return the position of needle in haystack as an int if found. If not, it returns false. To me, the proper thing in this scenario is to either return an int (even -1 is fine for not found) or throw an exception.

There's inconsistencies in typing of what is returned. There's nothing wrong with loose typing, especially in the place that PHP is used. It's just that the PHP API regularly returns not what you'd expect.

Throw into the mix that the built in simple-functions are all over the place (https://www.php.net/manual/en/ref.strings.php). Seriously, there's str_replace, strpos, and parse_str. These could easily be solved by doing something similar to C#'s naming by changing it to something like String.Replace, String.IndexOf, String.Parse.

Re: PHP 8 to Add a JIT

#189
So if JIT involves compiling into native machine code, can we expect that in the future JIT capability would help PHP devs implement compiling whole PHP project into native (like a single .exe binary for Windows)?
Post reply on HN