Live data from Hacker News

PHP 8 to Add a JIT

blog.krakjoe.ninja

131–140 of 190 posts

Re: PHP 8 to Add a JIT

#131
post #123

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.

For majority of backend web project, in 2019, there should be nearly no technical advantage re: one language over another among all the popular ones. (i.e. the ones you listed: PHP, Ruby, Python. I would argue to use pure nodejs over Typescript though. Most people underestimate the dev flow speed it gives you to not to have a compile/transpile step. Refresh and rerun is part of what made PHP so popular years ago.) In…

> Refresh and rerun

I don't understand how this isn't easy on other platforms. This is such a huge advantage of PHP that somehow isn't easy to do elsewhere.

I am using pm2 to restart ts-node on file change to get around it but it does take a second or 2 or else I get hit with 502 Bad Gateway on browser reload which is sometimes annoying.

rails also does it automatically but this is not instant and sometimes shows me an old version, so I restart the rails instance manaually in case when I want to make sure which is a sad additional step that no PHP dev ever does.

Re: PHP 8 to Add a JIT

#132
post #126

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.

I still use PHP a lot. PHP's problems are largely user driven. What drove you away in 2004 is likely still there. The community is still full of people who have no idea. Laravel is still king. Noun driven OO is still perceived as a good idea. But on the flip side, the language has some nice features now and performance got a big boost too. Still a couple of things missing but it's getting there.

Composer is new since 2004, which is pretty great

Re: PHP 8 to Add a JIT

#133

The article says that this will help PHP in areas outside of the web. But what others areas actually want PHP? Even in its niche, the web, it has fallen out of grace for new projects.

Don't believe it. Maybe in SV it's out of grace, but it gets plenty of use.

Re: PHP 8 to Add a JIT

#134
post #126

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.

I still use PHP a lot. PHP's problems are largely user driven. What drove you away in 2004 is likely still there. The community is still full of people who have no idea. Laravel is still king. Noun driven OO is still perceived as a good idea. But on the flip side, the language has some nice features now and performance got a big boost too. Still a couple of things missing but it's getting there.

Not too serious but I want to stop using a language still forcing me to type semi colons.

CSS -> Stylus. I don't even have to type brackets and colons and not just semi colons.

JS -> JS (TS). Some people may not be aware but you can fully write JS by omitting semi colons. (Except on a few occasions* but I can write a project without one just fine and decent editor will warn you when you're supposed to have one, like IntelliJ and derivatives. Configure it to not prefer semi colons and 1 shortcut key to reformat the code and all stripped.)

PHP -> Ruby, Python, JS all don't ask you for semi colons. Array expression is also too verbose in PHP.

Java -> Kotlin.

HTML -> Pug/Slim/Etc. While there's no semi colon, the verbosity of HTML is insane, people will appreciate the simplicity of template engines like Pug and never look back.

Bash -> Bash. They didn't have one decades ago...

* https://flaviocopes.com/javascript-automatic-semicolon-inser... (some random blog explaining JS semi colons)

Re: PHP 8 to Add a JIT

#135

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.

If your team only knows PHP, it's just a small project or you only have the resource to find PHP dev replacement, just use it. Easy to use, online resource is plenty, you won't get stuck unless you want to do a lot of parallel task. Just scraping web efficiently in parallel is kind of a work to get it done in PHP.

Right now I just love having type definitions through TypeScript that you can never have in PHP. (Every variable and hash members starts to have a meaning, which means no mistyping of names, never specify non existing member or method and never use wrong method, as in you can't use numeric methods on string members which happens far too often in other languages and the return value is completely consistent. Say, you have a switch statement, and all of them returns a number but you forgot to add 'default' and TS complains that the method is not always returning a number.)

Ruby as a language is beautiful although it doesn't have the power of TypeScript, the code looks far more beautiful than PHP and if you like how rails works which pushes their rules down to your throat but if you feel it tasty, you might like it too.

Re: PHP 8 to Add a JIT

#136

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…

I agree. PHP needs 1st party support for proper threading and asynchronous programming.

This would speed up applications more than a JIT would for most.

Though I’m very pleased that this made it to PHP 8

Re: PHP 8 to Add a JIT

#137
post #129
post #118

Earlier quoted context omitted.

> key optimisations such as scalar replacement of aggregates Can u give an example or link to a relevant article. Context: my area is more of high-level program (e.g. shape) analysis

Scalar replacement of aggregates means replacing an object allocated on the heap (for example, Point p = new Point) by local variables corresponding to its fields (double x, double y) Removing the object allocation saves time and puts less pressure on the GC. Replacing the instance variables with local variables may also allow the compiler to optimize some things that it would not have attempted to optimize before. F…

Right, and in a language where you are predominantly using strings, arrays, maps, unless you can remove and optimise through these data structures you spend your whole time allocating them, collecting them, doing lookup in them and you won't have any opportunity to apply other optimisations. You need to be able to understand these data structures at the level of an IR - DynASM or LLVM aren't going to remove a call to a lookup routine for you.

Re: PHP 8 to Add a JIT

#138
post #130
post #82

Earlier quoted context omitted.

Perl 6. You think Python 3 was bad?

Have you looked at Perl 6 recently?

The issue isn't the language which is great. The issue is with the development hell sapping resources from the community

Re: PHP 8 to Add a JIT

#139
post #17

Earlier quoted context omitted.

PHP was practically "serverless" before serverless was even a thing. You just deploy your code with ftp, rsync, git, or whatever. There's no step 2.

How is syncing your PHP code with the server serverless?

You still have to deploy to Lambdas.

I believe the post you're responding to was alluding to the degree to which a lot of single-file PHP/HTML is written in a very "serverless-esque" way: no dependencies on an outer framework, and likely scales quite far compared to other languages when run on any number of servers (with the required libraries).

Re: PHP 8 to Add a JIT

#140
post #129

Earlier quoted context omitted.

Scalar replacement of aggregates means replacing an object allocated on the heap (for example, Point p = new Point) by local variables corresponding to its fields (double x, double y) Removing the object allocation saves time and puts less pressure on the GC. Replacing the instance variables with local variables may also allow the compiler to optimize some things that it would not have attempted to optimize before. F…

Right, and in a language where you are predominantly using strings, arrays, maps, unless you can remove and optimise through these data structures you spend your whole time allocating them, collecting them, doing lookup in them and you won't have any opportunity to apply other optimisations. You need to be able to understand these data structures at the level of an IR - DynASM or LLVM aren't going to remove a call to…

I understand that a JIT engine cant do this, due to speed.

But would be surprised that a LLVM compiler with a custom-designed heuristic for specific optimizations cant manage this.

These problems may be polynomial etc etc, but MOST of the code generated should follow common patterns

I will have to give this some thought.

Thanks for the reply (also GP)

Post reply on HN