翻译成Javascript的语言?

时间:2022-09-22 20:42:28

Another post questioned how practical it is to compile languages into Javascript. Practicality aside, what interpreters translate from some language X to Javascript and were implemented in Javascript? I'm especially interested in the cases where X wasn't designed with the intention of targeting Javascript. Even if the interpreter isn't totally finished I'd like to hear about it.

另一篇文章质疑将语言编译成Javascript有多实际。除了实用性之外,从某种语言X翻译到Javascript的解释器是用Javascript实现的吗?我特别感兴趣的是X不是以Javascript为目标设计的。即使翻译没有完全完成,我也想听听。

You may be curious about the motivation for this question. Javascript certainly can't leverage as much power as assembler, but the flexibility for code distribution and execution may sometimes outweigh that cost.

你可能对这个问题的动机感到好奇。Javascript当然不能像汇编器那样充分利用功能,但代码分发和执行的灵活性有时可能会超过成本。

One use case for these interpreters is a model for teaching and learning programming languages. Consider how useful it is to have a Javascript interpreter in the interactive book Eloquent Javascript. Sure, there may be a performance hit over compiling it natively, but in some situations the cost is certainly worth it. And yes, I realize it's always an option to rely on the server to compile or interpret code, but I'm specifically interested in client-side approaches.

这些解释器的一个用例是用于教学和学习编程语言的模型。考虑一下在交互式书籍中有一个Javascript解释器是多么有用。当然,本地编译可能会对性能造成影响,但在某些情况下,这样做的代价是值得的。是的,我知道依赖服务器编译或解释代码总是一个选项,但我对客户端方法特别感兴趣。


UPDATE: A lot of responses include references to compilers that weren't implemented in Javascript. I just want to stress that the interpreter itself should be implemented in Javascript so that both it and the source language code could run on the browser on your grandparent's computer.

更新:许多响应包括对未在Javascript中实现的编译器的引用。我只想强调,解释器本身应该用Javascript实现,以便它和源语言代码都可以在祖父母的计算机上的浏览器上运行。

7 个解决方案

#1


4  

  • Objective-J is a language that basically takes the "Objective" part of Objective-C and glues it to ECMAScript
  • Objective- j是一种语言,它将Objective- c的"部分粘到ECMAScript上
  • Clamato is a Smalltalk-inspired language for client-side web scripting
  • Clamato是一种受小型会话启发的客户端web脚本语言

See also this question: Are there other languages than Objective-J that get “compiled” to JavaScript in the browser?

还可以看到这个问题:除了Objective-J之外,还有什么语言可以在浏览器中“编译”到JavaScript ?

#2


6  

CoffeeScript is a programming language that compiles to JavaScript.

CoffeeScript是一种编译为JavaScript的编程语言。

#3


4  

Community Wiki, let's mash this out :-)

社区维基,让我们结合这个:

jsc - re-compiles from CIL (CIL compiled from VB.NET, C#, etc.)

jsc -从CIL重新编译(CIL从VB编译)。净、c#等)。

Script# - compiles from C# (source-code).

脚本# -从c#(源代码)编译。

GWT: Google Web Toolkit - compiles from Java.

GWT:谷歌Web Toolkit -从Java编译。

Emscripten - compiles from LLVM. Should be able to work (Language X)->LLVM->JavaScript, minus issues, where Language X has an LLVM compiler.

从LLVM编译。应该能够工作(语言X)->LLVM->JavaScript,减去问题,其中语言X有一个LLVM编译器。

#4


2  

some more or less toy interpreters in pure javascript

一些或多或少是纯javascript的玩具解释器

and of course the obligatory

当然还有义务

#5


1  

j2js compiles Java bytecode to Javascript (e.g., Java, Scala, etc.).

j2js将Java字节码编译成Javascript(例如,Java、Scala等)。

#6


1  

List of languages that compile to JS

编译成JS的语言列表

#7


0  

Pyjamas can compile Python to JavaScript. That's a server-type translation; Pyjamas has not yet been used to compile itself so there is no JavaScript Python interpreter.

Pyjamas可以将Python编译为JavaScript。这是一个服务器类型的翻译;Pyjamas尚未编译,因此没有JavaScript Python解释器。

#1


4  

  • Objective-J is a language that basically takes the "Objective" part of Objective-C and glues it to ECMAScript
  • Objective- j是一种语言,它将Objective- c的"部分粘到ECMAScript上
  • Clamato is a Smalltalk-inspired language for client-side web scripting
  • Clamato是一种受小型会话启发的客户端web脚本语言

See also this question: Are there other languages than Objective-J that get “compiled” to JavaScript in the browser?

还可以看到这个问题:除了Objective-J之外,还有什么语言可以在浏览器中“编译”到JavaScript ?

#2


6  

CoffeeScript is a programming language that compiles to JavaScript.

CoffeeScript是一种编译为JavaScript的编程语言。

#3


4  

Community Wiki, let's mash this out :-)

社区维基,让我们结合这个:

jsc - re-compiles from CIL (CIL compiled from VB.NET, C#, etc.)

jsc -从CIL重新编译(CIL从VB编译)。净、c#等)。

Script# - compiles from C# (source-code).

脚本# -从c#(源代码)编译。

GWT: Google Web Toolkit - compiles from Java.

GWT:谷歌Web Toolkit -从Java编译。

Emscripten - compiles from LLVM. Should be able to work (Language X)->LLVM->JavaScript, minus issues, where Language X has an LLVM compiler.

从LLVM编译。应该能够工作(语言X)->LLVM->JavaScript,减去问题,其中语言X有一个LLVM编译器。

#4


2  

some more or less toy interpreters in pure javascript

一些或多或少是纯javascript的玩具解释器

and of course the obligatory

当然还有义务

#5


1  

j2js compiles Java bytecode to Javascript (e.g., Java, Scala, etc.).

j2js将Java字节码编译成Javascript(例如,Java、Scala等)。

#6


1  

List of languages that compile to JS

编译成JS的语言列表

#7


0  

Pyjamas can compile Python to JavaScript. That's a server-type translation; Pyjamas has not yet been used to compile itself so there is no JavaScript Python interpreter.

Pyjamas可以将Python编译为JavaScript。这是一个服务器类型的翻译;Pyjamas尚未编译,因此没有JavaScript Python解释器。