0

PHP is written in C, but is considered a language. What makes it different from something like jQuery which is considered to be a library of Javascript? Why is PHP not a library of C or jQuery a language in its own right?


This is not a dupe of this question because it does not address languages which is the primary point of my question.

7

A language is the source code you write when building an application, while a library is a packaged set of features you can use in that language.

PHP has its own syntax, keywords, methods, etc. that you can organize into features, and organize those features into an application.

You can write code in "PHP." You can't write code in "jQuery," the jQuery library is used by applications written in JavaScript. jQuery is simply a package of convenience methods that make it easier to use the JavaScript language.

It's important to separate the compiler/interpreter process from the code you write. How the code is compiled or interpreted is a hidden implementation detail. You shouldn't have to worry about it.

Why is PHP not a library of C? Again, knowing that the PHP interpreter is written in C doesn't matter. You could write your own interpreter in C++ or Go but it wouldn't change the PHP language.

As another example, the gcc compiler is written in C, but that doesn't make C a library of itself. The same goes for C#, in which the Roslyn compiler is written in C#, but C# remains a language.

  • 1
    Also, there are PHP implementations in C++ (HHVM), Java (P8, Quercus), C♯ (Phalanger, PeachPie), RPython (HippyVM), and probably a couple of others. – Jörg W Mittag Sep 14 '18 at 20:02
3

PHP is written in C

No, it isn't. It is written in English.

There are multiple implementations, only one of which (Zend Engine) is written in C. Quercus and P8 are written in Java, Phalanger and PeachPie are written in C♯, HippyVM is written in RPython (using the PyPy framework), HHVM is written in C++.

What makes it different from something like jQuery which is considered to be a library of Javascript?

A language has semantics, syntax, and a type system. PHP has all of those.

Why is PHP not a library of C or jQuery a language in its own right?

jQuery has no semantics of its own, its semantics are the ones of ECMAScript, it has no syntax of its own, its syntax is the one of ECMAScript, it has no type system of its own, its type system is the one of ECMAScript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.