如何创建一个语言这些天? [英] How to create a language these days?

查看:94
本文介绍了如何创建一个语言这些天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要开始编写那种编程语言。你这几天孩子怎么做?我已经走出了十多年的循环;你在做什么不同的现在比我们回到前互联网,前窗口天?你知道,回到真正的编码器编码在C,使用命令行,并qu在哪个shell是优越的?

I need to get around to writing that programming language I've been meaning to write. How do you kids do it these days? I've been out of the loop for over a decade; are you doing it any differently now than we did back in the pre-internet, pre-windows days? You know, back when "real" coders coded in C, used the command line, and quibbled over which shell was superior?

只是为了澄清,我的意思,你设计一种语言(我可以很容易地找出来),但是你怎么建立编译器和标准库等等?

Just to clarify, I mean, not how do you DESIGN a language (that I can figure out fairly easily) but how do you build the compiler and standard libraries and so forth? What tools do you kids use these days?

推荐答案

自从打孔卡时代以来,一个新的考虑是虚拟机的存在充分提供标准库。针对JVM或.NET CLR而不是ye olde语言围墙花园为您节省了大量的引导。如果你正在创建一个编译语言,你也可能发现Java字节码或MSIL比机器代码更容易编译的目标(当然,如果你在这里是有趣的创建一个严格的优化编译器,那么你会看到作为一个bug而不是一个特性)。

One consideration that's new since the punched card era is the existence of virtual machines already bountifully provided with "standard libraries." Targeting the JVM or the .NET CLR instead of ye olde "language walled garden" saves you a lot of bootstrapping. If you're creating a compiled language, you may also find Java byte code or MSIL an easier compile target than machine code (of course, if you're in this for the fun of creating a tight optimising compiler then you'll see this as a bug rather than a feature).

在负面,JVM或CLR的成语可能不是你想要的语言。因此,您可能仍然最终构建标准库,只是为了在平台设施上提供惯用的接口。 (一个例子是,每种语言和它的狗似乎提供了自己的方法写入控制台,而不是让用户手动调用System.out.println或Console.WriteLine。)然而,它使一个增量开发的惯用图书馆,并且意味着越来越模糊的图书馆,你永远不会到建立惯用的接口,仍然可以访问,即使以丑陋的方式。

On the negative side, the idioms of the JVM or CLR may not be what you want for your language. So you may still end up building "standard libraries" just to provide idiomatic interfaces over the platform facility. (An example is that every languages and its dog seems to provide its own method for writing to the console, rather than leaving users to manually call System.out.println or Console.WriteLine.) Nevertheless, it enables an incremental development of the idiomatic libraries, and means that the more obscure libraries for which you never get round to building idiomatic interfaces are still accessible even if in an ugly way.

如果你考虑解释语言,.NET也支持通过动态语言运行时(DLR)进行高效解释。 (我不知道是否有一个等价的JVM。)这将有助于释放你专注于语言设计,而不必担心这么多的解释器的优化。

If you're considering an interpreted language, .NET also has support for efficient interpretation via the Dynamic Language Runtime (DLR). (I don't know if there's an equivalent for the JVM.) This should help free you up to focus on the language design without having to worry so much about the optimisation of the interpreter.

这篇关于如何创建一个语言这些天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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