by rajaraodv

通过rajaraodv

JavaScript正在完善—解释 (JavaScript Is Turing Complete— Explained)

If you start learning functional programming in JavaScript, you’ll probably hear about lambda calculus, Turing machine, Turing complete and somehow “JavaScript is Turing complete”.

如果您开始学习JavaScript函数编程,您可能会听说有关lambda演算 , Turing机器 , Turing完成以及“ JavaScript是Turing完成”的信息。

But, no one seem to explain, in simple terms, what it actually means. What’s the relation b/w a Turing “machine” and JavaScript “language”? Also, most people use jargon to explain jargon like so:

但是,似乎没有人用简单的术语来解释其实际含义。 图灵“机器”和JavaScript“语言”之间的关系是什么? 同样,大多数人使用术语来解释术语,如下所示:

In computability theory, a system of data-manipulation rules (such as a computer’s instruction set, a programming language, or a cellular automaton) is said to be Turing complete or computationally universal if it can be used to simulate any single-taped Turing machine. The concept is named after English mathematician Alan Turing. A classic example is lambda calculus.

在可计算性理论中 ,如果可以将数据操纵规则系统(例如计算机的指令集 , 编程语言或元胞自动机 )用于模拟任何一种单带式Turing机器,则称该系统为Turing完整计算通用的 。 这个概念以英国数学家艾伦·图灵(Alan Turing )的名字命名。 一个典型的例子是lambda演算 。

So this is my attempt at explaining these comcepts simply.

因此,这是我试图简单解释这些概念的尝试。

图灵机 (Turing Machines)

Back in the day, people wanted to know how to create a machine that could do all the calculations they were doing by hand. They wanted to know how to build such a machine and how it might work.

过去,人们想知道如何创建一台可以手动完成所有计算的机器。 他们想知道如何构建这样的机器,以及它如何工作。

Alan Turing came up with a hypothetical machine that could take any program of any complexity and run it. It could be implemented using a simple tape, a head that moves left and right, could store data by reading, writing, and erasing the contents of square cells. Given long enough tape and enough time, it could compute any program.

艾伦·图灵(Alan Turing)提出了一个假设的机器,该机器可以采用任何复杂程度的程序并运行它。 它可以使用简单的磁带来实现,磁带可以左右移动,可以通过读取,写入和擦除方形单元格的内容来存储数据。 给定足够长的磁带和足够的时间,它就可以计算任何程序。

In other words, he explained how someone can build a computer. And called the computer a “Turing machine”

换句话说,他解释了某人如何构建计算机。 并将计算机称为“图灵机”

Trivia: Back in Alan Turing’s days, the word “Computer” meant the person who manually computes programs (not the machines) :)

琐事:在艾伦·图灵(Alan Turing)时代,“计算机”一词是指手动计算程序的人(而不是机器):)

如此强大但如此简单 (So powerful yet so simple)

Turing machines soon became very popular, and eventually a standard because while they provided a powerful mechanism to calculate anything, they were also easy to understand. As described in the video below, Turing machines use a tape to keep track of states and run computations.

图灵机很快变得非常流行,并最终成为一种标准,因为它们虽然提供了强大的机制来计算任何东西,但也很容易理解。 如以下视频所述,图灵机使用磁带来跟踪状态并运行计算。

“单”对“多”带图灵机 (“Single” Vs “Multi” Tape Turing Machines)

One other jargon you’ll hear about Turing machines is the concept of “single” tape.

关于图灵机,您还将听到的另一行话是“单”带的概念。

The initial version of the Turing machine had just a long single tape. Later on, people came up with the concept of “multiple” tape Turing machines that used two to five tapes. Multi-tape Turing machines were not any more powerful than single-tape ones, but they helped to simplify programs.

图灵机的初始版本只有一长条磁带。 后来,人们想到了使用两到五个磁带的“多”磁带图灵机的概念。 多带图灵机没有单带机强大,但它们有助于简化程序。

So explicitly saying “single” tape isn’t necessary.

因此,无需明确地说出“单个”磁带。

图灵完成 (Turing Complete)

If a physical machine (like a computer) or virtual machine, which is a software, (like JavaVM) can take any program and run it just like a Turing machine, then that machine is called “Turing Complete”. PS: It’s kind of a certification.

