SamC

is PHP really as bad as the internet makes out?

Recommended Posts

I've read many bad things about PHP over the years and actually wonder (from an experienced dev point of view) whether there's any truth in it? As a inexperienced programmer, you hear stuff like "the language doesn't matter, just learn to program". On the other hand, you hear, "don't choose language X or Y". You also face the choice of "am I going to learn a language that sucks?" which can be a total brick wall to a newbie. In PHPs case, the internet consensus is that it sucks almighty balls.

I was reading this earlier:

https://whydoesitsuck.com/why-does-php-suck/

Do devs get annoyed with a language because they don't fully understand it, or because they expect to be able to program in the same way they do in another language? Do they focus too much on the tools rather then end product as mentioned here:

https://blog.codinghorror.com/php-sucks-but-it-doesnt-matter/

Why do people comment on posts like the above with stuff like "Dynamic, weak typing sucks. I won't say more"? Is confirmation bias that important to programmers? Remember when Ruby was popular? Can I see a trend here...

How are inconsistencies in PHP any different from the total weirdness of JavaScript, which is super popular?

I'm well pleased with my sites I built over the years, they could be powered by fairy dust for all I care. Anyway, just after a few thoughts here.

  • Like 2

Share this post


Link to post
Share on other sites

Another question: Is PW a great peace of software? If yes, hmmm, - you know it's build in PHP.

In short: there may be some better or less better programming languages regarding to use cases, and yes, there are also some points in PHP that are bad, like in other languages too. But all that doesn't take to much account in comparision with what a developer do with it. So, it depends on the developer to 90% and 10% on the programming language.

just my 2 cents :)

  • Like 12

Share this post


Link to post
Share on other sites

There was a recent post somewhere in the forum of a video of Rasmus briefly explaining (sort-of) why PHP was "bad" at the beginning, and how far PHP has come in 2017 with PHP 7+. I personally love PHP despite its reputation because it's almost as old as the internet itself, and has endured with it. While that's not directly a measure of being a good programming language, it's a measure of stability that means anything I learn doing in PHP will be useful for years to come, unlike how some modern frameworks/language/libraries come and go.

And like horst said, there are always good and bad coders regardless of the language. Just like how they hail Python as a good programming language, but I've seen some people write some horrible stuff in it, ProcessWire is probably one of the best things I've come across that's written in a "bad" programming language. :)

  • Like 5

Share this post


Link to post
Share on other sites

Depends on a) your point of view and b) what you're doing with it.

While I might recommend something else for a programmer just starting out, that's mainly because PHP is a major abstraction layer and most PHP devs never get a proper idea about all the stuff that goes on behind the scenes. Also if you're doing something requiring a specific set of tools – such as working with big data and statistics – you'll probably find a language that is better suited for that particular task.

That being said, PHP is a decent language if you're primarily working on the web. It's rich in features, well supported, properly maintained, very widely spread, and so on and so forth. Additionally many online "this is why PHP sucks" lists focus on issues found from early PHP 5.x releases – or, better yet, PHP 4. These days there are a ton of things going for PHP, and not that many going against it.

(Much of this could also be said about WordPress, but... let's just not go there. It's not the same thing.)

... and, like @horst pointed out, in many cases the language isn't the most important thing to consider. You can do a lot with PHP, and the good thing is that (if you're doing something it's suited for) you can usually get it done fast. Surely there are languages that have technical advantages over PHP, but those usually apply to either specific situations or somewhat extreme cases, such as "I'm running Facebook" :)

  • Like 5

Share this post


Link to post
Share on other sites
3 hours ago, alxndre said:

There was a recentt post somewhere in the forum of a video of Rasmus briefly explaining (sort-of) why PHP was "bad" at the beginning, and how far PHP has come in 2017 with PHP 7+.

https://processwire.com/talk/topic/17707-php-in-2017-rasmus-lerdorf-wearedevelopers-conference-2017/

3 hours ago, alxndre said:

While that's not directly a measure of being a good programming language, it's a measure of stability that means anything I learn doing in PHP will be useful for years to come, unlike how some modern frameworks/language/libraries come and go.

+1 :) Progress can be great, fiddling with new stuff is fun but acquiring new skill takes time – for me a lot of time :) – so I try to stick to well tested and proven tech. For example, when I was young and bold :P I used to upgrade Mac OS as soon as the new version came out. These days I wait at least for six months before I do it, in order to watch and learn. There are enough beta testers out there, I'm no longer one of them.

Edited by szabesz
+1 added :)
  • Like 9

Share this post


Link to post
Share on other sites

I'm currently in a full on switch away from php to elixir, but I'd still not say php is generally bad. For websites with none or some business logic involved it's certainly good enough and has lot's of tools/people for moving quickly in that space. But I'd no longer use it for anything more complex or custom made. 

The things, which drew me to switch over where actually not the language per se, but rather the environment: Elixir is a compiled language, which is way more performant than php. It's damn easy to do concurrent computation harnessing the power of multi-core cpus, which is just a pain in php (react-php or threading). Long running computations are hard to do in a php world, where 98% of the time each request starts/terminates the whole world. Sure one can start a php script in the cli, but it's the communication which is the annoying part. Websockets or http2 streaming are the things in the web world, which are only possible with long running processes. 

