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?

41 of 341 comments (clear)

  1. Naturlich by Anne+Thwacks · · Score: 2
    If you think .NET is better, then the answer is "yes".

    However, it must depend to some extent on what your constraints are. If you support 32 PHP websites that are online and working (and not running on Intel architecture), migration might be a rather expensive waste of time.

    Have you considered becoming a PHB?

    --
    Sent from my ASR33 using ASCII
    1. Re:Naturlich by imidan · · Score: 4, Insightful

      I worked in a place where the whole codebase was PHP, partially as a result of the web site being done in Drupal. I'm aware of many problems with PHP, but my approach there was to continue to develop with it because of the existing codebase and institutional expertise.

      A new guy came in who was big on Python, and immediately started implementing server-side Python stuff. I warned that there may be difficulty integrating the Python and PHP services, but the new guy thought I was just an old who wanted to keep doing the old and busted thing because it's all I knew.

      The boss didn't nip it in the bud early enough, and I wound up having to write code to share session information between the PHP and Python services. It was a kludge, but it worked. It would have been seamless if we'd kept working within the same language we'd started in, or if we'd undertaken to port the existing code to Python. Oh, and then the new guy quit and left us with this two-language system that few of the other employees could easily maintain.

      Point is, I agree that there's more to consider than what is the "better" programming language.

    2. Re:Naturlich by Anonymous Coward · · Score: 2, Insightful

      [...] I wound up having to write code to share session information between the PHP and Python services. It was a kludge, but it worked. It would have been seamless if we'd kept working within the same language we'd started in, or if we'd undertaken to port the existing code to Python.

      The correct way is to make it an interface usable from any language. Then it matters not a whit what language you work in. If you do that enough, you can pretty easily migrate from one language to another, one interface at a time, and it simply won't matter to the rest of the code.

      This in a way is the same lesson as "GOTOs considered harmful", "structured programming", "object-oriented programming", and so on, and so forth. Programming is about abstraction. Interfaces are the abstraction you need here. Witness the generally low level of abstraction in PHP. (Consider java, cf. "the kingdom of nouns", for an entirely different, but equally useless, level of applied abstraction.)

      Oh, and then the new guy quit and left us with this two-language system that few of the other employees could easily maintain.

      Meaning that either you now have to hire more python people or port the whole mess back to PHP. But quite apart from language favoritism, yes that's a pretty rude thing to do, leaving behind a mess for people unqualified to deal with it. It also means the guy is an arrogant hack and unsuitable for teamwork.

      Point is, I agree that there's more to consider than what is the "better" programming language.

      Sure. Though it in turn depends on what the question is. If it's about maintenance of an installed base, well, separating the parts and adding architecture is the way to go. You buy freedom to move to a better language that way. Freedom that you sorely need because most web-anything is done by monkeys (hence popularity of PHP) and sticking with the poo-flinging crowd guarantees you won't stay clean.

      If it's about personal dislike having to dwell in an ecosystem full of stupidity, then learning a nicer-to-work-in-for-you language and probably eventually finding another job is the way to go.

      IMO both the language and the ecosystem surrounding PHP is indeed full of stupidity. Moving from there to somethingsomethinghashdotnet, however, is but a very small step upwards, and mostly sideways into the wonderful world of corporatism. I like to think it says something about the person who chooses then sticks with his choice of language.

      (Says I, who routinely scripts in C and writes applications in shell.)

    3. Re: Naturlich by drinkypoo · · Score: 2

      They probably run the 'a.out' interpreter.

      a.out is an obsolete binary format, not an interpreter. There are C interpreters (e.g. picoc) but a.out is not among them.

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
  2. Languages don't write code, people write code. by MrAnnoyanceToYou · · Score: 5, Insightful

    Don't blame tools for the things that people do with them. You'll find the same problems wherever you go.

    1. Re:Languages don't write code, people write code. by MrAnnoyanceToYou · · Score: 3, Interesting

      I actually enjoyed writing Assembly more than C# and Java. My version of hell involves some idiot making me write factory classes to do basic RegEx comparisons.

  3. Bad developers is universal by corychristison · · Score: 4, Insightful

    Doesn't matter what language you use, bad developers are universal.

    The thing is PHP 7.2 is actually pretty good, and 7.3 is looming.

    My advice is start your own projects "the right way" (that's subjective), and start your own firm or agency and win with quality.

    I'll be 100% honest, this is what I did. Working self employed over 4 years now. Business is doing well. Even have a couple of staff now.

    1. Re:Bad developers is universal by corychristison · · Score: 2

      Never claimed to be an expert, and my statements were language agnostic.

      My point was if he's tired of working with other people's code he should write his own, and use that. If that means moving to a new language and using that, so be it.

      I've made a living writing custom software, and while I use PHP where it's appropriate, it's not the only language on my tool belt.

    2. Re: Bad developers is universal by c6gunner · · Score: 2

      He uses Ruby on Rails, obviously.

    3. Re:Bad developers is universal by BronsCon · · Score: 2

      It's the right tool if you're hired to work on an application already using it. The only exception to that rule is, of course, if you're hired to rewrite it in something else.

      --
      APK quotes people (including myself) without context and should not be trusted. Just thought you should know.
  4. Maintenance and reliability by what+about · · Score: 3, Insightful

    There are a ton of languages that makes it easy to "start" something, they lack
    - strong typing
    - strong debugging support
    - reliable libraries
    - reliable refactoring
    - capability of scaling to large and distributed projects
    A beginner starts using the language and ... it is trapped into it, sunk cost

    New languages are just reinventing the wheel, really, they are the result of people forgetting history.
    The main difference is that a few keystrokes are saved with a resulting code that is impossible to understnd a week after you heve written it.

    A pity that Microsoft bashing of Java (to then make Java clone c#) result in knee jerk reactions on the name.

    1. Re:Maintenance and reliability by DamonHD · · Score: 4, Insightful

      As someone who used the early JVMs i production, Microsoft's was NOT better. It was a JVM that would crash randomly, that could not interface with OLE even though Sun bent over backwards to make it possible, and like many Microsoft code bases at the time had very poor docs and failed to follow even them. That was easily the nastiest buggiest JVM impl that I ever touched.

      At least, this is what my flashback tells me, now that you set it off! %-P

      Rgds

      Damon

      --
      http://m.earth.org.uk/
    2. Re:Maintenance and reliability by Hognoxious · · Score: 2

      You could equally interpret those events as Sun heading Microsoft off at the pass before the fucking bastards reached the "extinguish" stage.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    3. Re:Maintenance and reliability by drinkypoo · · Score: 2, Interesting

      Microsoft bashing of Java? Are you sure you know the history there? For a long time, Microsoft shipped the best JVM on Windows, better than Suns

      Fastest != best

      Microsoft's JVM was an incomplete implementation, created for the purpose of deceiving customers, and was used as evidence in the US v. Microsoft antitrust case in which Microsoft was found to be guilty of abusing their position in the marketplace (before being effectively pardoned by Dubya's dog Ashcroft.) This effectively makes it the worst JVM of its day.

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
  5. Yes by Njovich · · Score: 2

    If you are so frustrated with PHP you should switch, perhaps another language will fit you better, or at least it will be a good experience. Keep in mind that PHP doesn't have a monopoly on bad code, bad configuration or bad performance.After you switch to a different environment such as a corporate .net environment you may find you get different types of problems that you you may not even have realized existed when you used PHP. Either way, still good experience.

  6. People use PHP because... by maroberts · · Score: 3, Insightful

    ..it's easy to get stuff done in PHP. There are certainly languages which are 'better' in various respects than PHP, but it is not going to replace the fact that if you want a website done quickly then PHP is your tool of choice.

    Also, it's cheaper to find PHP employees. That doesn't necessarily mean that you find great coders, but looking on the job boards, the level of salaries offered to PHP developers can be half to a third of salaries offered to developers experienced in (say) Node.js/ React. Not only that there a PHP developers on every street corner.

    At the moment I'm amazingly doing PHP at what I call 'financial developer' rates. But these jobs are hard to come by

    --

    Donte Alistair Anderson Roberts - hi son!
    Karma: Chameleon

  7. Re:Switch fields entirely by Tough+Love · · Score: 3, Insightful

    If you can't find decent people to work with in PHP, then you're probably not good enough yourself. No matter what language you'll switch to, you'll find yourself down in the dregs.

    The thing is, with PHP it's the blind leading the blind. Nobody has a clue, and starts with Rasmus (by his own admission). No skilled programmer would put up with PHP for any significant amount of time, life is too short for that aggravation. The corollary is, PHP crap never gets fixed because nobody with the skill is willing to go sewer diving to the extent that would be necessary.

    --
    When all you have is a hammer, every problem starts to look like a thumb.
  8. Actually You CAN'T by Delifisek · · Score: 5, Insightful

    If you came from PHP without any other language experience (except javascript). You cannot understand how PHP exclusively fit for Web development until you start do something with other language.

    Other languages need for spesific frameworks, configurations, concepts for web projects. PHP was ready to run. When you try to learning other languages web stack you will be frustrated and return to PHP again. Other languages need extra steps to do simple things in web because of their nature.

    Sure php much worse syntax and function names most other languages. However that was language quirks any professional can handle.

    Problem is, php entry level is low and with abundant documents and training videos people easily put something on web and so they think they can handle big projects.

    And without strict guidelines for project management, php can be lethal as a dodge viper on rainy day.

    What you need is, find a battle hardened Project manager which uses Jira and other tools to agile development plus getting know automated testing.

    After 6 months You will be fine with php any given sunday.

    If you insist to change, you should look Google GO. not .NET it was for windows shops for who develop desktop applications. It wasn't just a language, you have to change your development style, development environment working environment etc.

    Google GO was logical next step, It was easy (to comparing other static languages) and it was forced writing disciplined code practices by nature. It fast and you do not need change entire environment. Plus you get military grade arsenal (comparing to php) for complicated projects.

    My 2 cents after 20 years of PHP Web development.

    --
    [My english is better than most other people's Turkish, so please point out mistakes politely. Thank you.]
  9. Paid by Microsoft? by aleck7 · · Score: 2

    I guess itâ(TM)s a âoetestâ by Microsoft to see reaction of masses. Surely PHP is PoS, but itâ(TM)s an Open Source PoS. Going to a vendor-locked ecosystem is shooting yourself in a foot. So: 1) Ditch? Well, just keep learning. There are proper languages around you know. 2) Submit to MS? Why? Learn C# if you must, but donâ(TM)t limit yourself. I still think itâ(TM)s MS-trolling.

  10. Re:.NET? by Joce640k · · Score: 2

    PHP is the worst language ever.

    Apart from all the alternatives.

    --
    No sig today...
  11. 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.

  12. PHP Async sucks by cheesyweasel · · Score: 2

    I've been coding PHP, Java and more recently JS for a while. I feel like PHP has dropped the ball when it comes to async programming compared to the others. I think that's one of the reasons why facebook forked PHP (hacklang.org) to make it async friendly. ReactPHP is slow compared to node, and the fastest PHP async framework, Swoole by Tencent, is still limited in what it supports. I've been trying vert.x on Java which isn't bad and not minding koa. I feel like they need to do more to support projects like ReactPHP with native extensions like Swoole.

  13. Re:.NET? by jellomizer · · Score: 4, Interesting

    PHP has a lot of problems, but what they poster reported isn't near the top of them.
    the 3.5 Meg with Gadgets isn't PHP it is Google. Also for a lot of other page size issues, the biggest problem is less with the language but with added Javascript Add ins such as Jquery or Angular.js this moves your few kilobyte page to megs very quickly.

    In .NET I had aspx pages that seem to place a meg of session data onto the page, which I normally disable because I don't program websites with point and click, and I would rather have more more control when the screen refreshes or just does an AJAX cal and DOM the results back in.

    I have been doing Web Application Development (I don't do web sites) from the beginning I know what is happening in general on all sides of computers the clients and the servers.
    A particular web language sometime can help sometimes make particular tasks which are annoying much easier. But they cant stop you from making a crap Web Application, and they all have a feature where people may misuse or abuse to create utter garbage.

    The posters experience probably has PHP Developers fresh out of college bight eyed and ambitious, looking to change the world with Open Source Technology however lacking the experience to know how to debug (I still have to show recent college grads on how to use the programming debugger, and they are always worried because for some reason that it isn't pure enough for them, or cheating.. For those college professors out there why arn't you showing these kids normal debugging software that has been around for generations!) and also they are often happy when it works, they don't know when to go back to make it better, or they also don't know when to call it good enough and continue on.

    The posters experience with .NET developers are probably with professions who have been doing it for a few years, they have families and their goals to change the world isn't going to be their unique take on how to format that textbox. They have more years experience and learned from their younger years. They know when to dig and optimize, and when good enough is good enough. They uses the tools in .NET (Or in PHP or whatever freaking language they are either told to use or what is best suited for the project) more carefully and more often. They know each tool is a double edge sward while making one job quicker and easier it may have a side effect that you need to mitigate, work around, or decide that it isn't worth it. Now I normally don't code sites with point and click programming, because it really bloats up the Application, that doesn't mean I never do it. Sometimes that method would save weeks off my development cycle. And bloat isn't a big issue for the project.

    Experience is more important then the language.

    --
    If something is so important that you feel the need to post it on the internet... It probably isn't that important.
  14. Not Language but environment... by NoBody.de · · Score: 2

    I don't think the problem isn't PHP or not,
    but "Web Sites"...

    If you make websites you deal with people who wants websites,
    And everybody knows how websites are done, right?
    This attitude drives away any "good" developers.

    So you're stuck with the one you can't or won't or just don't care...
    Not all developers in this area , but the majority.

    If you want to write good software you need project and customers who understand what "good" means.
    The language is secondary,

    Your challenge is finding these "good" projects.

    PS:
    (and perhaps saying "i dont do php" shows the right attitude... just saying...)

  15. Judge not lest ye be judged, you utter cunt by Hognoxious · · Score: 4, Insightful

    that's a pretty rude thing to do, leaving behind a mess for people unqualified to deal with it.

    It's also pretty rude to fire an entire team and replace them with offshore monkeys, but it happens all the time. This is just the reflection of that - his obligation ends at the last paycheck.

    It also means the guy is an arrogant hack and unsuitable for teamwork.

    I can't comment on the specifics from a technical POV because I don't know the details - and neither do you. As for the personal attack, he might have got cancer and decided to use his remaining time travelling for all we know. Even if he was just jumping ship for a better offer, why is that wrong?

    --
    Confucius say, "Find worm in apple - bad. Find half a worm - worse."
  16. You got a point there. by Qbertino · · Score: 2

    This is actually one of the things I was thinking / considering.
    Not sure yet if I'll go that path, but your feedback resonates.
    Thanks for your thoughts!

    --
    We suffer more in our imagination than in reality. - Seneca
  17. Comparing language to library by bad-badtz-maru · · Score: 2

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

    I wonder what Agret's thoughts on C# are?

  18. LOL! by Qbertino · · Score: 4, Insightful

    Ok, I will not rag on .Net just now, but I'm definitely not moving to .Net should I leave PHP behind. So you have a point there.

    --
    We suffer more in our imagination than in reality. - Seneca
    1. 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
    2. Re:LOL! by LesFerg · · Score: 3, Funny

      And also, lets not forget that C# was responsible for stopping a whole lot of developers from using Visual Basic. I mean, how could you complain about that?

      --
      If I had a DeLorean... I would probably only drive it from time to time.
  19. Re:question already is its own answer by Bongo · · Score: 2

    It sounds like the problem you’re highlighting is HOW people are introduced to programming, in early PHP examples, rather that what a language’s expression space permits theoretically.

    It’s like learning to draw. If the first exercises are, draw an imaginary forest, people don’t learn to look. If the first exercise is, draw a portrait, it forces you to change your thinking right from the outset, because it will not work unless you focus on learning how to observe shapes.

    Mixing PHP into HTML is satanic. ;-) And anyone who is taught to start that way, is a lost soul. So maybe there is a book out there called Architecting Functional PHP Patterns... ?
    Or maybe not?

  20. PHP's Value Propositions Remain Unchallenged by Slicker · · Score: 3, Interesting

    Yes, a great deal of PHP code in the wild seems unruly. However, this is not due to PHP per-se. Choosing a solid framework (such as codeigniter or cakePHP), following its conventions, and practicing good team dynamics makes all the difference. I have been coding since 1984 in a variety of languages and, although PHP's verbosity annoys me (requires too much finger twisting on the keyboard), I have never seen a more generally productive language. You can easily build a lot, fast. The discipline to make maintainable code is worth the effort that you need anyway, even if coding in Python.

    Here are the reasons code becomes unruly:
    (1) undisciplined and/or weakly experienced coders
    (2) not clear design pattern (usually goes with #1)
    (3) well experienced coder's tendency to over-engineer

    The worst of these is #3 and it's very common amongst head-strong developers who are knowledgeable.

  21. Re:.NET? by davide+marney · · Score: 4, Interesting

    But [web programming languages] can't stop you from making a crap Web Application, and they all have a feature where people may misuse or abuse to create utter garbage.

    There is a higher-order thread running through this argument that has to do with good programming practices regardless of language. Modular code and UI components are Good Ideas, for example. Containers are a Good Idea. Git is a Very Good Idea. Typing is a Good Idea if you generate code. Templating is a Good Idea. Observer Pattern is a Good Idea. Eventing is a Good Idea.

    What I do is listen to our industry, study their good ideas, and incorporate them in my next project, fitting them to the language and framework the customer is using. Language is primarily a *business* decision, it has to do with what kinds of IT resources the company is willing to commit to.

    That shouldn't stop good development. As John Lennon famously said, "I'm an artist. Give me a tuba and I can get you something out of it."

    Now go code. Make beautiful, good code with whatever tools they give you. Be the artist.

    --
    "We receive as friendly that which agrees with, we resist with dislike that which opposes us" - Faraday
  22. It's not the language, it's the user base by Opportunist · · Score: 4, Insightful

    Moving to .net won't make you any happier, because strong typing does not make a better code base. Better programmers make better code base. And neither PHP nor .net require you in any way to be a good programmer. Both come with sufficiently plentiful training wheels that both of them attract people who have no idea what they're doing and rely mostly on cargo cult programming.

    But this is how programming is these days. Yes, you still have a few good (and very expensive) people who know what they're doing and who actually understand the implications of using this function (or API call) instead of that one, but for every programmer who does know that, you have at least a dozen who copy/paste most of their code from various online sources after googling the problem du jour. This is an universal problem and not one you can solve by switching the programming language.

    If you want to solve that problem, you have to switch the user base.

    --
    We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
  23. Stability Matters by coop247 · · Score: 2

    I was strictly a .NET programmer from, jeez, 1.0 up to almost v3. Loved the IDE, code base felt "bigger" than it needed to be for projects. My main issue was that the application on the server just dies a lot. And this wasnt just 1 app, at one company, my experience across multiple companies, multiple setups, it just seemed the the application would crash for no reason and need completely restarted pretty regularly.

    Been on PHP/LAMP for several years now and that bastard never so much as went down once. .NET/IIS might be better now, but that was my experience.

    --
    //TODO: Insert catchy phrase
  24. Depends on your age. by Rufty · · Score: 4, Insightful

    New coders look at crap PHP and think "I can do that!"
    Experienced coders look at crap PHP and think "That's crap PHP."
    Old coders look at crap PHP and think "Job security."

    --
    Red to red, black to black. Switch it on, but stand well back.
  25. PHP is a bad language for long lived code by damaki · · Score: 2

    As a developer who did 6 years of Java, 4 years of C# and 5 years of PHP for a living, PHP is not a good language for long term maintainability in a team. So, if you are alone on the project, you know perfectly your way around the language quirks, know how to use composer properly and have no need for scalability, then PHP is probably good enough for you. In any other case, do not use PHP.
    PHP is a bad language for teams with various levels of knowledge of the language, who do not pair-program or when scalability (connection pooling issues mostly, and not only DB connections) matters, of if you want to use microservices inside of a PHP script (there is a circle in PHP hell for that).
    In a nutshell, PHP is a bad language to have legacy code in, and not easily scalable. It is quirky, though not unmanageably quirky with the right tools, but once you ignore warnings, do not use proper code quality tools (sonarqube and such), you are definitely fucked with PHP. And these days, I am maintaining several of those nightmare no-framework, reinvent-the-wheel, warnings everywhere and no composer and custom classloading PHP application.

    By the way, beware of C# in a team. C# is a huge and complex language. Just like C++, you must agree on a subset of a language, for consistency sake. Once you got your subset, you are good to go.

    --
    Stupidity is the root of all evil.
  26. Re:question already is its own answer by tepples · · Score: 2

    There's little to no difference between python and php that isn't purely syntactical.

    And there are places where syntax makes all the difference, such as list comprehensions (and the generator expressions that power them).

    all the criticisms against php are equally valid against python.

    I've found a few, which I'll quote here for convenience:

    • Number-like comparison of strings can never be fully turned off. For example, both '10' <= '1e1' and '10' >= '1e1'. One can use strcmp in one's own code and pass sort_flags to sorting functions that support them, but some functions still use the built-in operators < and > that don't even impose a total order. Likewise, switch uses the built-in == comparison operator whose semantics are byzantine.
    • Parse errors and undefined function errors are fatal in PHP 5. (Or do CentOS and RHEL have PHP 7 packages yet?)
    • Inconsistent conventions for function naming and argument order in the standard library.
    • Associativity for the ternary ?: operator is the less useful side.
    • PHP allows the server operator to change program semantics in ways that are annoying to work around, especially for shared hosting subscribers without access to the server-wide configuration. At various times, these have included "magic quotes" that spray backslashes all over the request variables, not following HTTP redirects in the CURL library,[1] and restricting the size of files uploaded by a site's users to outdated limits such as 2 megabytes by default.
    • PHP versions change the semantics of existing programs in ways that encourage shared hosting providers to continue to offer only outdated versions of PHP, making it impossible for web application developers to take advantage of new features. Compare Python, which puts added functions in one namespace per module and conditions new incompatible syntax features on presence of from __future__ statements.
    • The developers of PHP rejected keyword arguments.

    [1] From March 2005 through September 2013, cURL could not follow redirects with open_basedir enabled because of a heavy-handed security fix.

  27. Re:Switch fields entirely by MightyMartian · · Score: 3, Interesting

    I once got hired to fix a PHP-based website that had been done by a couple of fly by nighters. It was a fucking nightmare. Because they were lazy and/or stupid, they had enabled every bad directive from the bad old days. They didn't even use functions, it looked more like BASIC spaghetti code. In the end I refused to do any more work until the contract was rewritten so that I was billing out time. At the end of the day I essentially threw out what these idiots had written and rewrote the whole thing from the ground up. But I vowed after that that I would never take on a job where I had to fix someone else's spaghetti code. Hire me to rewrite, that's fine, but not to repair.

    --
    The world's burning. Moped Jesus spotted on I50. Details at 11.
  28. 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.

  29. Re:Switch fields entirely by dinfinity · · Score: 2

    The thing is, with PHP it's the blind leading the blind. Nobody has a clue, and starts with Rasmus (by his own admission). No skilled programmer would put up with PHP for any significant amount of time, life is too short for that aggravation.

    That is absolute nonsense. Take a look at the Symfony framework. This is a well thought out, well structured, well documented, properly supported, actively developed, stable framework aimed at longevity and used with success in many, many commercial products.
    There are also tons of well structured PHP SDKs which are great to use.

    With regard to the language, it has made significant progress as compared to for instance Python. Developing in PHP 7.0 or higher in an OOP fashion, creating nice clean, testable and robust code is easy and painless. Doing that in Python is dreadful with the Python2 / Python3 split, combined with an opaque code inclusion scheme and Frankenstein OOP implementation.

    PHP used to be dreadful as well and a framework such as Wordpress reflects that. It is an abomination, from a clean, modular OOP coding perspective. Drupal has made changes to be more properly OOP, but still doesn't come close to Symfony.

    The question for a developer faced with PHP is thus: what environment am I going to be working in? Archaic spaghetti code or a modern well structured OOP project? Yes, there are tons of very shitty PHP environments out there, but also tons of great ones as well. In addition to that, if time is available to refactor that archaic spaghetti code, it is as easy as in any language to change it into usable maintainable modular OOP code.