Jump to content
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 13

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

If you are doing Web PHP is still awesome, however if it reaches the point where you are really taking shit load of request, that's when you will branch to faster languages like Golang, For me am still deciding which to commit to still deciding between .NET Core, Spring MVC or Golang Web frameworks but still be using PHP for simple sites. 

Share this post


Link to post
Share on other sites
On 11/10/2017 at 6:37 PM, LostKobrakai said:

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.

Exactly you've hit the nail with the shortcoming of PHP, it's interpreted every time it needs to be parsed and fed to the Zend Engine meanwhile compiled languages would run much more faster and scale better than PHP, I read the benchmark of a Golang application and I was blown apart normally i'd stick to Spring but the memory consumption is excess, but I haven't come across elixir, might give it a shot

Share this post


Link to post
Share on other sites
11 hours ago, Sephiroth said:

PHP, it's interpreted every time

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

You might want to watch it from 02:42
PHP was meant to be a templating language only (which it is still today) on top of the business logic written in C but as it turned out, nobody wanted to write and compile C.

Sure, these days we have better alternatives when it comes to writing code that can be compiled to machine code but it still requires a lot more setup an configuration than to simply use PHP or Perl which are preinstalled on each webserver, ready to be used by writing a few lines of code or installing a CMS or framework in a few minutes. PHP is evolving and it is still a solid option for small or medium sized solutions and I guess 95% of the web belongs to those categories.

Sure, when one is after a career of writing code for big companies (including big governments), PHP might not be the best language to practice. However, freelancers and small companies can still rely solely on PHP as far as running code on the server is concerned.

  • Like 1

Share this post


Link to post
Share on other sites
Quote

PHP is evolving and it is still a solid option for small or medium sized solutions and I guess 95% of the web belongs to those categories.

I agree and php does the job perfectly with processwire for all those cases. If you have a bigger project you can choose from different php frameworks.

If your project is really big and needs faster resources ok you can use something like elixer. But wouldn't that be the 5% cases ?

Quote

Sure, when one is after a career of writing code for big companies (including big governments), PHP might not be the best language to practice. However, freelancers and small companies can still rely solely on PHP as far as running code on the server is concerned.

PHP is still most wanted. Just look on the internet how many companies are looking for junior and senior php coders. I know a few coders in my neighborhood who make/maintain apps for ios. They all use php for server and cloud communication.

  • Like 1

Share this post


Link to post
Share on other sites
56 minutes ago, pwired said:

Just look on the internet how many companies are looking for junior and senior php coders.

One ‘issue’ I would say for me learning processwire so far is that I’m not sure how much actual php I’ve learnt. My logic skills have certainly improved, I can see that, but as far as getting a Job as a junior dev with js/php I feel like I’m still so far away! Round here they list requirements that read to me like the requirements for a very experienced dev, not stuff that I’d call “junior”. Can be frustrating. I’m trying to get self employed work as a way to get experience as my normal mon-fri day job has nothing to do with web at all, hardly touch a computer (gotta pay the bills though). This is why I’m always at this every night and weekends. Always looking for that opportunity to do this full time! Lucky I enjoy it so much or I would have given up this dream years ago.

  • Like 2

Share this post


Link to post
Share on other sites

I'm in the same boat but I set out fixed and achievable goals for myself. As log as I can reach my goals I do not care too much what other options are out there. I try to keep an open eye on the ever evolving technology but I also have 24 hours a day  :) so we need to take it easy as much as possible.

6 minutes ago, SamC said:

I’m not sure how much actual php I’ve learnt

I do not know either but I'm sure I keep improving.

11 minutes ago, SamC said:

getting a Job as a junior dev with js/php I feel like I’m still so far away! Round here they list requirements that read to me like the requirements for a very experienced dev, not stuff that I’d call “junior”.

Do not think they would surely not be happy to employ you, they just list whatever they think would be perfect for them. However, when there is no one in sight fulfilling those requirements then they are happy to employ the first one who can at least help them out :) 

  • Like 3

Share this post


Link to post
Share on other sites

@SamC

You're right about that, the list of php coder jobs requirements published by companies are high and go beyond php such as oop, frameworks, js, sql, git, xml, json, css to name a few. I certainly wouldn't be able to code in all those fields at a company level. But I see the internet economy growing fast year after year with opportunities, jobs, self employment and money to be made. Instead of coding for a company I looked for shops that also have a website or a webshop. The number of shops that also start a website or a webshop is growing rapidly and they need somebody who can set it up and maintain it. Sure, some of them already have somebody doing that but not all of them. It is a matter of checking all the shops in your neighborhood until you find them. I found a health shop where they desperately needed someone to maintain several web shops for them. The php coding level needed for a webshop is not so high as for a company and is perfect for both making a second income and upgrading your coding skills in different fields as you go.  Making money on the internet economy is also a good solution for if you are going to get a bad pension when you retire. Getting a pension in spain is uncertain and if you get one you get very little paid. Economy in spain is going bad and the social seguridad here tries to cut pensions where they can. The growing internet economy can be a solution for that. Either you use the money you make for a private pension or you keep on working easy from home :)

  • Like 3

Share this post


Link to post
Share on other sites

Yeah the pension thing is a problem in a lot of countries, and one of the things (along with holidays/sick leave/perks) that makes working for a company more desirable than self-employment. However, there are pros and cons to both.

One of the reasons I want to get into process module development (gonna go through @bernhards great guide) is so I can start looking a the core code and classes and a bit deeper into the system rather than just sticking with the API which is an abstraction away from the underlying PHP.

I think once I start to get the hang of that, my skills will certainly improve. I was looking at react and stuff to further my JS, but tbh, am I actually going to use that at the moment? If I need a job at a company, then I need to know this, if I'm making websites for local companies self-employed, then probably not. Same with PHP, I have no idea how to use a framework like laravel. But do I need this? That would take time away from PW module development, which would be a great thing to do, contributing to open source, learning more etc.

It's like a cat and mouse game, and I'm most definitely the mouse :P

@szabesz when you say achievable goals, this is something I'm missing which would help for sure. What sort of goals do you set yourself?

  • Like 3

Share this post


Link to post
Share on other sites
26 minutes ago, SamC said:

Same with PHP, I have no idea how to use a framework like laravel

There are tons of tutorials and other staff to learn Laravel. If you keep the PHP way I do recommend digging into that. You'll learn many useful stuff (MVC, OOP, templating, Composer, etc) and it's also relatively easy to grasp. Plus knowing Laravel nowadays for a PHP dev is a must imo. And once you know Laravel, all other frameworks will be much easier to understand.

I agree that if there's no project to start using a new tool can be frustrating. I usually decide what to learn and during the learning process a project usually comes to my mind that could be created/rewritten in it, or at least more fun.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
6 hours ago, SamC said:

What sort of goals do you set yourself?

Currently I'm lucky enough to be able to pick whatever technology I want in order to deliver the end results and that is why my goals regarding web development are not learning something specific but to focus on the tasks I'm "assigned to". As long as everybody is happy with my work, I'm happy too :) There is always room for improvement but that's what keeps me interested anyway...

  • Like 1

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.

×
×
  • Create New...