Elixir does come with a own testing framework within the language. Code documentation is first-class citizen and the community/package manager push people actively to use it e.g. with automatic documentation hosting for packages. So there's a kinda canonical place for documentation and hell can it be good for the more popular packages. In PHP there's not even real consensus about using composer.

And the final point is that a functional language with immutable data does now fit my mind way better than oop and shared memory.

  • Like 5

Share this post


Link to post
Share on other sites
2 hours ago, LostKobrakai said:

I'm currently in a full on switch away from php to elixir

Does it also mean quitting ProcessWire based development?

Reading a bit about Elixir for web development, PHP and Elixir doesn't seem to be in the same league. Am I mistaken?

For example: https://elixirforum.com/t/elixir-web-development/2827

"
Are you looking to do rendering on the client on the server or both?

  • server side rendering than as people have already pointed out you can take a look at phoenix and eex templates.
  • client side rendering you can use whatever front end framework you find most appropriate the 3 biggest being React, Ember, Angular 2 (there are many other valid options like Elm etc.)
  • Server side and client side rendering well welcome to a world of pain :slight_smile: you will need to select an appropriate solution based on your choice of front end framework e.g. Ember2 -> Fastboot6, Angural 2-> Angular Universial3, React2 -> there are a ton of options pick one you dislike the least.

"

Sounds like scary stuff :-[

Share this post


Link to post
Share on other sites
14 hours ago, szabesz said:

Sounds like scary stuff :-[

Can say that again!

17 hours ago, LostKobrakai said:

But I'd no longer use it for anything more complex or custom made. 

What sort of stuff are we talking about here?

  • Like 2

Share this post


Link to post
Share on other sites

Was just wondering: are you going to tell your clients that their webproduct is made (partly) with elixer instead of php ?

Share this post


Link to post
Share on other sites
17 hours ago, szabesz said:

Sounds like scary stuff :-[

It’s certainly a different language, but besides any language/runtime based differences it’s actually not to different to use phoenix compared to using e.g. laravel in php. It’s got routers, controllers, views and behind that some business logic. I also noticed that the functional nature of the language does actually make the latter easier to understand than some oop classes and I found learning a functional (/actor based) language actually made me understand some principles behind oop quite a bit better.

2 hours ago, SamC said:

What sort of stuff are we talking about here?

Anything which you’d use laravel or similar frameworks for in the php world or rails in ruby. So custom web-applications, json api's, applications which often require things to run longer than the few second web requests. So kinda anything which is not just a website (cms) with a handful of forms and not full on e-commerce. I'd also do websites in elixir if they're supposed to handle a really big number of users / spikes of users. Some early adopters of elixir could reduce their number of servers to a quarter after switching to elixir (most from ruby/rails). 

53 minutes ago, pwired said:

Was just wondering: are you going to tell your clients that their webproduct is made (partly) with elixer instead of php ?

For the thing's I'll be using elixir for the client's won't really care. We're not doing very many marketing sites, where the client might want to edit texts or something. We run a SaaS product, where any client interaction is on the frontend anyways and also some web-applications, which we fully manage for our customers. Those also have the most interaction with people using the application on it's frontend and very few to no interaction with the client themselves.

  • Like 5
  • Thanks 1

Share this post


Link to post
Share on other sites
On 11/11/2017 at 11:34 AM, LostKobrakai said:

Anything which you’d use laravel or similar frameworks for in the php world or rails in ruby. So custom web-applications, json api's, applications which often require things to run longer than the few second web requests. So kinda anything which is not just a website (cms) with a handful of forms and not full on e-commerce. I'd also do websites in elixir if they're supposed to handle a really big number of users / spikes of users. Some early adopters of elixir could reduce their number of servers to a quarter after switching to elixir (most from ruby/rails).

That's a totally valid point.

I should see elixir so I can move away from Laravel to create rest apis and systems.
The only benefit of Laravel (And other PHP Frameworks) is they can interact with the ProcessWire API directly (Using composer and namespaces). But that can easily be solved with a simple Rest APi although requires more work :)

 

Share this post


Link to post
Share on other sites

From my personal experience, the language syntax is a real bug bear for me. You seem to have type more to express the same thing in other languages. And as a result, readability is not the best, at least in my eyes.

My personal (hopeful) wish is that they revise their syntax one day and adopt a more modern, concise syntax to bring it inline with their modern peers. Maybe the Internet will break if this happens haha.


Otherwise, as a whole I think PHP is pretty to good at trying to incorporate best practices / bits from other languages. They're a step or two behind, but they do seem to get there.

And every language has some sort of issues / shortcomings. It's how a programmer deals with it and what practices he/she adopts (e.g. Design Patterns, Defensive Programming, Automated Testing etc etc ) that will ultimately determine how good/bad your program is.

Share this post


Link to post
Share on other sites
8 minutes ago, FrancisChung said:

From my personal experience, the language syntax is a real bug bear for me. You seem to have type more to express the same thing in other languages. And as a result, readability is not the best, at least in my eyes.

On the other hand some languages seem to promote (or at least make it easy to author) fewer lines of code or fewer characters over readability. In my experience expressive syntax often results in code that is easier to read and grasp.

Of course you can write unreadable or readable code either way, so again it's very much up to the developer :)

  • Like 3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.