For those who dislikes PHP or is skeptical about it

Read this short and precise article :slight_smile:
http://pete-robinson.co.uk/blog/post/the-problem-with-being-a-php-developer

2 Likes

What qualifications does the author of that article have? How much experience does he have with other languages?

PHP was originally designed by Rasmus Lerdorf. Do you know what his favorite language is? Not PHP.

We can always find someone that either praises or criticizes anything. A company can fund an organization and then that organization can say that the company’s product is the best on the market. So the source of the praises or criticisms make a difference. The following have comments that, as far as I know, are from people qualified to make relevant comments.

A big problem with PHP is that it is not formally (precisely) described and is not easy to formally describe. The documentation is correspondingly unclear.

2 Likes

The first line of the article (written in 2012) indicates the author has over 10 years of php experience. His about me page indicates experience with javascript as well as c. Not entirely sure how you concluded that he was a paid shrill.

These were interesting links but I don’t understand their relevancy.

The first one (from 2007) merely describes some of the challenges in determining precedence rules in php. All languages have these sorts of issues. Personally, regardless of the language, if I am unclear about precedence then I use parenthesis. Life is too short to try and remember all the little stuff.

The second one (from 2010) was from the author of a php compiler that appears to be upset that Facebook released their own compiler. Actually, I think the article might be an attempt at humor? Parts of read like a parody and were quite funny. But again, I just don’t see the relevance between a compiler writer and someone who feels that php has some inconsistent function naming. Or whatever the standard php criticism happens to be.

2 Likes

He needs to get experience with at least one popular OO language, such as C++, Java or C#, before he can be considered legitimate by those that need convincing. He is convincing to those that agree with him of course.

I admit my comparison is misleading. The important thing is that anyone can post a criticism therefore you can always find criticisms of something. Mere existence of criticisms is not proof. This thread (the original post) implies that the article is proof.

No they don’t. Most other popular languages are rigidly defined. I don’t know about Perl and Python but C++, Java, ECMAScript and C# all have committees defining them. Much of PHP operator precedence originates from a time when PHP was informally defined. The relevance of the Meta Programming article is that it is an example of the informal definition of PHP. JavaScript is an example of a language that was informally defined but ECMAScript is and as a result most current variations of JavaScript are also.

The same could be said for the article that is the subject of this thread. You can choose to ignore the criticisms of PHP but there will always be criticisms from nearly all, probably all, computer language experts.

So @SamuelCalifornia

Wouldn’t you agree that all programming languages have their quirks? I’ve felt so many different feelings about PHP the past years, went up and down the emotional rollercoaster when comparing PHP to other languages. But in the end… It gets the job done. Right?

Sure many people write crappy code in PHP, and the language does give the freedom to create a big mess, in comparison to eg. Java. However in my opinion; it’s much more the experience and knowledge of the developer which decides whether a codebase is “good” or “bad”, rather than the programming language he’s using.

What I personally like about PHP is the somewhat maturity it has in comparison to for example JavaScript. The PHP community is finally settling on some good standards; I’m thinking about Symfony and Laravel as frameworks, composer as a package manager and the 7.x versions are really polishing the syntax. I feel many other languages are still somewhat immature (JavaScript) or outdated (Java or .NET) when it comes to web development. While PHP has many quirks and strange things, it is possible to write clean, testable and maintainable code for modern web applications. And isn’t that what defines “a good programming language”?

2 Likes

The argument that seems to always be brought up about PHP is that it’s a bad language since people who use other languages say PHP has been written with no security at all in mind. But that isn’t true at all. With the release of PHP 7, the security has been increased, PHP now uses less resources as opposed to the older PHP 5 so you’ll see an increase in speed performance, and lastly, many new features has been introduced like the spaceship operator.

What many non-PHP users are talking about is the codes that are produced by PHP users. They seem to confuse this with the security of PHP itself. Like many other languages, PHP is only as good as its writer. If the writer isn’t well knowledge, then the end product will only end up having what the writer has put in. So that is why you have a lot of really horrible tutorials because a majority of the tutorials don’t teach you security. They only teach you how to do it in a quick manner. And like I always say.

Simple isn’t always the best in every case.

