什么是“真实"?编程语言? [英] What is a "real" programming language?

查看:79
本文介绍了什么是“真实"?编程语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近有一位老师说PHP 不是真正的编程语言",但在我看来,这只是给出了无力的理由:

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

  • 未编译.
  • 这是脚本化的.
  • 它不会在所有平台上运行.

PHP 不被视为真正的"编程语言吗?什么是真正的"编程语言?一种语言必须经过编译才能被认真对待吗?

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

两天前,我在学校的 A-Level 计算机课上上了一节入门课–我们在课程的第一年使用 Java.我不熟悉 Java,但对一般编程基础知识(变量、函数、面向对象、循环等)有很好的掌握.

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.).

我们的第一个任务老师完成得快得离谱.她没有费心去解释任何概念,它们是如何工作的,或者你将它们实际用于什么,并且似乎很高兴看到大多数学生(总的来说,他们是编程新手)蠕动在他们的座位上,对她在说什么一无所知.事后看来,我认为她以惊人的速度完成了它,看看谁能真正处理"计算机 A-Level,因为学生仍有机会在 9 月开始之前改变他们的科目.

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.

第一个也是唯一的任务是编写一个 Java 命令行应用程序来将二进制转换为十进制(十进制).我们有一个两小时的品尝会来做这件事,在解释了二进制系统的工作原理之后,我们不得不开始,尽管总的来说,没有人真正有最模糊的想法从哪里开始.一个小时后,有些人比其他人走得更远,但没有人真正取得任何重大成就.老师自己也糊涂了,她叫来了隔壁的另一位老师.他过来帮助人们,看看下一步该去哪里.

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.

不吹牛,我可能确实是班上经验最多的人,并且在练习中走得最远.他问我以前是否有过任何经验;我说是的,尤其是在 PHP 中,并开玩笑地评论说我可以写一些东西,只需几行 PHP 就可以将二进制转换为 denary,而 Java 应用程序正在迅速成长为几屏代码.

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.

他回答说:PHP 不是真正的编程语言!"...!经过一番讨论,他给出了上述三个原因.但是,我指出您可以在任何运行 Apache 的平台上运行 PHP,但我认为他并不真正了解 Apache 是什么,而且一无所知!

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!

推荐答案

首先我们需要知道什么是编程语言.至少,编程语言是计算机读取并指示其执行某些操作.许多人还希望通用编程语言图灵完备.然而,在某些情况下,域特定语言不是图灵完备的,但仍然是用于该特定领域的一种有用的编程语言.编程语言可以被编译或解释,并且它们可以在多种平台或仅一种特定平台上运行.不同的需求需要不同的编程语言.显然,PHP 是一种编程语言.

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.

我对真正的"编程语言的定义是在现实世界中至少具有一种实际用途的任何编程语言.这与通常没有实际用途的深奥的编程语言相反.由于 PHP 被广泛用于解决实际问题,因此它很容易满足成为真正编程语言的要求,尽管它可以说不是一种特别漂亮的语言.

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 是一种实用语言.它是出于能够快速制作网页(该名称最初代表个人主页)的特定需求而创建的,并且根据需要扩展了语言.由于没有理论背景或强大的设计原则来推动它的创建(甚至没有语言的正式规范),它不像许多其他更现代的语言那么干净.诸如正确处理外来字符/unicode 字符之类的功能显然是在之后添加的,并且没有与语言的其余部分完全集成.这种不整洁和缺乏理论严谨性导致许多人(尤其是学者)不喜欢该语言,这可能是您的老师不将 PHP 视为真正"语言的部分原因.

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.

然而,PHP 擅长于它的设计目的,许多网站都在使用它,甚至是像 Facebook、雅虎这样的大型网站!和维基百科.

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

这篇关于什么是“真实"?编程语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