News for hackers. Stuff that matters.
Re:Usage statistics of server-side programming languages for... by easton on Monday September 13, 2021 @08:30AM (#28510624)
I'm curious how this changes if you remove PHP being used for WordPress (where the people using it probably didn't choose it). Do lots of companies still choose PHP for brand new projects? I know Facebook has a dialect they still use, but you don't hear much about it anymore.
Re:Usage statistics of server-side programming languages for... by minimaul on Monday September 13, 2021 @08:47AM (#28510810)
Yep. My employer is a mix of PHP and JS.

PHP 8 for our API, JS for the app that consumes it - sharing code both server-side and client-side.

It works really well for us.

Development on a modern version of PHP with a framework like Symfony or Laravel is so very different to development on old PHP5 versions.

edit: PHP 7.x and 8 let you do things like:

- no automatic type conversions

- typed function parameters and return types

- typed object properties

- named parameters

All of these are little niceties but they add up to making it fantastically easier to avoid stupid mistakes that used to be common with PHP.

Re:Usage statistics of server-side programming languages for... by kreetx on Monday September 13, 2021 @10:22AM (#28511868)
I'd argue that the first three are not all that little ;)
Re:Usage statistics of server-side programming languages for... by 0x0nyandesu on Monday September 13, 2021 @08:34AM (#28510664)
PHP is my bread and butter. Yes there are still shops that use it. It doesn't really deserve the bad rap.
Re:Usage statistics of server-side programming languages for... by qsort on Monday September 13, 2021 @08:40AM (#28510735)
As a Java dev I feel you. PHP, Java are both languages that used to be god-awful, but they have evolved massively in the past decade and most of the criticism is outdated.
Re:Usage statistics of server-side programming languages for... by godojo on Monday September 13, 2021 @08:47AM (#28510805)
The bad rap was probably due to older versions. I used to program PHP in a professional setting (quite a while ago) and it basically interchangeable as any other system script (bash) executed by a parent http server process.

The language itself at the time was mostly useful because you could execute a script made of HTML (or anything really) with some embedded magic tags interpreted as PHP instead of the opposite where you had to do some sort of template engine.

Re:Usage statistics of server-side programming languages for... by acdha on Monday September 13, 2021 @09:26AM (#28511180)
Older versions were worse but the current versions still have a lot of cultural baggage around the idea that ignoring errors is great and that's it's helpful to automagically convert data types. Changing that would break a huge amount of code and habit so the community is kind of slow-walking in that direction by deprecating features, adding opt-in config, and using linters to identify likely sources of problems.

I don't disagree that it was useful — especially for having such a simple “upload a file, hit refresh” workflow — but popularity can work against you when it encourages optimizing for easy starts over long-term maintainability and a huge number of people learned dubious habits and aren't quick to switch.

Re:Usage statistics of server-side programming languages for... by WesolyKubeczek on Monday September 13, 2021 @08:41AM (#28510741)
It's bearable since version 7, and unless they make it another Java in version 8 which will make it unbearable again, it's gonna be ok.

Kids who want to seem cool have moved on to Go and NodeJS, so PHP is mainly left with people who got some experience and mostly know what they are doing, save for those who really just twiddle Wordpress until it sort of appears to do what they want it to do.

I suspect that PHP's ultimate fate is to become another Perl — a quite mature platform with very few people tending to it, obscure, with a community of very expensive veteran programmers.

Re:Usage statistics of server-side programming languages for... by deweller on Monday September 13, 2021 @08:48AM (#28510829)
PHP 8 has been out since November. It adds some typing but everything is optional. PHP has always been a loosely typed language. Converting to a strongly typed language would against the grain of the entire culture and history of PHP.

https://www.php.net/supported-versions.php https://www.php.net/releases/8.0/en.php

Re:Usage statistics of server-side programming languages for... by hparadiz on Monday September 13, 2021 @09:10AM (#28511023)
The funny part is we still use Node for various sub tasks like webpack. Soon we'll be adding a unit testing layer to the JavaScript which will run in NodeJS as well. But I might wrap it with our PHP launcher. We'll see.

The thing with PHP is it's very easy to understand in comparison with Perl. When Facebook did a study on which languages take the least amount of time to onboard new hires PHP won every time. It's also why they use their own version of PHP in house (Hack). It's 95% same thing with additional features like async built into their engine.

Re:Usage statistics of server-side programming languages for... by wongarsu on Monday September 13, 2021 @08:39AM (#28510724)
According to the Stack Overflow Developer Survey it's the 11th most used technology, between C and C++ [1]. It's no Java or NodeJS, but it's still widely used.

1: https://insights.stackoverflow.com/survey/2021#technology

Re:Usage statistics of server-side programming languages for... by chewmieser on Monday September 13, 2021 @08:40AM (#28510728)
Tons of companies still use PHP even for new projects. Likely in part due to its market saturation - it's incredibly easy to find PHP developers.

Only developers complain about PHP. And even that isn't really warranted anymore as PHP has grown leaps & bounds since most of the hate.

Re:Usage statistics of server-side programming languages for... by Darmody on Monday September 13, 2021 @09:05AM (#28510982)
It's incredibly hard to find good PHP developers.

I just inherited a PHP project that it's a nightmare. It doesn't make any sense. It works on PHP 7.3 but the quality is worse than the old PHP 4 stuff.

It is so easy to write good PHP code nowadays but most devs don't do it. They just go for the old ways, with spaghetti code, no clear architecture, etc, because it just works. They don't have to think, just type. Thats why people hate the language. They see the bad code and they think the language is poorly designed.

Re:Usage statistics of server-side programming languages for... by lowercased on Monday September 13, 2021 @09:45AM (#28511412)
> It's incredibly hard to find good PHP developers.

But... is it much easier to find good devs in any other tech stack? I don't see it, personally. My ruby friends complain it's hard to find ruby devs at all, and harder to find good ones. I do see a lot of JS/node folks that get accepted as 'good', but when the rubber hits the road, the code is often still... meh - cut corners, SO copy/paste, etc.

I see bad node and bad js and bad python... but somehow the languages and stacks get a pass and "it was just a bad developer". But if you see bad PHP, people think "the whole language sucks". Completely inconsistent.

Re:Usage statistics of server-side programming languages for... by Darmody on Monday September 13, 2021 @12:41PM (#28513606)
You don't see as much bad python code as you see bad PHP code. PHP has no entry barrier. You can just start typing and things start working.

Compare that with deploying a hello word website in python, java or elixir.

Re:Usage statistics of server-side programming languages for... by lowercased on Tuesday September 14, 2021 @10:49PM (#28534650)
I don't see much python code period, in my day to day work, but what I do see often... doesn't seem demonstrably 'better' by any metrics than run of the mill code from any other stack. But it sometimes comes with some sense of smugness about being 'pythonic'. Standard Java I don't get that sense, but do from some Kotlin advocates I know (usually the ones that are new to programming in general who feel they've found some new magic bullet that will overturn all the bad PHP out there).
Re:Usage statistics of server-side programming languages for... by hparadiz on Monday September 13, 2021 @09:12AM (#28511044)
These days if you're not using PSR4 configured auto loading with all your code in the src or tests directory and a separate public folder then you're not really qualified to work on PHP at a professional level.

I highly encourage using this template for all new projects

https://github.com/thephpleague/skeleton

Re:Usage statistics of server-side programming languages for... by Darmody on Monday September 13, 2021 @12:50PM (#28513712)
I just had my worst PHP dev experience in 5 years of coding. Literally. I just had to leave the office. I'm on my way home and still feel fatigued.

The project not only doesn't use composer (well, it does now because I needed some components) but it has the same third party components duplicated or triplicated around the application. It looks like they downloaded them Everytime they needed them. Some of them are modified to make them work on newer versions of PHP. And the views and the logic are mixed together in big 4k lines files with no functions. Html, js, PHP, tens of SQL queries on loops, all mixed together.

It's so bad it looks that it was made like this on purpose.

The funny thing is a pretty important project for a pretty important and unique customer.

Re:Usage statistics of server-side programming languages for... by tored on Monday September 13, 2021 @02:54PM (#28515250)
Classic. Absolutely fabulous when this happens.

Just want to nuke everything to oblivion.

But there is hope, sometimes it can be better to inherit badly written repetitive & copy-pasted code, rather than badly written abstractions.

Badly written abstractions can be really hard to get out of years later because it tends to be viral all over the project, however when there are no abstractions at all, you can decide them right now, you are in charge. Bit by bit you can unwind this mess to something grander, to your own creation. Good luck. Praying the PHP prayer for you.

Re:Usage statistics of server-side programming languages for... by Darmody on Monday September 13, 2021 @04:20PM (#28516328)
There's no unwinding. Boss says it should be done like this just to finish tasks quickly.

For the last couple weeks I've been thinking I should look for a new jobs as it looks there's no future here.

Re:Usage statistics of server-side programming languages for... by hparadiz on Tuesday September 14, 2021 @07:09AM (#28522934)
I've actually fixed this sort of situation at multiple different companies. Typically I end up getting buy in from management once I have started cause it saves money in the long run.

You start by setting up the standard router for all URLs when the php file doesn't exist. You then setup your router to answer somefile.php or whatever file you want. You then have that route execute your own class. You simply delete the original file and it now loads from your router. You can typically copy/paste the code from the file into a function in a class without any modifications. As you go you can get rid of includes / requires all over the place because now you've got auto loader configured so you can just call code from other files at will.

So then I just repeat this process. Sometimes it takes years but I can typically make a huge dent in most systems in the first few months.

If I don't get buy in I do it anyway for any code I'm asked to work on cause it makes the work better and there's no reason not to do it at that point.

I actually kind of envy you. I enjoy refactoring projects like that. You can typically bring that 4k line file you mentioned down to just a few classes and views.

Re:Usage statistics of server-side programming languages for... by Zelphyr on Monday September 13, 2021 @04:23PM (#28516375)
Yes, for all the warts of the language, the worst thing about PHP is the illegible code that gets written by someone who glued together a bunch of solutions they found on StackOverflow. The good news is, in my experience, most of those people have moved on to JavaScript.

Note that I enjoy both PHP and JavaScript immensely. But, my God, some of the code that I've seen in both languages...

Re:Usage statistics of server-side programming languages for... by astura on Monday September 13, 2021 @09:33AM (#28511252)
Yep, only companies that are seeking VC funds have to use "cool" technology to wow investors.

OTOH many bootstrapped or legacy companies pick long established technology to build their products as they are only selling product implementation, not the idea of changing the world or whatnot.

It might also be the client simply wants php. They don't want to pay to maintain anything extremely over-engineered.

Re:Usage statistics of server-side programming languages for... by giancarlostoro on Monday September 13, 2021 @08:37AM (#28510696)
Yeah they do, PHP has a few frameworks like Laravel (inspired by Django iirc) that can be used to work on organized web projects. The nice thing is, you know you can host it online for pennies when you're all done. One of my web hosts has a $8 a year plan for example.