如果物理机(如计算机)或虚拟机(即软件)(如JavaVM)可以采用任何程序并像图灵机一样运行它,则该计算机称为“图灵完备”。 PS:这是一种认证。

示例:图灵完整版与图灵不完整机 (Examples: Turing complete Vs Turing incomplete machine)

A calculator is a good example of a Turing incomplete machine because it can only perform a small pre-defined subset of calculations.

计算器是图灵不完整机器的一个很好的例子,因为它只能执行小的预定义计算子集。

However a home computer (Mac or a PC) is a Turing complete machine because it can do any calculation that a Turing machine can do if we give it enough memory and time.

但是,家用计算机(Mac或PC)是图灵完整的计算机,因为如果我们给它足够的内存和时间,它可以执行图灵计算机可以执行的任何计算。

“ JavaScript正在完成图灵” (“JavaScript Is Turing Complete”)

If you think about it, a Turing machine is just a concept — it means that any “thing”(physical or virtual) that takes any program and run it is essentially a Turing Machine. And if that “thing” can run every program that a “Turing Machine” can run, then it is called “Turing Complete”.

如果您考虑一下,图灵机只是一个概念-它意味着需要任何程序并运行它的任何“ 事物 ”(物理的或虚拟的)本质上都是图灵机。 如果该“事物”可以运行“ Turing Machine”可以运行的每个程序,则称为“ Turing Complete”。

Now if you think about any modern programming language, they also take programs(written by us) as input and run them. Further, any program that can be theoretically written to run for a Turing machine can also be written in JavaScript. Thus, JavaScript is Turing complete.

现在,如果您考虑使用任何现代编程语言,它们也将程序(由我们编写)作为输入并运行它们。 此外,理论上可以编写为图灵机运行的任何程序也可以用JavaScript编写。 因此,JavaScript已完成。

That’s it!

而已!

??? If you like this post, please 1. ❤❤❤ it below on Medium and 2. please share it on Twitter. You may retweet the below card???

??? 如果您喜欢这篇文章,请1.下面的Medium中进行 ❤❤❤然后2.在Twitter上分享。 您可以转发以下卡吗???

我的其他帖子 (My Other Posts)

LATEST: Functional Programming In JS — With Practical Examples (Part 1)

最新: JS中的函数式编程—带有实际示例(第1部分)

功能编程 (Functional Programming)

  1. JavaScript Is Turing Complete — Explained

    JavaScript正在完善–解释

  2. Functional Programming In JS — With Practical Examples (Part 1)

    JS中的函数式编程—结合实际示例(第1部分)

ES6 (ES6)

  1. 5 JavaScript “Bad” Parts That Are Fixed In ES6

    ES6中修复的5个JavaScript“不良”部分

  2. Is “Class” In ES6 The New “Bad” Part?

    ES6中的“类”是新的“不良”部分吗?

Web包装 (WebPack)

  1. Webpack — The Confusing Parts

    Webpack —令人困惑的部分

  2. Webpack & Hot Module Replacement [HMR] (under-the-hood)

    Webpack和热模块更换[HMR] (在内部)

  3. Webpack’s HMR And React-Hot-Loader — The Missing Manual

    Webpack的HMR和React-Hot-Loader —缺少的手册

Draft.js (Draft.js)

  1. Why Draft.js And Why You Should Contribute

    为什么选择Draft.js以及为什么您应该贡献力量

  2. How Draft.js Represents Rich Text Data

    Draft.js如何表示富文本数据

React And Redux: (React And Redux :)

  1. Step by Step Guide To Building React Redux Apps

    构建React Redux应用程序的逐步指南

  2. A Guide For Building A React Redux CRUD App (3-page app)

    构建React Redux CRUD应用程序指南 (3页应用程序)

  3. Using Middlewares In React Redux Apps

    在React Redux应用程序中使用中间件

  4. Adding A Robust Form Validation To React Redux Apps

    向React Redux应用添加强大的表单验证

  5. Securing React Redux Apps With JWT Tokens

    使用JWT令牌保护React Redux应用程序

  6. Handling Transactional Emails In React Redux Apps

    在React Redux应用程序中处理交易电子邮件

  7. The Anatomy Of A React Redux App

    React Redux应用程序剖析

