Abstract (programming) language built to transpile.

huangapple go评论90阅读模式
英文:

Abstract (programming) language built to transpile

问题

以下是您要翻译的内容:

简介

我经常遇到这样的情况:一个库是用特定的编程语言编写的。如果我想在同一种语言中使用该库,那太好了,但如果我想使用不同的语言,那将是个问题(这并不意味着可能有一种更或多或少的巧妙方法)。对于某些库,我有这样的感觉,它们之所以用特定的编程语言编写,仅仅是因为任何语言都可以胜任(以及作者的个人偏好),这意味着没有使用特定语言的高级外部第三方库。对于这些情况,我认为如果存在某种抽象(编程)语言,库的作者可以在其中指定算法,然后可以将其转译成许多其他编程语言。因此,如果我想使用该库,我可以简单地使用转译器将该库转换为我选择的语言。

实际问题

所以我正在寻找的是一种专门用于转译成大多数流行编程语言(例如Java、C/C++、Python)的语言。我想知道是否有人已经付出了努力来创建这样一种“通用”的转译语言。

请注意,我寻找从一种语言到另一种语言的特定转译器。我想知道是否存在一种(编程)语言,已经被设计成可以被转译成许多不同的实际编程语言的源代码。因此,我正在寻找的语言可能甚至无法自行运行(只有转译后的代码才是实际的程序)。

尽管我会对这种语言的存在感兴趣的一般优点/缺点,但这也不是这个问题的重点,因为这里是SO的规则。因此,我要求您不要以这种方式写基于意见的答案。

这个问题的答案很可能是没有这样的语言,但由于我的研究没有找到任何线索,我想也许这里有人知道这样一种语言,因为它可能因为不被广泛使用而被我忽略了。

英文:

Introduction

Oftentimes I encounter a situation in which a library has been written in a particular programming language. That's great, if I want to use the library in the same language, but if I want to use a different language, that's going to be a problem (that doesn't mean that there might be a more or less hacky way).
For some libraries I have the feeling that they have been written in that particular programming language, simply because any language will do (and because of personal preference of the author) meaning that no language-specific high-level external 3rdparty-libraries are being used. For these situations I thought that it would be neat, if there was some sort of abstract (programming) language in which the library author can specify the algorithms, but which can then be transpiled into a lot of other programming languages. Thus if I want to use that library, I can simply use the transpiler to get that library in my language of choice.


Actual question

So what I am looking for is a language, that is specifically meant to be transpiled into most popular languages (e.g. Java, C/C++, Python). I'm interested in whether someone has gone through the effort of creating such a "universal" transpiler language before.

Note that I'm not looking for a particular transpiler from one language to another. I want to know whether there exists a (programming) language that has been designed for being transpilable into source code of a lot of different actual programming languages. Thus the language I'm looking for would probably not even run by itself (only the transpiled code would be an actual program).
Although I would be interested to hear general pros/cons for the existence of such a language, this is also not what this question is about due to the rules here on SO. Therefore I'd ask you, to not write opinion-based answers in this kind of style.

The answer to this question might very well be that there is no such language, but as my recherche hasn't brought anything up, I thought that maybe someone here knows of such a language, that I might have missed due to it not being widely used.

答案1

得分: 4

一种旨在被转译成其他各种语言的语言是Haxe。目前支持生成以下语言的源代码:

  • JavaScript
  • ActionScript 3
  • PHP(包括PHP7)
  • C++
  • Java
  • C#
  • Python
  • Lua

(参考:https://haxe.org/documentation/introduction/compiler-targets.html)

它还支持直接编译成特定虚拟机的字节码。

英文:

One language that was designed with the intention of being transpiled to various other languages is Haxe
At the time of writing it supports generating source code for:

  • JavaScript
  • ActionScript 3
  • PHP (including PHP7)
  • C++
  • Java
  • C#
  • Python
  • Lua

(reference: https://haxe.org/documentation/introduction/compiler-targets.html)

It also supports compiling directly to byte code for specific VMs

huangapple
  • 本文由 发表于 2020年1月7日 02:15:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/59616963.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定