This simply means that throwing up a few lines to save time or being trivial will not excuse the fact that said lines may in fact hold bugs or even security risks. This is why I believe any new beginner who comes into the programming world shouldn’t actually learn PHP first. In fact, any language at all. The first few things I look at when I look at any code or snippet in any language are

  • Proper and consistent indentations.
  • Logic

The reason why I cannot stress indentation enough is because the indentation describes how well knowledge the writer is. If the writer has sloppy and inconsistent indentation, this tells me that the writer doesn’t really care about their code. They just want it to “work”. Or maybe they weren’t taught properly. This in turn is why PHP IMO is looked down upon. It’s because a large portion of PHP users are novice and most of them have no experience in web development. PHP itself is very useful I would say when it comes to dynamic content. It’s just that everyone who bashes on PHP only see PHP as a beginner language. It’s not really. PHP too offers OO just like any language. When you go from Procedural to OO, you’ll start to see that it really isn’t a beginner language. Otherwise, any language using OO is also a beginner language because PHP isn’t all about Procedural. Things like PDO are only written in OO. There’s no Procedural for it at all and PDO is recommended over mysqli_*.

2 Likes

Yes. It is more a matter of having features that are unnecessary that can cause problems as well as lacking features that would be good to have.

Well yes, JavaScript is another language that was informally designed. It is not a good one to compare to.

That reminds me of the “goto” controversy that began nearly half a century ago. There is widespread disgust with “gotos”, but what is the problem with a language having the feature? Because the presence of the feature is implicit permission to use it.

I do not claim to be an expert, either in any computer language or in computer language design in general. I am saying that the specialist who are experts do not consider PHP to be among the best.

My first computer language that I learned was Fortran. I have not used it since learning it in about 1971. My second language was COBOL. I have never claimed that it is the best language; I don’t consider it to be a great language but to the extent that it is designed to be non-cryptic, it should be used more than it is being used, at least something like it. I used it because it was what my employer used; that is the point I am getting at.

PHP is being used extensively. Employers use it. Many individuals use it. Many of us must use it because so many others use it. The battle about how good PHP is will never end. If someone says that PHP is a great language then there will always be someone saying it is not, and I think that is true of PHP more than it is true of many other languages. If someone were to say that they use PHP because it is very popular, then it is very difficult to “argue” about that.

Improper indentation might indicate poor thinking but source code can be perfectly indented yet be a logical mess. It is frustrating for me when programmers comment on things that are easy to see yet ignore the things that can make a difference of many hours. In the C language, many people are quick to criticize use of “void” for the “main” method, yet that is so trivial.

Hi Sam

This was to main reason I wrote my thoughts down; so I’m sorry to read no arguments for or against it in your reply. Do you agree or not with this statement? If you do: why? If not: which programming languages, according to you; are a better fit when building web applications?

I am sorry, @brentroose, but I am not experienced enough with PHP to be able to be clear about its features.

So let me go sideways a bit. I think that the whole system for web applications is a problem. HTTP and HTML were not designed to do web applications. The original design was for HTTP to be a way to get documents from a server and HTML was designed to be more of a word processing feature. HTTP is stateless. Web applications developed but were not designed, much like PHP was not initially designed to be what it has developed into. So my answer to the question of “a better fit when building web applications” is that web applications need to be totally re-designed.

I don’t like C# in many ways but I prefer it over PHP. First let me define some terms. I will use the term “translate” to refer to the processing of syntax and semantics to convert human-readable source code into an intermediate language and the term “interpret” as execution of an intermediate language. There is not agreement of those definitions among others but that is my definition. C# calls the runtime translation of its intermediate language into machine code “compiling” but that seems to be an improper use of the term. It just makes everything more confusing.

In my opinion at least, the fundamental design of PHP and JavaScript as runtime translation and interpretation languages makes them less relevant for large-scale use. C# and Java compile into intermediate languages that allows the compiler to do many things. I think the “include” feature of PHP makes it sloppy. Unlike C++, a PHP include is processed during execution. In C++ #includes are done by the pre-processor and the #included source code exists as if it is in the file that #includes it. In PHP we can’t be sure what source code is relevant, correct? Even if we have PHP bytecode, the relevant source code is not certain until actual execution, right? So that does seem to be a security vulnerability, as @spaceshiptrooper refers to, but I don’t know about that and that is not what I am concerned about. My concern is that as a developer I can’t be sure what code is relevant; I hope you understand what I mean. If I have a function or a variable in PHP then it is not as clear where the function or a variable is, whereas other languages are more precise.