销售队伍 (Salesforce)

  1. Developing React Redux Apps In Salesforce’s Visualforce

    在Salesforce的Visualforce中开发React Redux应用程序

Thanks for reading!

谢谢阅读!

翻译自: https://www.freecodecamp.org/news/javascript-is-turing-complete-explained-41a34287d263/

JavaScript正在完善—解释相关推荐

  1. 在CodeMash 2012的“ Wat”演讲中提到的这些怪异JavaScript行为的解释是什么?

    本文翻译自:What is the explanation for these bizarre JavaScript behaviours mentioned in the 'Wat' talk fo ...

  2. JavaScript类型强制解释

    by Alexey Samoshkin 通过阿列克谢·萨莫什金(Alexey Samoshkin) JavaScript类型强制解释 (JavaScript type coercion explain ...

  3. JavaScript Onclick事件解释

    The onclick event in JavaScript lets you as a programmer execute a function when an element is click ...

  4. javascript 询问_JavaScript解释引擎

    看完本文,你就可以理解下面两个实例的原理. fun() console.log(num)function fun() {num = 20 }// output: 20 var num = 10 fun ...

  5. JavaScript 正则表达式 通俗解释 快速记忆

    1.正则表达式中最重要的三个符号: 1.1 B 在正则表达式中B有3种类型的括号: 1.1.1 方括号 "[". 方括号"["内是需要匹配的字符.中括号括住的内 ...

  6. javascript函数式_JavaScript中的函数式编程—结合实际示例(第1部分)

    javascript函数式 by rajaraodv 通过rajaraodv JavaScript中的函数式编程-结合实际示例(第1部分) (Functional Programming In Jav ...

  7. ES6中修复的5个JavaScript“不良”部分

    by rajaraodv 通过rajaraodv ES6中修复的5个JavaScript"不良"部分 (5 JavaScript "Bad" Parts Tha ...

  8. javascript函数式_JavaScript中的函数式编程—结合实际示例(第2部分)

    javascript函数式 by rajaraodv 通过rajaraodv JavaScript中的函数式编程-结合实际示例(第2部分) (Functional Programming In Jav ...

  9. 终端打开后-bash_如何爵士化Bash终端-带有图片的分步指南

    终端打开后-bash by rajaraodv 通过rajaraodv In this blog I'll go over the steps to add Themes, Powerline, fo ...

最新文章

  1. R的一些统计分析包工具
  2. 组策略部署软件----将部署的软件分类
  3. Java异常机制及异常处理建议
  4. 和Java相关的书籍,想成为架构师的请收藏一下啊
  5. 在UltraWebGrid单元格中绑定dropdownlist
  6. 二维数组各行分别求和_【PyTorch入门】之十分钟看懂二维卷积层的运算、实现及应用...
  7. mybatis中SqlSession一定要关闭
  8. 资深系统管理员给Linux/Unix新人们的建议
  9. hive遍历_Hive解析流程-抽象语法树生成
  10. 命名实体识别(NER)资料收集
  11. 看我!挖到了一个3万美元的 Instagram 漏洞
  12. 《数据库原理MySQL》第三次上机实验
  13. WDM驱动inf模板
  14. 劳易测BPS300i SM 100条码定位
  15. java中dl列表_Java DLFolder.getFolderId方法代码示例
  16. 谜一样的科学家——阿兰图灵
  17. MATLAB——KNN分类器实例
  18. 技术团队建设总结(一)
  19. C语言中-条件编译#ifdef的妙用详解_透彻
  20. Java泛型中的桥方法(Bridge Method)

热门文章

  1. 子查询 不同情况 mysql
  2. 动态数组相关操作 0104 ArrayList
  3. dj鲜生-35-设置django的session使用redis来存储
  4. 爬虫-cookie与session的功能与用途
  5. mysql-数据库的增删切换使用等操作
  6. jquery - 正则表达式
  7. elasticsearch查询文档数量
  8. MySQL 大表优化方案,收藏了细看!
  9. 如何绘制吞吐率曲线图
  10. 实现可折叠的分组tableview