News for hackers. Stuff that matters.
Re:PHP 8.1.0 by the_gipsy on Thursday November 25, 2021 @05:15PM (#29345469)
With a proper type system you don’t need to run your code 50 times a minute.
Re:PHP 8.1.0 by chubot on Thursday November 25, 2021 @05:57PM (#29345808)
Code that passes type checks can also fail to solve the user's problem, make 10,000 database calls, or render a page that is completely unreadable.

The human in the loop is a good thing. All things being equal, the type system is also a good thing, but what usually happens is that you end up checking your page once a minute or once every 10 minutes, not 50 times in a minute. That difference can make or break a project.

Re:PHP 8.1.0 by lolinder on Thursday November 25, 2021 @06:45PM (#29346138)
It depends a lot on what you're working on. If you are building a front end with PHP as your templating language, then yes, the ability to instantly see your changes is huge. In my experience, when working on back end, the difference isn't that significant because you really want to be using unit tests anyway, not constantly interacting with the front end to test your work. In those back end cases, having a strong type system makes a huge difference.

I'm working on a project that has a legacy PHP code base and a new JVM code base. What kind of naturally happened is that we end up doing most of our front end work in PHP and all of our new backend work on the JVM.

Re:PHP 8.1.0 by noduerme on Thursday November 25, 2021 @11:38PM (#29347529)
I've rewritten a ton of legacy PHP services / page generation code into NodeJS over the last couple years. I know PHP inside-out and love it the way you love... um, something fugly like an old futon. It's really nice to be working in Typescript on both ends now, to have share modules and data models between server and client codebases. But one thing I do miss about PHP is not needing to make sure the server restarts on every backend code change. Nodemon and PM2 are both pretty good about this, but it's that one out of ten times they don't restart and I spend a minute or two wondering what I missed before realizing they didn't restart; happens a few times a week and drives me up the wall.
Re:PHP 8.1.0 by chubot on Friday November 26, 2021 @04:37PM (#29354387)
Yeah I definitely agree that it's domain specific, and I was really talking about front ends (hence "checking your page").

User interfaces, data science, and security/reverse engineering work are three domains that really require tight feedback loops. The work I did on parsing shell [1] is basically a kind of blackbox reverse engineering, and was done with < 100 ms feedback loops.

[1] https://www.oilshell.org/blog/tags.html?tag=parsing-shell#pa...

Re:PHP 8.1.0 by the_gipsy on Friday November 26, 2021 @07:16AM (#29349576)
And for those cases you should use tests, not a manual procedure.

Of course you will need some manual procedure, and e2e tests, but not “50 times a minute”. That is just frustrating.

Re:PHP 8.1.0 by path411 on Thursday November 25, 2021 @08:57PM (#29346861)
Well php has strong typing built in now and they have been iterating on it every release. It's well ahead of native js. I can't imagine having any real complaints on using 8.x php for a back end these days.
Re:PHP 8.1.0 by bardan on Friday November 26, 2021 @12:17AM (#29347660)
I still dislike the constant $ and ->, today it just feels like extra typing. Otherwise I agree with you.
Re:PHP 8.1.0 by thinkindie on Friday November 26, 2021 @04:00AM (#29348531)
I'm with you. This is the only complaint I have about the language itself.
Re:PHP 8.1.0 by jv22222 on Friday November 26, 2021 @04:40PM (#29354420)
Trying to imagine php without $ and all I can think is... :o
Re:PHP 8.1.0 by smsm42 on Thursday November 25, 2021 @08:52PM (#29346845)
I never seen any practical proof of that often repeated claim. Unless you define "proper" in an absurd way that has absence of bugs as the part of its definition, I've seen roughly as many bugs and as much time spent debugging in strongly typed languages as I have in weakly typed ones. Sure, some kinds of bugs go away, but they're replaced with different ones.
Re:PHP 8.1.0 by the_gipsy on Friday November 26, 2021 @07:20AM (#29349603)
Just try it out.

I am not saying that a type system will find all bugs. It will stop you from running incorrect code “50 times a minute”. Then you should have tests. Lastly you must also do some manual procedure (or run slower e2e tests).

Doing all this yourself constantly is just frustrating.

Re:PHP 8.1.0 by smsm42 on Friday November 26, 2021 @09:13PM (#29356598)
I did. I've been doing it for over 3 decades, and worked with all kinds of languages. Of course, it's only my own anecdotal data set, but no, "once you try strongly typed language you'll see how magnificent it is" doesn't work anymore. I tried, and it's not that it's bad - it has its advantages - but it's not the bugless paradise that fanboys promise. And also I learned that running incorrect code 50 times a minute is not bad at all - actually, it's a pretty good rapid prototyping technique. Some people never launch their code until they are sure it's 100% perfect, I am not one of those people.
Re:PHP 8.1.0 by Implicated on Thursday November 25, 2021 @05:24PM (#29345543)
As someone who isn't perfect, it's nice to be able to quickly iterate on ideas.
Re:PHP 8.1.0 by rbanffy on Thursday November 25, 2021 @05:26PM (#29345556)
You still can. It’ll just stop you before you get to a running web application that may be doing something wrong with the data that goes through it.
Re:PHP 8.1.0 by smt88 on Thursday November 25, 2021 @05:32PM (#29345600)
Iterating on ideas is much quicker when the compiler tells you when you made a mistake or failed to change your code after changing your mind.
Re:PHP 8.1.0 by thevagrant on Thursday November 25, 2021 @06:12PM (#29345906)
Honestly, I don't see much difference. You learn either way. People may have preferences, that's fine. A compiler isn't a magical tool that creates bug free code.
Re:PHP 8.1.0 by smt88 on Friday November 26, 2021 @09:18AM (#29350361)
A compiler with a good type system catches a mistake instantly instead of at runtime.

The difference in time it saves the dev can be anywhere from a few seconds to minutes per mistake.

Multiplied by hundreds of mistakes, it makes a huge difference. And that's not even getting into the advantages of better autocomplete for external libraries.

As someone who has written many thousands of lines of PHP, JS, TS, C#, Java, and Python, I now find it baffling that someone would start a project in 2021 without a great type system as a safety net.

Re:PHP 8.1.0 by root_axis on Thursday November 25, 2021 @07:13PM (#29346304)
The difference is massive. Computers are many orders of magnitude better at this kind of thing than humans, especially in a large application where changing the shape of a single data structure can have cascading effects throughout the entire code base; you simply will not catch things a typechecker will.
Re:PHP 8.1.0 by thevagrant on Friday November 26, 2021 @03:45AM (#29348449)
An IDE does provide some help. Certainly, I'm not arguing against compilers. I was merely commenting on the "iterating on ideas is much quicker".
Re:PHP 8.1.0 by djbusby on Thursday November 25, 2021 @05:37PM (#29345638)
Hello me! Nice to meet me!
Re:PHP 8.1.0 by jhgb on Friday November 26, 2021 @11:40PM (#29357484)
Show me a practical type system that rejects all programs with logical bugs.