Some people make the argument that we don’t have to use various features of PHP and we don’t have to code in a certain way. The problem with that is, that just as with “gotos”, code written by organizations (businesses or whatever) belong to the organization. I have been a maintenance programmer. I have had to modify programs written and heavily modified by others. The programmer that uses a “goto” might understand the program just fine, but the problem is other programmers assigned to modify it. That is the situation that causes the “goto” to be hated. WordPress is a large web application. People say we should avoid getting into the WordPress source code because it is not written well. Well that does not help those that need to work with the source code. I use WordPress as an example because it is well-known but there are hundreds of other corporate systems that are potentially a mess.

[quote=“SamuelCalifornia, post:9, topic:244698”]
C# and Java compile into intermediate languages that allows the compiler to do many things.
[/quote]Add to the end of that sentence “at compile time separate from execution”.

[quote=“SamuelCalifornia, post:9, topic:244698”]
The programmer that uses a “goto” might understand the program just fine, but the problem is other programmers assigned to modify it.
[/quote]Add to the end of that sentence “might have problems understanding the program”.

Hey Sam!

Thanks for your feedback. As a web developer using PHP daily, I’d like to raise a few more things:

First of all; a good IDE. The same goes for C# or any language. The C# has Visual Studio, which is, in my opinion; one of the best IDE’s ever written. A quote a tutor of mine made a few years ago: “Microsoft does a lot of things wrong; but they know how to make IDE’s”. The same goes for PHP: once you use an IDE, almost all the problems you point out about interpreting vs compiling fall away.

Also; one could go a step further and use HHVM instead of the standard PHP interpreter; which will generate bytecode and improve performance a lot. (This is what Facebook does/did, they now actually made their own programming language called Hack: http://hacklang.org/).

Next thing I think about is the additions PHP 7 adds to the syntax. Type declarations became a big thing; so now PHP can also be strong typed. We could have a discussion in itself whether weak or strong typed languages are better or have more advantages, but to stay ontopic: modern PHP offers both.

About HTTP: yeah you’re right. But it is the thing we’re stuck with, and not going to change any time soon. And because of this, we’re greatly improving the things we’ve got. A good, funny talk about this topic comes to mind: https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript

And finally about maintaining code: I might not have enough professional experience in the area yet (a bit more than 2 years now); but I feel maintaining an existing codebase (your own or someone else’s), has much more to do with writing clean code, tests and documentation. Which is perfectly possible to do in PHP, but it’s also possible to neglect. The same goes for any other language.

As someone who has used PHP since around 2002, I’ve seen some pretty bad code. PHP makes it easy to get something, anything working, and I actually enjoy the flexibility it can provide with various ways of doing things, but many of the “features” it offers are often misused and/or misunderstood by beginners. It is absolutely possible to write nice code in PHP, it was even possible to write nice code in PHP before it supported objects properly and when register_globals was on by default and $HTTP_ variables were the way to access information. The problem is that it is also really easy to write bad, insecure code, and many other languages don’t have that particular problem because they were more carefully planned/implemented.

I also agree that HTTP/HTML are not the best methods for developing applications, HTML has been pushed well beyond it’s original purpose, but they are what we have.

I still like PHP, and when I need something done, it’s the tool I usually pull out first. I feel like I’m in an odd place of agreeing with most of the criticisms, and yet, it serves its purpose well.

Jeff

2 Likes

PHP programmers often defend PHP by saying that we can simply avoid using the features that can make software less maintainable. That works great when we only work with our own code but (as I indicated back in December) if we choose to be a PHP programmer for someone else and we must work with someone else’s code then the argument “simply avoid using the features” is not relevant.

I would assume it could be if you just update their code to a more modern style. If you know how the application is supposed work, then all you need to know is replacing old deprecated code to something modern. Take x7chat as an example. I like this application because it’s a nice and quick way of making a chat room. The only problem is, the author hasn’t updated the code in 4 years. So I took the liberty to update it myself. Changed the password hashing algorithm to PHP’s default password hash and added a few new options. The new modifications worked fine until the author closed their website down.

If you truly understand how an application runs, you can simply apply your own knowledge to have it working on up-to-date code.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.