News for hackers. Stuff that matters.
Re:PHP 8 to Add a JIT by sickcodebruh on Sunday March 31, 2019 @04:51PM (#19538297)
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.
Re:PHP 8 to Add a JIT by tylerjwilk00 on Sunday March 31, 2019 @09:54PM (#19539792)
PHP is faster than both Ruby [1] and Python [2] and unlike TypeScript the executed code is the same as the written code, no transpiling.

[1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

[2] https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re:PHP 8 to Add a JIT by gravypod on Monday April 01, 2019 @08:28AM (#19542577)
Like the author of the article said, most websites are I/O bound tasks. This is a CPU bound benchmark.
Re:PHP 8 to Add a JIT by igouy on Monday April 01, 2019 @12:04PM (#19544772)
Like the author of the article also said:

"To improve the ability to execute math faster in PHP seems, at a glance, to be a very narrow scope.

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."

Re:PHP 8 to Add a JIT by ognarb on Sunday March 31, 2019 @06:15PM (#19538783)
I use Symfony 4 and like it. Clear config organisation, class based controller with logic and route embedded together. Twig the templating engine is nice and doctrine is a very powerful ORM.
Re:PHP 8 to Add a JIT by godot on Sunday March 31, 2019 @06:13PM (#19538776)
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 short, use whatever you're comfortable with. If you're super proficient with PHP, keep using it. If Python is that language for you, use Python.

Re:PHP 8 to Add a JIT by reallydude on Sunday March 31, 2019 @11:18PM (#19540158)
> there should be nearly no technical advantage

In practice there is. Specifically in regard to parallelism and performance, which is important for any non-trivial application.

You can spin up multiple Python processes or just re-implement in a different language, some nuanced part of the stack that you've crafted to bottleneck(s), or you can just choose not to use it from the start. It's not like you're going to design around the deficiency at all levels.

You'll run into Ruby performance problems very early on without specific knowledge, so people just stopped using it for anything load bearing. My bias against Ruby is limited to PoC programs having memory problems and poor performance compared to virtually identical implementations in other languages, being a cultprit. YMMV.

Perl is hard for people to understand, since every feature of the language is a landmine of obfuscation...php is getting there on it's own, to be fair.

The idea that there should be no technical advantage is ignorant. There are choices that have been made and there's reasons for each. You don't run Python on stream processing with Flink because it's not suited for parallelism. Catching errors like a kafka broker disappearing, in PHP, is almost trivial like in many languages, while Java requires a custom retry method that requires intimate knowledge of how any connector works.

Knowing the languages, PHP has some very compelling strengths, as does Java (performance and safety) and Python (generally consistency of implementation and speed of development)...I still don't understand why I keep running into rats' nests of javascript and other esoterics.

Re:PHP 8 to Add a JIT by sickcodebruh on Monday April 01, 2019 @10:57AM (#19543890)
I find that the cost of TypeScript's compiler more than pays for itself with all the other benefits it offers. It's to the point that I can't imagine working in JavaScript without it and I'm less happy working in other dynamic languages when I'm forced to. Refresh and rerun is great when you're developing but offers you nothing when you come back to the code weeks or months later. A good type system has your back even after you've forgotten how everything fits together.
Re:PHP 8 to Add a JIT by h1d on Sunday March 31, 2019 @06:42PM (#19538912)
> 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 by h1d on Sunday March 31, 2019 @07:07PM (#19539038)
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 by drubenstein on Sunday March 31, 2019 @05:09PM (#19538410)
I've had a reasonably good time with Laravel (versions 5.x), although not having a lot of experience with other stacks (say, django), ymmv.

That said, I don't think it's so profoundly amazing as to be worth learning PHP if 1) you're not already somewhat exposed to it or 2) the place where you work doesn't already use a lot of PHP.

Re:PHP 8 to Add a JIT by legohead on Sunday March 31, 2019 @05:54PM (#19538672)
do you care about performance? PHP, Go, C#

you'll "figure it out later"? anything else that floats your boat

Re:PHP 8 to Add a JIT by lugg on Sunday March 31, 2019 @06:17PM (#19538790)
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.

Re:PHP 8 to Add a JIT by h1d on Sunday March 31, 2019 @06:55PM (#19538981)
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 by stephenr on Sunday March 31, 2019 @10:49PM (#19540027)
> I want to stop using a language still forcing me to type semi colons.

Fuck it, go one step further and stop using languages that expect you to use any formal syntax. Just write down "Computer do this thing! Now, good and bigly like!" and then wait for it to happen.

Of all the fucking complaints about a language "requires semicolons" is the most ridiculous thing I've heard (and no you're not the first place I've heard it, but it's still as ridiculous now as it was the first time I heard it).

> Ruby, Python, JS all don't ask you for semi colons.

Except, JS does require semicolons, it just happens to be able to insert them for you in some situations.

> Array expression is also too verbose in PHP

Array syntax in PHP is the same as in JS: `['foo', 'bar', 'bar'];`. Oh that nasty semicolon is the "verbose" part I bet?

Re:PHP 8 to Add a JIT by h1d on Sunday March 31, 2019 @10:52PM (#19540034)
> Array expression

I meant as in

$hash['member']

vs

hash.member

Re:PHP 8 to Add a JIT by stephenr on Sunday March 31, 2019 @11:00PM (#19540074)
Well that isn't even an Array in Javascript, so already I'm beyond caring what you mean.
Re:PHP 8 to Add a JIT by halfnibble on Monday April 01, 2019 @04:40AM (#19541538)
I understood that "array expression" meant "associative array", and that the closest equivalent in JavaScript is an Object. But I don't consider myself a PHP guru.
Re:PHP 8 to Add a JIT by lugg on Sunday March 31, 2019 @08:58PM (#19539547)
I'm a big fan of standardjs. Beats prettier and the rest. Takes more of a go fmt approach.

While debating myself on whether to learn rust or go next I fell into clojure. I'll probably pick go up next and then rust.

Re:PHP 8 to Add a JIT by kibibu on Sunday March 31, 2019 @06:47PM (#19538934)
Composer is new since 2004, which is pretty great