What are the pros and cons of plain PHP or Classic ASP?

PHP and Classic ASP are server-side scripting languages. What is wrong with having a website written in this instead of the trendy JavaScript Frameworks like React, Angular etc.? If memory serves me correctly, there is an issue with security where you can post in a text box some script and hack into a system.

Can we please discuss some pitfalls or drawbacks to having a website written entirely in PHP or ASP? What does a JavaScript framework or Node.js bring to the table that would otherwise be lacking?

I am just now venturing into a contract where I am tasked with updating and maintaining existing code. All I know right now is that it is written in PHP and Classic ASP. I am in the process of investigating these scripting languages and I want to know what the opinion of other developers are.

Recommended Answers

All 3 Replies

As someone who has been coding, almost exclusively, in PHP since 2002, and has coded DaniWeb entirely in PHP, I think I am qualified to answer this.

In my humble opinion, PHP has a really bad rap because it started as a simple scripting language to create dynamic content online back in the day, and it's open source. That means it's really easy to get up and going with PHP very easily, but it also means that, because of the very low barrier to entry, there is a lot of bad PHP code that exists out there on the web. It's a favorite language for script kiddies and people who are tinkering.

PHP is also a little haphazard in that it's a very old language that has been trying really hard to mature and keep up with the times. However, that means there's a lot of internal PHP functionality and function names, etc., that don't follow the same convention, or almost seem like they're afterthoughts, as the language has slowly evolved and been built on top of itself over the decades.

Imagine trying to work on the same project for 30 years and constantly try to innovate and build on top of it. At some point, it becomes a little bit like spaghetti when you just keep building on top of things without ever starting off with a fresh, clean slate.

More of the trendy languages nowadays are significantly newer, and have been designed from the ground up from the mistakes of languages that came before them. That means that, right out of the gate, they're well thought out and intuitive.

Languages like PHP had to learn from their mistakes, over time, and so the current syntax might come off as a bit of an afterthought without a strong convention.

All that being said, I've been saying for 20 years now, I'll switch away from PHP if I ever feel as if the language is getting in the way of something I'm trying to accomplish, or is making my life more difficult that it needs to be, or I can't do what I'd like to do because of the language, etc. I've never felt that way yet.

PHP still powers a significant chunk of the web, it's still an actively-developed, evolving language with a big community behind it, and I'm still quite happy with it.

commented: I see a lot of JavaScript enthusiasts criticize PHP for what PHP was 20 years ago (but look at JS in 2002!) It's ignorance and hype train to me. I hav +0

PHP 5 was simpler but PHP 7.4 and 8.0 are much harder to write in because they are much tighter syntactically and have classes and objects so less errors can creep in e.g. initialisation of variables.

Versions of PHP are coming out every year now with code breaking every time they come out with new versions. This results in many annoying syntax errors that have to be corrected or an older version has to be run with its security flaws.

PHP also is harder for low level HTTP requests whereas C is much tighter and faster and programmer knows what is happening under the hood whereas in PHP or Python or Javascript it is harder to know what the code is actually doing and why strange reverse proxy errors are cropping up.

Large PHP frameworks are used now to simplify code e.g. Zend or Laminas.

What language you use will depend on what you want to do. PHP is good for basic data manipulation but for large link lists or dictionaries Python would be better. For low level memory manipulation C is better. It depends on what the software is meant to do. Ruby may be better for quick mockups or playing with algorithms.

Sit down and architect the problem then pick the language. If you just go along with what you know you may create a headache.

I once tried to use PHP for low level JSON Web service client and it took years to see it was not up to scratch so I switched to C and it was harder at the beginning but I got all my client code up and running in a few months or even days as it was so powerful and versatile compared to PHP.

So productivity was huge by picking the right language. Familiarity is not always best. Pick the best language for the project by looking at its capabilities, syntax and power.

Later I found Perl was much quicker for regex searches than C but took longer to get my head round arrays and hashes to handle drilling down into a JSON hash of hashes. Also Perl took about 10% of the lines of code of C to do the Web service client.

So use of languages will evolve depending on what the language is used for.

If you want the beauty of Web GUI eye candy then probably JavaScript and CSS is the go not PHP, C or Python in which case Node is the best option as JavaScript is a natural for processing JSON which seems to be ubiquitous these days in handling Web based data.

If you want the beauty of Web GUI eye candy then probably JavaScript and CSS is the go not PHP, C or Python in which case Node is the best option as JavaScript is a natural for processing JSON which seems to be ubiquitous these days in handling Web based data.

On the web, you have to use both a server side and clientside language (js, html, css) no matter what server side choice you go with. JS can be used for both with node, but you can’t avoid html/css/js on the front end either way.

They being said, I’m not quite sure you answered the question of whether it is a good idea for him to take on an existing php/asp project.

My quick answer is that php is what you make of it. You can write very neat, well structured, MVC framework php, or you can write spaghetti mess php. Php doesn’t have a lot of structure to it built in, that forces you to write half decent code, so it’s up to the programmer to be well disciplined.

commented: Plain JavaScript is not a good backend/ server side language either. Ever tried to build a serious web app with node and mongoose? I'd rather have fro +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.