编译为 C/C++ 的编程语言来源?

发布于 2024-11-17 13:21:04 字数 178 浏览 4 评论 0原文

我使用 CoffeeScript 来简化 JavaScript 开发。它是一种语法清晰的语言,可以编译成 JavaScript。

那么,有哪些已建立的编程语言可以编译为 C/C++ 源代码,以简化语法和/或增强功能?

I'm using CoffeeScript to make JavaScript development easier. It's a language with clean syntax that compiles into JavaScript.

So, what are the established programming languages that compile into C/C++ source code, to simplify syntax and/or enhance functionality?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(14

神经大条 2024-11-24 13:21:05

ValaGenie 是以下语言:使用 GObject 类型系统并编译为 C 代码。我从未使用过它们,但它们看起来很有趣。 GObject 是 GTK 使用的类型系统,但我相信它与 GTK 是分开的。

Vala and Genie are languages that use the GObject type system and compile to C code. I've never used them but they look interesting. GObject is the type system used by GTK but I believe it's separable from GTK.

雨轻弹 2024-11-24 13:21:05

GHC(Glasgow Haskell 编译器) 曾经有一个选项 (-fvia-c) 来编译为 C。

我相信从 v7 开始,LLVM 用于生成本机代码而不是通过外部 C 编译器。

GHC (the Glasgow Haskell Compiler) used to have an option (-fvia-c) to compile to C.

I believe that starting with v7 however, LLVM is used to generate native code instead of going via an external C compiler.

暮光沉寂 2024-11-24 13:21:05

OOC 很新,但相当不错。

OOC is very new but quite nice.

晚雾 2024-11-24 13:21:05

HipHop 可以将 PHP 程序转换为 C++。

There's HipHop, which transforms PHP programs to C++.

绝情姑娘 2024-11-24 13:21:05

引用 Qt 文档:

元对象编译器 moc 是处理 Qt 的 C++ 扩展的程序。
moc 工具读取 C++ 头文件。如果它找到一个或多个包含 Q_OBJECT 宏的类声明,它会生成一个包含这些类的元对象代码的 C++ 源文件。除此之外,信号和槽机制、运行时类型信息和动态属性系统都需要元对象代码。
moc生成的C++源文件必须与类的实现进行编译和链接。

所以这有点像 C++ 变成了 C++,我不确定它是否符合您的需求。

Quoting Qt documentation:

The Meta-Object Compiler, moc, is the program that handles Qt's C++ extensions.
The moc tool reads a C++ header file. If it finds one or more class declarations that contain the Q_OBJECT macro, it produces a C++ source file containing the meta-object code for those classes. Among other things, meta-object code is required for the signals and slots mechanism, the run-time type information, and the dynamic property system.
The C++ source file generated by moc must be compiled and linked with the implementation of the class.

So it's kind of C++ getting turned into C++, I'm not sure if it fits in what you are looking for.

随遇而安 2024-11-24 13:21:05

编程语言 IBM Informix 4GL 经过多步转换为 C 代码,然后对其自身的运行时库、ESQL/C(C 中的嵌入式 SQL)运行时库以及系统的 C 库进行编译和链接。

  • program.4gl - 原始源代码
  • program.4ec - 带有嵌入式 ESQL/C 和扩展输入操作的 C 代码
  • program.ec - 带有嵌入式 ESQL/C 和扩展输入操作的 C 代码嵌入式 ESQL/C
  • program.c - 纯 C 代码
  • program.o - 目标代码
  • program - 可执行文件

.4ec 阶段是一种历史偶然;最初,ESQL/C 编译器同时处理扩展输入操作和 ESQL/C,但是当从 ESQL/C 编译器中删除扩展操作时(当 ESQL/C 库和编译器被显着重写时),扩展输入操作通过从原始 ESQL/C 编译器中提取处理该问题的代码来处理。

有相当多的人编写了代码生成器,可以从另一种语言编写 I4GL 源代码,或者在将密切相关的源代码提交给 I4GL 编译器之前将其预处理为 I4GL。

The programming language IBM Informix 4GL goes through a multi-step transformation to C code, which is then compiled and linked with its own runtime library, the ESQL/C (Embedded SQL in C) runtime libraries, and the system's C libraries.

  • program.4gl - original source code
  • program.4ec - C code with embedded ESQL/C and extended input operations
  • program.ec - C code with embedded ESQL/C
  • program.c - pure C code
  • program.o - object code
  • program - executable

The .4ec phase is a sort of historical accident; originally, the ESQL/C compiler handled both the extended input operations and the ESQL/C, but when the extended operations were removed from the ESQL/C compiler (when the ESQL/C library and compiler was significantly rewritten), the extended input operations were handled by carving out the code that handled that from the original ESQL/C compiler.

A fair number of people have written code generators which write I4GL source from another language, or which preprocess a closely related source code into I4GL before it is submitted to the I4GL compiler.

无边思念无边月 2024-11-24 13:21:05

Embeddable Common Lisp (ECL) 可以将 Common Lisp 编译为 C。

Embeddable Common Lisp (ECL) can compile Common Lisp to C.

︶ ̄淡然 2024-11-24 13:21:05

我想你可以为 LLVM 编写一个 C 后端,然后你可以将几乎任何东西转换为 C,但更深层次的问题是“为什么?”今天没有任何工具可以做到这一点的原因是,如果您要编译为 C,为什么不一路走下去并以某种中间机器代码语言为目标呢? (例如,LLVM 或 JVM)

现在,在过去,编译为 C 的想法更有道理,因为缺乏像样的 vm 语言,但今天没有太多充分的理由这样做。也就是说,您仍然可以找到大量采用某些解释语言并尝试将它们编译为 C/C++ 的项目。例如,以下是一个 Python 到 C++ 的编译器:

http://shed-skin.blogspot.com/

I suppose you could write a C backend for LLVM, then you could translate pretty much anything down to C, but the deeper question would be "why?" The reason that there aren't any tools that do this today is that if you are going to compile down to C, why not go all the way and target some intermediate machine code language instead? (For example, LLVM or the JVM)

Now in the older days, the idea of compiling down to C was a bit more defensible, since there was a lack of decent vm languages, but today there are not too many good reasons to do it. That said, you can still find plenty of projects around which take certain interpreted languages and try to compile them down to C/C++. For example, here is a python to C++ compiler:

http://shed-skin.blogspot.com/

于我来说 2024-11-24 13:21:05

有人可能会说,由于大多数主要编程语言都是图灵完备,因此它们实际上是等效的并且编写的程序它们之间可以互相翻译。

也就是说,正如其他人所提到的,有相当多的语言有(或在开发早期曾经有)生成 C 代码的后端,因为这消除了语言实现中二进制代码生成所涉及的复杂性。这绝不意味着(双关语无意)所述代码实际上是可读的 - 它只是比其编译形式更具可读性。

至于我对该列表的贡献,lexyacc “程序”(如果它们可以被认为是这样的话)通常被转换成 C 代码 - 一个可怕的、混乱的混乱,但仍然是 C 代码。 ..

One could argue that since most major programming languages are Turing-complete, they are actually equivalent and programs written in them can be translated into each other.

That said, as other people have mentioned, there are quite a few languages for which there are (or used to be, early in their development) backends that produce C code, since that removed the complexities involved in binary code generation from the language implementation. That does not by any means mean (pun unintended) that said code was actually readable - it was just more readable than its compiled form.

As for my contribution to the list, lex and yacc "programs" (if they can be considered that) are typically transformed into C code - a horrible, tangled mess of it, but C code nonetheless...

清风不识月 2024-11-24 13:21:05

我听说 clang 可以将 C++ 编译为 C。不过,我怀疑这会“简化”任何东西。

I hear that clang can compile C++ into C. I doubt that would "simplify" anything, though.

预谋 2024-11-24 13:21:05

Oracle 的 PRO*C/C++ 是一种嵌入式 SQL 语言。它允许在 C/C++ 中包含 SQL 语句,该语句由预编译器处理,该预编译器用对所需 C/C++ SQL 库的函数调用替换嵌入式 SQL 语句。预编译器的输出是标准 C/C++,然后可以将其编译为可执行文件。

http://en.wikipedia.org/wiki/Pro*C
http://download.oracle.com/docs/cd /B19306_01/appdev.102/b14407/toc.htm

Oracle's PRO*C/C++ is an embedded SQL language. It allows the inclusion of SQL statements in C/C++ which is processed by a precompiler that replaces the embedded SQL statements with function calls to the needed C/C++ SQL libraries. The output from the precompiler is standard C/C++ which can then be compiled to an executable.

http://en.wikipedia.org/wiki/Pro*C
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14407/toc.htm

明媚如初 2024-11-24 13:21:05

Matlab(嵌入式Matlab)的子集可以编译为C。您需要嵌入式编码器工具箱。

A subset of Matlab (Embedded Matlab) can be compiled to C. You need the embedded coder toolbox.

甜味超标? 2024-11-24 13:21:05

大多数语言都可以用来生成 C 代码,但这实际上取决于您想要做什么。您真的希望能够阅读代码吗?您只是想创建 Windows 应用程序吗?

如果您正在寻找一种易于学习的通用语言,Python 始终是一个不错的选择,它可以完成 C/C++ 可以做的所有事情。

Most languages can be used to generate C code, but it really depends what you're trying to do. Do you actually want to be able to read the code? Are you just trying to create Windows applications?

If you're looking for a universally useful language that's easy to learn, Python is always a good choice, and it can do everything that C/C++ can.

北音执念 2024-11-24 13:21:04

语言 Haxe 可以输出到 C++、C#、Java、JavaScript、Python(实验)、PHP、Flash 和 NekoVM。

The language Haxe can output to C++, C#, Java, JavaScript, Python(experimental), PHP, Flash and NekoVM.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文