“简单”的通用元语言节目

发布于 2024-10-06 20:47:06 字数 258 浏览 4 评论 0原文

我意识到不可能有一种语言适合所有情况。

但有一类简单的程序,其源代码在任何语言中看起来都几乎相同。

我想到的不仅仅是“你好世界”,还有算术,也许是字符串操作,你通常会在实用程序类中看到的基本内容。

我想将我的实用程序保留在这种元语言中,并将其自动翻译为一堆流行语言。我现在用手做这个。

再次强调,我并不要求翻译每一个可能的程序。我正在考虑一种非常有限、简单但超级可移植的语言。

你知道类似的事情吗?它有不应该存在的理由吗?

I realize that it is impossible to have one language that is best for everything.

But there is a class of simple programs, whose source code looks virtually identical in any language.

I am thinking not just "hello world", but also arithmetics, maybe string manipulation, basic stuff that you would typically see in utility classes.

I would like to keep my utilities in this meta-language and have it automatically translated to a bunch of popular languages. I do this by hand right now.

Again, I do not ask for translation of every single possible program. I am thinking a very limited, simple language, but superportable.

Do you know of anything like that? Is there a reason why it should not exist?

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

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

发布评论

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

评论(5

向日葵 2024-10-13 20:47:06

检查 Haxe 及其 维基百科页面。它是开源的,其主要目的就是您所描述的:仅从一个来源生成多种语言的代码。

Check Haxe, and its Wikipedia page. It's open source and its main purpose is what you describe: generating code in many languages from only one source.

空城仅有旧梦在 2024-10-13 20:47:06

几乎您选择的任何语言都将具有一些无法以自然方式映射到另一种语言的功能。我能想到的最接近的可能是 JavaScript 的一个有用的子集。当然,如果您是语言作者,您可以根据需要对其进行限制,只提供几乎任何语言都通用的结构(循环、条件等)。

出于可变性的目的,XML 表示形式是最好的,但你不想在其中编码。

Just about any language that you choose is going to have some feature that doesn't map to another in a natural way. The closest thing I can think of is probably a useful subset of JavaScript. Of course, if you are the language author you can limit it as much as you want, providing only constructs that are common to just about any language (loops, conditionals, etc.)

For purposes of mutability, an XML representation would be best, but you wouldn't want to code in it.

如歌彻婉言 2024-10-13 20:47:06

如果您发现没有通用语言,您可以尝试实用的模型驱动开发方法,使用基于模板的代码生成器。

在模板上,您保留算法的基本概念。然后,必要时可以使用一种或多种特定语言(C++、Java、JS、Python)为此算法添加代码。无论如何,无论您选择哪种语言或方法,您都必须这样做。配置开关将为您应用的任何模板选择正确的语言。

AtomWeaver 是一个代码生成器,可使用模板并采用 ABSE 作为建模方法。

If you find that there is no universal language, you can try a pragmatic model-driven development approach, using a template-based code generator.

On the template you keep the underlying concepts of an algorithm. Then, you would add code for this algorithm in one or more specific languages (C++,Java,JS,Python) when necessary. You would have to do it anyway, whatever the language or approach you choose. A configuration switch would pick the correct language for any template you apply.

AtomWeaver is a code generator that works with templates and employs ABSE as the modeling approach.

┈┾☆殇 2024-10-13 20:47:06

我做了一些查找,发现了这个。
https://www.indiegogo.com/projects/universal-programming-language
看起来很有趣

I did some looking and found this.
https://www.indiegogo.com/projects/universal-programming-language
looks interesting

笑咖 2024-10-13 20:47:06

经典的 Pascal 非常简单。 Oberon 是另一个类似的选择。或者您可以发明自己的衍生语言,类似于计算机科学教科书中的伪代码。将其中一种语言实现翻译成任何像样的现代命令式语言是微不足道的。

A classic Pascal is very simple. Oberon is another similar option. Or you could invent your own derivative language similar to the pseudocode from the computer science textbooks. It's trivial to implement a translator from one of that languages into any decent modern imperative language.

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