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.

amflare
  • 241
  • 1
  • 8
  • 5
    Possible duplicate of [Library vs. framework vs API?](https://softwareengineering.stackexchange.com/questions/54451/library-vs-framework-vs-api) – gnat Sep 14 '18 at 13:39
  • It should be noted that PHP has a standard library. – Theraot Sep 14 '18 at 15:56

2 Answers2

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.

Dan Wilson
  • 3,073
  • 1
  • 12
  • 16
  • 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.

Jörg W Mittag
  • 101,921
  • 24
  • 218
  • 318