Slashdot Mirror


Ask Slashdot: Should I Ditch PHP?

Long-time Slashdot reader Qbertino does PHP for a living, but says he's growing "increasingly frustrated with the ignorant and clueless in the vincinity of PHP." Crappy code and baaaaad application setups is one thing, but people refusing to fix them or simply not even understanding the broader implications of bad applications or attempting SEO with gadgets while refusing to fix 3.5 MB-per-pagecall are just minor tidbits in a history of increasingly unnerving run-ins with knuckledragers in the "web agency" camp...

Will I leave the larger part of this backwards stuff behind if I move to another server-side programming language such as Java or Kotlin for professional work in the broader web area? Do I have a chance to do quality work on quality projects using PHP, or are those slim compare to other programming languages? In short, should I ditch PHP?

"I think .NET is a much cleaner language to work in with Microsoft's excellent Visual Studio IDE and debugger," argues Slashdot reader Agret , adding "there are many large projects in my city hiring .NET developers and being a strongly typed language the code quality is generally better than PHP."

But what's been your experience? And would a frustrated developer find more quality projects by ditching PHP?

3 of 341 comments (clear)

  1. I left the PHP community in 2002 by loufoque · · Score: 2, Informative

    And you should have done the same.
    It's just full of bad programmers and the only applications people build in PHP are crappy websites.

    Moved to a real programming language with a niche that values skill, and I easily multiplied my salary by 10.

  2. I've used both. by The+MAZZTer · · Score: 3, Informative

    It breaks down to PHP being much less capable than ASP.NET in its capabilities, though I admit it's been a while since I've used PHP, some of these limitations are built into the basic design of PHP so I'm not sure how they could have improved those aspects since then.

    ASP.NET and ASP.NET Core have control of pretty much the entire web server stack (to a point). So you can do things like declare REST APIs and map them to single functions, whereas it is much harder to do that in PHP because first the web server needs to map a request to your PHP script file before you even get control in the first place, so you need to use Apache mod_rewrite or whatever (as opposed to a single line of ASP.NET code embedded with your REST API function.

    I think that's really the biggest thing. PHP code starts and ends at the PHP script file and all code is run in the context of a HTTP request. There's no built-in way to do background processing outside of that, and you are writing a collection of scripts, not a full application. In ASP.NET you are writing an APPLICATION, and you get as much control over requests into your application URLs as you need. You can filter requests, add middleware, and your app doesn't even serve static files from disk unless you tell it to.

    PHP has also had growing pains, starting out with no OOP support but having such things added eventually and having their APIs eventually converted over to use OOP (I stopped using it before this point so I am not sure how good it is). Also some bad security decisions that had to be corrected have led to things like mysql_escape and mysql_real_escape functions. Meanwhile in .NET you just use SQL parameters and you're good from a security standpoint. It has been awhile so I would hope PHP has SQL parameters now. I can't speak to the current state of PHP from a security standpoint but they've had a rocky journey for sure.

    Also as a side note, .NET has EF/EF Core, which is amazing. I fell in love with it. Use any DB you want. Write classes that represent objects. And then EF/EF Core generates DB structures and queries for you; you don't have to deal with any of that. Change the object structure? DBs will be migrated to the new structure. It's pretty much magic. With PHP you're stuck picking a specific database and manually writing queries. If you want objects to represent your records (a database abstraction layer of some sort is a good idea for security reasons) you have to build all that by hand.

  3. Re: LOL! by datavirtue · · Score: 4, Informative

    Why is .Net bad? Its just incredibly complete sugar to manipulate memory and data to your will. C# is by far the best language we have at the moment for most problem domains and the .Net ecosystem is amazing...presenting the only viable solution for cross platform development at the moment. Avoiding .Net is really bad advice.

    --
    I object to power without constructive purpose. --Spock