What is a "real" programming language? [closed]

Recently a teacher said "PHP isn't a real programming language", but only gave, in my opinion, weak justification:

  • It's not compiled.
  • It's scripted.
  • It doesn't run on every platform.

Is PHP not considered a "real" programming language? What is a "real" programming language? Must a language be compiled to be taken seriously?

Background

I did an induction lesson into my A-Level Computing Class in school two days ago – we're using Java for the first year of the course. I'm unfamiliar with Java but have a pretty good grasp on general programming fundamentals (variables, functions, object-orientation, loops, etc.).

Our first task the teacher ran through ridiculously fast. She didn't bother to explain any of the concepts, how they work, or what you would realistically use them for, and seemed to take great pleasure in watching most of the students (who were, on the whole, new to programming) squirm in their seats at not having the vaguest idea what she was on about. In hindsight, I reckon she went through it incredibly quickly to see who could really "handle" taking Computing A-Level, since students still have a chance to change their subjects before September begins.

The first and only task was to write a Java command-line application to convert binary to denary (decimal). We had a two-hour taster session to do this, and after explanation how the binary system works we had to begin, despite, on the whole, nobody really having the foggiest idea where to begin. After an hour some were further than others, but nobody had really achieved anything significant. The teacher herself became so confused she called in another teacher from next door. He came round to help people and see where to go next.

Without bragging, I probably did have the most experience in the class and had gotten the furthest in the exercise. He asked me if I'd had any previous experience; I said yes, particularly in PHP, and jokingly commented that I could write something to convert binary to denary in just a few lines of PHP, whilst the Java application was rapidly growing into several screens of code.

He replied, "PHP isn't a real programming language!"...! After some discussion, he gave the three reasons above. However, I pointed out you can run PHP on any platform that runs Apache, but I don't think he really knows what Apache is and was having none of that!


Solution 1:

First we need to know what a programming language is. At its minimum, a programming language is something that is read by the computer and instructs it to perform certain operations. Many people would also expect a general purpose programming language to be Turing complete. However there could be situations where a domain-specific language isn't Turing complete but is still a useful programming language for that specific domain. Programming languages can be compiled or interpreted, and they could run on many platforms or just one specific one. Different needs require different programming languages. Clearly PHP is a programming language.

My definition of "real" programming language would be any programming language that has at least one practical usage in the real world. This is opposed to an esoteric programming language which typically has no practical usage. Since PHP is used widely to solve real problems it easily meets this requirement for being a real programming language, although it is arguably not a particularly beautiful language.

PHP is a pragmatic language. It was created out of a specific need to be able to quickly make web pages (the name originally stood for Personal Home Pages) and the language was extended as required. Since there was no theoretical background or strong design principles driving its creation (there isn't even a formal specification of the language) it is less clean than many other more modern languages. Features like correct handling of foreign characters / unicode characters are obviously added on afterwards and not cleanly integrated with the rest of the language. This untidiness and lack of theoretical rigour causes many people (especially academics) to dislike the language and this may be part of the reason why your teacher doesn't regard PHP as "real" language.

However PHP is good at what it was designed for and many sites use it, even very large sites like Facebook, Yahoo! and Wikipedia.

Solution 2:

It's not compiled

PHP can be compiled (e.g. through HHVM).

It's scripted

That's just another way of saying that PHP is not compiled.

It doesn't run on every platform

Neither does Java.

Sounds like you have a really bad teacher there.

Solution 3:

Of course PHP is a programming language. He probably meant it isn't a "real" programming language in the same sense that "real" men don't eat quiche.

Solution 4:

define:programming language

It seems, according to this, that PHP is a programming language. Whether it's a real programming language is entirely subjective. Whether it's a good language is also subjective. Certainly, it is most commonly not used as an application programming language, but it can be used to develop shell applications via CLI. I have never done this, so my understanding of it is sketchy, but it's possible.

Now, is PHP "scripted" (I take this to mean a scripting language), and does it run on every platform? You judge:

PHP: Hypertext Preprocessor is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document. As a general-purpose programming language, PHP code is processed by an interpreter application in command-line mode performing desired operating system operations and producing program output on its standard output channel. It may also function as a graphical application. PHP is available as a processor for most modern web servers and as standalone interpreter on most operating systems and computing platforms.

Source: http://en.wikipedia.org/wiki/PHP

Does Java even run on every platform? No. Only those for which there exists a JVM.

Finally, does a language need to be compiled? Many aren't. Even Java isn't compiled in the same way C or C++ is. And then you'd also need to take a look at Perl, Python, etc.

Personally, I think PHP is a real programming language. I started there and easily moved on to C/C++ and Java. I wouldn't use it for the same purpose as Java, and its design is different from Java, but that doesn't mean much. It was easier to learn than Java for me.

Solution 5:

First of all, not being compiled and being interpreted (what he surely meant by scripted, which is somewhat vague and used for different purposes anyway) are different sides of the same coin, and thus really the same reason.

The last reason, that it doesn't run on every platform, is just confusing. It sounds like he's trying to tout Java's portability and PHP simply isn't Java. However, Java runs on one very specific platform: the JVM. That platform in turn runs on many other platforms, and thus gives Java its portability, but it's not quite the same as the traditional use of "portable". For example, C is portable and runs on everything from a PDP-11 to the latest embedded devices.

However, C does that by specifying rules of its own abstract platform, and compilers transform C code into assembly according to those rules. This is how Java's portability is similar to C's: they both define rules which are translated into instructions for a specific, concrete machine (processor); the difference is when that occurs.

All problems in computer science can be solved with another level of indirection.
  — David Wheeler

In reality, even assembly or "machine code" is interpreted by the processor into its native actions. (I don't have a good source at hand for this, but I recall that it's lightly covered by A Crash Course in Modern Hardware, which is a good presentation anyway.) As processor speeds get faster, we hardly notice on our underused boxes whether a given program is in asm or run through an interpreter, but this is where the definition of "real programming language" comes into play.

The only sensible way to define a "real programming language" is as "a language to get real work done", but that really punts on the definition of "real", too. (It does, however, establish a distinction with esoteric programming languages, because nobody does real work, for example, in Malbolge, for any definition of "real" you could get ten people to agree upon.) And, compared to today, your choices of a programming language were much more limited by their implementation strategy and overhead (e.g. a runtime interpreter) in the past. However, even today, some languages are more "real" than others for certain applications and expected loads, it all depends on your requirements.

It sounds like your teacher has only experienced PHP through toy web applications (and maybe using 'application' is a stretch for what he's seen). Toy programs aren't real work. PHP definitely has a lot of problems, but I could not say it isn't a real programming language, except in jest.

Debugging is anticipated with distaste, performed with reluctance, and bragged about forever.
  — Dan Kaminsky

There is a certain association of "real" with "hard to do" (related to "real work") and your teacher may have been expressing this sentiment. This has always appeared to me as a form of bikeshedding (there's a better term for this exactly, but I can't remember it), where one's estimation of the value of a thing is related to the effort one had to put into it (e.g. a bikeshed is more important when I provided input on the color of the roof and whether it should have a sign). We intrinsically value our own effort more than that of others – just because we're familiar with it, if for no other reason – even when it doesn't make sense to do so. PHP, despite its faults, does make some things easy, and it and programs written in it can consequently be perceived as worth less.