当某人编写一种新的编程语言时,他们用什么来编写? [英] When someone writes a new programming language, what do they write it IN?

查看:113
本文介绍了当某人编写一种新的编程语言时,他们用什么来编写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请原谅我的无知.我迷上了PHP,专心致志地浏览SO,并且不得不问一个我多年来一直在想的问题:

Please excuse my ignorance. I'm dabbling in PHP and getting my feet wet browsing SO, and feel compelled to ask a question that I've been wondering about for years:

当您编写一种全新的编程语言时,您用用什么语言编写它?

When you write an entirely new programming language, what do you write it in?

对于你们所有的程序员来说,这听起来确实很愚蠢,对此我深表敬意,但这是一个困惑的小鸡.鸡蛋给我的东西.你做什么工作?对自己说今天我要发明一种新语言!然后启动...记事本?所有的编译器是否都建立在以前存在的语言之上,以至于一劳永逸地可以将曾经设计的所有编程语言都绘制到一棵巨大的分支树上,最终植根于……我不知道,这是古老的东西了吗?

This probably sounds really silly to all you programmers, for whom I have tremendous respect, but it's a perplexing chicken & egg thing to me. What do you do? Say to yourself Today I'm going to invent a new language! and then fire up... Notepad? Are all compilers built on previously existing languages, such that were one to bother one could chart all programming languages ever devised onto one monstrous branching tree that eventually grounded out at... I dunno, something old?

我的才智使我着迷……请教育我!

With my feeble intellect, I find this fascinating... Please, educate me!

推荐答案

这不是一个愚蠢的问题.这是一个很好的问题.

Its not a stupid question. Its an excellent question.

已经回答的简短答案是:另一种语言".

As already answered the short answer is, "Another language."

会引发一些有趣的问题吗?如果它是第一语言写的,那该怎么办? 您的特定硬件?对于在嵌入式设备上工作的人来说,这是一个非常现实的问题.正如已经回答的另一台计算机上的一种语言".实际上,某些嵌入式设备永远都不会获得编译器,它们的程序将始终在另一台计算机上进行编译.

Well that leads to some interesting questions? What if its the very first language written for your particular piece of hardware? A very real problem for people who work on embedded devices. As already answered "a language on another computer". In fact some embedded devices will never get a compiler, their programs will always be compiled on a different computer.

但是您可以将其进一步推回去.那第一个写过的程序呢?

But you can push it back even further. What about the first programs ever written?

第一批用于高级语言"的编译器将以所谓的汇编语言"编写.汇编语言是一种语言,其中该语言中的每个指令都对应于CPU的单个指令.它的语言水平很低,而且非常冗长且需要大量劳动.

Well the first compilers for "high level languages" would have been written in whats called "assembly language". Assembly language is a language where each instruction in the language corresponds to a single instruction to the CPU. Its very low level language and extremely verbose and very labor intensive to write in.

但是,即使编写汇编语言,也需要一个名为汇编程序的程序才能将汇编语言转换为机器语言".我们再回头.最早的汇编程序是用机器代码"编写的.完全由二进制数组成的程序,它与计算机本身的原始语言直接一一对应.

But even writing assembly language requires a program called an assembler to convert the assembly language into "machine language". We go back further. The very first assemblers were written in "machine code". A program consisting entirely of binary numbers that are a direct one-to-one correspondence with the raw language of the computer itself.

但是它仍然没有结束.即使其中只有 still 原始数字的文件也需要翻译.您仍然需要将这些原始编号存储在文件中.

But it still doesn't end. Even a file with just raw numbers in it still needs translation. You still need to get those raw numbers in a file into the computer.

无论您信不信由你,早期的计算机在其正面都有一排开关.翻转开关,直到它们代表二进制数,然后轻按另一个开关,然后将那个数字加载到计算机内存中.然后,您将继续轻弹切换,直到您加载了一个最小的计算机程序,该程序可以从磁盘文件或打孔卡中读取程序.您轻按了另一个开关,它开始运行程序. 80年代上大学时,我看到了具有这种能力的计算机,但从来没有承担过用交换机加载程序的工作.

Well believe it or not the early computers had a row of switches on the front of them. You flipped the switches till they represented a binary number, then you flicked another switch and that loaded that single number into the computers memory. Then you kept going flicking switched until you had loaded a minimal computer program that could read programs from disk files or punch cards. You flicked another switch and it started the program running. When I went to university in the 80's I saw computers that had that capacity but never was given the job of loading in a program with the switches.

甚至在此之前,计算机程序就必须使用插板进行硬接线!

And even earlier than that computer programs had to be hard wired with plug boards!

这篇关于当某人编写一种新的编程语言时,他们用什么来编写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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