Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


What's PHP Excel at? - Page 2
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

What's PHP Excel at?

2

Comments

  • "What about Python"

    Thanked by 1vimalware
  • Thanks @raindog308 my sentiments in a much more verbose way. :-)

    Thanked by 1raindog308
  • If one programming language was better than all others, then there will be only one language.

    They all have pros and cons, and it depends of what you want to do, and with whom. If it's collaborative work, you need to ensure that all persons participating are able to use the language.

    By the way, it's always good to have knowledges in different programming languages. Like that, you can choose the one which is the most suitable for your needs and resources. I use C/C++, Perl, PHP, and Javascript/Node.js. One language will be more convenient, for one thing, another for something else etc...

    To generate web pages, I find that PHP is more suitable. When it comes to highly interactive pages, then I prefer node.js. But that is only my opinion, and my feeling.

    Feelings must not be forgotten. The tool is one thing, the user another. If you feel more comfortable and fluent in one programming language, you'll certainly achieve better things, than if you use a "better" language that you are not mastering.

    So like in everything, try everything, and see what works best for you.

    By the way, PlayStation or Xbox ?

  • jsgjsg Member, Resident Benchmarker

    @raindog308 said:
    COBOL still has a massive presence...far, far more than PHP. A 2017 study estimated 220 billion lines of COBOL still in production use every single day.

    +1 for that

    @CConner said:
    To add, definitely check out https://deno.land/ - looks pretty promising.

    deno.land said:
    A word of caution: Deno is very much under development

  • varwwwvarwww Member
    edited December 2019

    Modern PHP7+ (LNMP/LAMP Stack) is pretty good and pragmatic. composer for dependency management (Follow PSR-4) + cherry pick your components from high quality repos like Symfony. Also remember to follow general web dev advice like escape ouput, sanitize input, Use PDO and prepared statements for databases, dont trust anything from user and you will have a pretty good scalable secure web app.

    Things PHP are not good for are websocket/live chat applications. You could use golang/nodejs for such use cases.

    Most of the people online that hate on PHP probably had to work on something like < PHP5 spaghetti codebases / Wordpress.

    Use https://phptherightway.com/ as reference. Codebase quality - all depends on the programmer. If you are a team, make sure everyone has their text editors/ide's configured to use PSR-12 formatting.

    Thanked by 1scorcher9
  • joepie91 said: Wordpress still uses MD5 for password hashing (yes, really), still uses unsigned automatic updates (which means you can instantly hack every WP install in the world by compromising the update server), and its plugin system is badly designed, resulting in a lot of plugin security issues and conflicts, on top of just plain messy code.

    Actually, they've added release signing recently. I've hit a nasty bug during updating and spent 5 hours trying to fix this. :smile:

    evnix said: If you have millions of dollars and can hire expensive devs, go for Java/SpringBoot, you cannot go wrong with it. Literally every big app is written with it, Kafka, elasticSearch etc etc etc.

    Ever since I discovered Java/Spring Boot I can never look back. This is just so much easier than PHP/Node.js. Even though Java is a static typed language, my lines of code reduced drastically. Performance is 100-1000 times better than similar PHP code. Code is more organized and easier to understand.

    Java documentation is much superior to PHP. Every use case is already described by someone, and there are whole books written about your use case. You never have to reinvent the wheel.

    You get database connection pooling and proper multi-threading by default! Most "cool" features are just there, and they just work out of the box.

    And the most amazing thing is that your code won't stop working 10 years later. Your Spring Framework version or Java version won't suddenly become outdated.

    Thanked by 1vimalware
  • @intelpentium said:

    joepie91 said: Wordpress

    And the most amazing thing is that your code won't stop working 10 years later. Your Spring Framework version or Java version won't suddenly become outdated.

    Spring Framework version support 3 year (?)
    Laravel 2-3 year
    Symfony 3-4 year
    .NET Core 3 year

    Thanked by 1intelpentium
  • nemnem Member, Host Rep

    dragon1993 said: My main problem with php is, it takes too much resource and too many times doing the same thing.

    I am having a rest api that upload users response (40 ish insert rows) / users into mysql database. The servers can't keep with the request. Most of the time, it's 503 / 504 timeout.

    Each PHP-FPM worker is dedicated to a particular request. If you wanted to interleave requests, you could build some gnarly proxy server (or Amp) that reads some parcel of data from Apache or NGiNX and asynchronously processes it. Some languages (Node) make it much easier to implement that model than PHP. That being said some of the stuff mentioned earlier is rooted in lore from the PHP5 days. 7 is plenty good and it comes down to your ability to implement code.

    Shitty code will run like shit no matter the language. Maybe changing your tool around might make you implement it better, but don't conflate one's ability to design with a language's ability to implement.

    Thanked by 1SteveMC
  • @nem said:

    dragon1993 said: My main problem with php is, it takes too much resource and too many times doing the same thing.

    I am having a rest api that upload users response (40 ish insert rows) / users into mysql database. The servers can't keep with the request. Most of the time, it's 503 / 504 timeout.

    Each PHP-FPM worker is dedicated to a particular request. If you wanted to interleave requests, you could build some gnarly proxy server (or Amp) that reads some parcel of data from Apache or NGiNX and asynchronously processes it. Some languages (Node) make it much easier to implement that model than PHP. That being said some of the stuff mentioned earlier is rooted in lore from the PHP5 days. 7 is plenty good and it comes down to your ability to implement code.

    Shitty code will run like shit no matter the language. Maybe changing your tool around might make you implement it better, but don't conflate one's ability to design with a language's ability to implement.

    It's true.
    I usually make monilit web apps, i don't need websocket.
    In this thing nodejs isn't better that PHP.
    (Websocket / async / microarchitecture of course)
    I don't like hosting my clients apps, many companies do it for cheap.

  • evnixevnix Member
    edited December 2019

    dragon1993 said: Spring Framework version support 3 year (?)

    probably he meant, upgrading it won't be much of a hassle.
    Java maintains strong backwards compatibility, a jar compiled 15 years ago will have a very high probability of working even in the latest version of Java.
    This principle is followed on in the frameworks, I recently upgraded a spring 1.x app written in jdk7 6 years ago to latest spring 2.x/jdk13
    Apart from a few constants(which notified on compile), nothing changed at all. The underlying implementation had changed but they had all maintained their contract. I managed to save a huge amount of time(and with it money).

    Most of NodeJS frameworks are always in flux, The code you write a year ago is almost always guaranteed to not work when you upgrade your underlying framework. This is true and gets worse for frontend JS frameworks/libraries too, The react code I had written a year and half ago unfortunately breaks in the current version of react and needs some major refactor to upgrade :disappointed:

    PHP-Symfony is decent at backwards compatibility,
    Laravel upgrade is usually a breaking change and in many cases the core team fails to notify about all the breaking changes (I have been through this trouble many times)
    PHP has really nice tools like Rector(https://github.com/rectorphp/rector) which allows you to auto-upgrade your PHP code(as well as Framework versions) without much of a hassle.

  • nemnem Member, Host Rep

    @evnix said:
    PHP has really nice tools like Rector(https://github.com/rectorphp/rector) which allows you to auto-upgrade your PHP code(as well as Framework versions) without much of a hassle.

    Curious as to what's your experience with its efficacy in automatically fixing code. Impeccable, decent job, hit or miss?

  • nem said: Curious as to what's your experience with its efficacy in automatically fixing code. Impeccable, decent job, hit or miss?

    It does a decent job, In my experience, It covers 99% of the cases for language level upgrades. 100% for code refactoring.

    While for framework upgrades, the more standard your code is, the more you will benefit.

    Any kind of smart code/hacks to trick the interpreter or use of eval is bound to fail.

    Thanked by 2nem mfs
  • SplitIceSplitIce Member, Host Rep
    edited December 2019

    Where PHP wins:
    - Low barrier of entry (this is what often leads to poorly developed libraries)
    - Framework / Library stability (low churn)
    - Templating
    - Backwards Compatibility
    - Resource consistency and freeing: At the end of every request resources go back to 0, and resource usage for a given script is usually consistent allowing for easy capacity estimations (i.e this server can support 32r/s because the page takes 0.25 seconds and takes 1/8th of the servers resources).
    - single layer vendor / packages leading to lower disk space requirements and easier dependency management
    - availability: cpanel / directadmin
    - large number of low traffic scripts can be deployed without increasing memory requirements

    Also as a side note I've got code I wrote over 10 years ago running with minimal changes. Backwards compatibility has turned out fairly good. Not 100%, but remarkably good for a language that has had large engine changes.

    Where PHP doesn't do well:
    - Memory usage: On average tends to be higher than say V8, but lower than RoR. Depends on the application of course.
    - Extension framework: Extension development is a bit clunky
    - Package & Extension repos (i.e packagist and PECL/PEAR): dated and basic

    At the end of the day pick the right tool for the job. For me this means:

    I'd go with PHP for a forum, a billing system, a mostly static site with some dynamic elements. It's just too easy.

    I'd go with NodeJS for anything that interacts heavily with the system, deals with non HTTP inputs/outputs (i.e a netflow processor), or anything that needs heavy backend real-time processing.

    I'd go with Lua (Openresty) for a lightweight API that needs to be able to take any r/s thrown at it.

    Thanked by 2corbpie SteveMC
  • nemnem Member, Host Rep

    @evnix said:

    nem said: Curious as to what's your experience with its efficacy in automatically fixing code. Impeccable, decent job, hit or miss?

    It does a decent job, In my experience, It covers 99% of the cases for language level upgrades. 100% for code refactoring.

    While for framework upgrades, the more standard your code is, the more you will benefit.

    Any kind of smart code/hacks to trick the interpreter or use of eval is bound to fail.

    Nice. I'll bundle that in as a last ditch effort for sites to modernize themselves in the panel.

  • @joepie91 said:

    @FAT32 said:
    @joepie91 is definitely an expert in Node.js. Hope that I have projects that are significant enough to ask for code review one day.

    Can I ask what is the most common problems or mistakes in all the Node.js code that you have seen so far?

    I'd say, in no particular order, off the top of my head:

    • Mixing (error-first) callbacks and promises
    • Not using custom error types / catch-all'ing errors
    • Highly imperative and mutating (spaghetti) code, lack of abstractions
    • Relatedly, inconsistent data formats/shapes throughout the code (ie. no conceptual "types")
    • Trying to chase the latest framework/database/library/whatever hype without understanding the tradeoffs or whether it's actually an improvement, or even the right kind of solution at all

    I’d also like to add:

    for (var a = 0; a < 100; a++) {
        if (a == 50) break;
    }
    

    breaking the middle of a conditional loop = obviously your condition sucks a*s

  • Daniel15Daniel15 Veteran
    edited December 2019

    If you want to switch to a better language than PHP, then JavaScript is probably not the best choice as it also has a bunch of flaws (and I say this as a frontend developer). What about C#, Go, or Python? Or at least TypeScript.

    SplitIce said: Where PHP doesn't do well: - Memory usage: On average tends to be higher than say V8, but lower than RoR. Depends on the application of course.

    It really depends on your use case. If you have 10 infrequently-accessed sites on a server, using Node.js or Ruby on Rails requires all 10 to be running as separate processes in memory, whereas PHP can use one single PHP-FPM server for all 10 sites. I don't think I'd ever try running hundreds of Node.js sites on a single VPS, whereas it's definitely achievable with PHP.

    LTniger said: PHP is qualified enough to be used by Facebook, Wikipedia, Wordpress, Baidu etc.

    Facebook hasn't used PHP for years. It uses Hack, which has origins in PHP but is a much safer strongly-typed language and basically all the bad PHP-isms have been removed from the language.

    Thanked by 1mfs
  • I know that this is a terrible and irrational reason to support PHP over node.js, but npm and electron makes me allergic to node.js. As soon as I see a package.json file, I press back button.

  • FAT32FAT32 Administrator, Deal Compiler Extraordinaire

    @Jun said:
    I know that this is a terrible and irrational reason to support PHP over node.js, but npm and electron makes me allergic to node.js. As soon as I see a package.json file, I press back button.

    What. As if composer.json is not a dependency file. People shouldn't just bash one language/framework over another just because you dont like it, especially the way you express it.

  • @FAT32 said:

    @Jun said:
    I know that this is a terrible and irrational reason to support PHP over node.js, but npm and electron makes me allergic to node.js. As soon as I see a package.json file, I press back button.

    What. As if composer.json is not a dependency file. People shouldn't just bash one language/framework over another just because you dont like it, especially the way you express it.

    Yeah I know I know. You're absolutely right. I just can't justify my allergy and I know I'm wrong. Guess I should revisit node sometime. My short experience was far from pleasant but I guess it was just because I don't know how to use it right.

  • My short experience with node was to take over a couple different existing code base. And I was only surprised to see how many packages the project depends on for even a tiniest bit of logic. And a lot of stuffs broke from bad version management across all dependent projects. After mingling for a while, I could not like npm. Is this just because of a bad coder?

    Thanked by 1vimalware
  • CConnerCConner Member, Host Rep

    Daniel15 said: What about C#, Go, or Python? Or at least TypeScript.

    Go is hardly a good alternative to PHP or JS for larger projects.

  • SplitIceSplitIce Member, Host Rep

    @Jun Bad software engineering will destroy any project regardless of language.

    Source: 12 months in a job that involved evaluating & occasionally rescuing failed projects. 10 years as a software engineer, many of those as lead.

    Thanked by 1exception0x876
  • yoursunnyyoursunny Member, IPv6 Advocate

    https://yoursunny.com is proudly built with PHP.

    Using PHP, I can run N completely unrelated projects in the same site, using a fixed number of processes (two nginx and two php-fpm). I do have to adjust nginx rewrite rules from time to time.
    Using Python or Node, I would have to run N python or node processes, each with their systemd setup. This would consume more CPU and RAM even when idle.

  • jsgjsg Member, Resident Benchmarker
    edited December 2019

    Are we discussing languages or language universes incl. batteries, editors, FCGI support, etc.?

    I'm grateful to @joepie91 because he made the effort to lay it out so well. And yes, the only thing PHP excels at is in creating unreliable, slooooow, and trouble ridden (incl. gross vulnerabilities) "applications" (or web services).
    "But PHP 7.x is y% faster than PHP 5.x" you say? Sure ant species A is y% larger than species B too - but that doesn't change the fact that ants are not large.

    Let's be honest: PHP was created by someone [attributes self-redacted] who wanted to enable clueless hobbyists to somehow makeshift small scale little app thingies. And he succeeded. Today there are millions of (largely) clueless hobbyists who happily use PHP.

    Well noted, I don't write this to insult anyone! I write it because with a language come personalities, wishes, world views, history, etc. and maybe most importantly a goal, e.g. "make it easy even for clueless non programmers to create something on the web". And that is OK, really, but it becomes a problem when such a language gets used for serious stuff.

    Btw. I agree with @Jun. Some software written in language X looks and "smells" differently from language Z, A, and B. And it is absolutely OK to avoid a language based on that. Maybe it's not the wisest thing to do but it's OK. The relevant point there is to understand that a subjective verdict is not an objective one and hence no basis to ridicule others who like what one personally dislikes.

    That's why I do not ridicule PHP "developers" - as long as they stay within their bounds. facebook is a good example. They started basically as hobbyists and used PHP (which is OK) but when they turned into a company of some weight they left PHP as far as they could by switching their PHP codebase to Hack that is, to a PHP-like language (well, they couldn't throw away all their code as well as all their developers) which is much more stringent and free of some of PHP's major sins and weaknesses.

    Someone here mentioned (among other applications/services) "billing" done in PHP. Guys, have you been lobotomized? It's 2019 and we KNOW how trouble and vulnerability ridden PHP is. Doing billing - which also means to deal with customers confidential data! - in PHP should lead to automatic sentence-tripling in court if there ever is a problem - and there will be problems.

  • nemnem Member, Host Rep
    edited December 2019

    I mean if we want to make ad hominem arguments about languages, let's not forget the morsel about npm package maintainers and their security practices... Nearly 52% of npm packages were published by accounts that had weak, hackable credentials.

    PHP provides plenty of great features now including strict typing, traits, covariants/contravariants, variadic formal parameters, typed class properties, asynchronous programming, etc. 8 is introducing JIT that levels the playing field with Node.

    It's really how you use it. There's idiots in any field.

  • SplitIce said: @Jun Bad software engineering will destroy any project regardless of language.

    Yeah, any bad user can destroy any project regardless of language, I know. But for some reason, npm was by far the worst of all library repositories I have ever experienced.

    jsg said: Btw. I agree with @Jun. Some software written in language X looks and "smells" differently from language Z, A, and B. And it is absolutely OK to avoid a language based on that. Maybe it's not the wisest thing to do but it's OK. The relevant point there is to understand that a subjective verdict is not an objective one and hence no basis to ridicule others who like what one personally dislikes.

    Yeah I didn't mean to ridicule node or its users but I really couldn't like node not for the language itself but for my experience with npm and electron. I have sworn not to use node.js ever again after trying it out for a while but from recent trend of programming language, I figured out that obviously I was wrong. Guess I'll try it out again this weekend.

    nem said: I mean if we want to make ad hominem arguments about languages, let's not forget the morsel about npm package maintainers and their security practices... Nearly 52% of npm packages were published by accounts that had weak, hackable credentials.

    And I'm really not surprised about this from my experience with npm.

    Thanked by 1vimalware
  • jsgjsg Member, Resident Benchmarker
    edited December 2019

    @Jun said:
    ... but from recent trend of programming language, I figured out that obviously I was wrong. Guess I'll try it out again this weekend.

    Largely disagree. Following a trend is highly likely to be nonsensical because trends are created by masses of people and masses of people tend to be stupid not very smart. Also note that there is little correlation between a language being trendy and being and supporting good quality.

    Thanked by 1vimalware
  • SteveMCSteveMC Member
    edited December 2019

    Indirectly related, never forget to keep an eye on announcement, updates, and so on, no matter what language, engine, tool, you are using. For example, today : https://nodejs.org/en/blog/vulnerability/december-2019-security-releases/

  • nemnem Member, Host Rep

    @jsg said:

    @Jun said:
    ... but from recent trend of programming language, I figured out that obviously I was wrong. Guess I'll try it out again this weekend.

    Largely disagree. Following a trend is highly likely to be nonsensical because trends are created by masses of people and masses of people tend to be stupid not very smart. Also note that there is little correlation between a language being trendy and being and supporting good quality.

    PHP -> Ruby -> Node and conversely the hate train PHP <- Ruby <- Node

    And then there's Python. I love Python even though I'd never write in it more than is necessary. Such a semantically beautiful language :heart:

    Indirectly related, never forget to keep an eye on announcement, updates, and so on, no matter what language, engine, tool, you are using. For example, today : https://nodejs.org/en/blog/vulnerability/december-2019-security-releases/

    I hope they fix the type. Renders like shit on Windows. L-SEP L-SEP L-SEP

  • jsgjsg Member, Resident Benchmarker

    @nem said:
    And then there's Python. I love Python even though I'd never write in it more than is necessary. Such a semantically beautiful language :heart:

    Yes, I used Python for over a decade for scripting jobs but have switched away because it has become a fat monstrosity.

Sign In or Register to comment.