When it comes to programming, there are two main broad categories of languages. We have programming language and scripting language. The two types are different in several aspects. One of the languages that are commonly used is Hypertext Preprocessor (PHP). So, under which category does it belong to? Is PHP a programming language or a scripting language?
Being a server side language, many people assume that PHP is a purely programming language. The ability of this language to perform some complex tasks cements the position of PHP as a programming language.
Also, Read:Â Difference Between Scripting, Markup and Programming Languages
However, the truth of the matter is PHP is a powerful scripting language for web programming. It is the language that you can use to allow a seamless interaction between web pages and the servers.
So, why should we classify PHP as a scripting language and not a programming language? Well, here are some of the reasons:
PHP is an interpreter based language
This is one of the factors that differentiate programming and scripting languages. While programming languages are compiler based, scripting languages are interpreter based. This simply means that PHP doesn’t have to be compiled before interpreted. The compilation process entails translating a high-level language into a machine language.
As a scripting language, PHP doesn’t have to be compiled. Instead, the interpreter executes the instructions directly without first converting them into machine instructions. This is different from programming languages as they first have to be compiled into machine language before being interpreted.
Also, Read:Â 20 Interesting facts about PHP every developer should know
Usage
Another reason that makes PHP be a purely scripting language is the usage. Can you list any applications that have been built from scratch using PHP language only? Obviously, you won’t be able to do so. This is because PHP must be combined with other languages and components in order to come up with a complete system.
This is a typical characteristic of most scripting languages. They cannot fully depend on themselves to build an application. They must be blended with other applications. For example, PHP should be blended with HTML and JavaScript.
Temperament
By temperament, am referring to the levels of difficulty of a programming language. It is too hard or can it be easily coded. Scripting languages are very easy to code. You simply need to type only a few lines of code. This is another reason why PHP can be easily categorized as a scripting language.
On the other hand, programming languages will force you to write several lines of codes just to implement a single function. You won’t get away with some short lines codes.
Creation of files
When it comes to a programming language, they create files that can be stored and even transferred from one device to another. The files are usually in the .exe format. On the other hand, PHP does not create the .exe file.
Running
Another distinct feature of scripting languages is they run inside another program. They don’t run independently. In our case, PHP can only run in a web server or browser. On the other hand, programming languages can run independently without depending on the parent programs.
Conversion
On the other hand, programming languages can be used to build a complete application from scratch. Take for example C language. It is capable of building a standalone application from nothing.
Interpretation
As a scripting language, PHP is interpreted within another language such as HTML before being interpreted again by the browser. This is different from programming languages which are compiled into a compact form and don’t have to be interpreted by another program.
In conclusion, you can easily assume that PHP is a programming language. This is because it has lots of features of a typical PL. Otherwise, the article elaborates well why PHP is a scripting language.
Is the author of this text high? I don’t even know where to start with this nonsense. Those statements are simply WRONG on so many levels.
“PHP is interpreted within another language such as HTML before being interpreted again by the browser.”
What on the Earth are you talking about?
I agree with you. When I read languages are tow types programming languages and scripting languages, I relized this article is nonsense. I don’t know why this is mentioned in PHP Weekly.
I got a little upset when I read this article. I mean, it’s OK to be ignorant, but then at least don’t spread your ignorance as if it were knowledge. Whether a language is interpreted or compiled doesn’t define whether it’s a programming language or not. As far as I know, there is no clear distinction between a scripting language and a programming language as, quite often, they can be both, e.g. javascript. I believe the definition of a *programming* language is the ability to control the program flow, as opposed to for instance HTML documents that are rendered top down with no way of iterating or branching code. That’s why you need languages like PHP in the first place, to add some server-side logic.