创建域的多语言版本的最佳方法是什么?

发布于 2024-09-09 00:54:07 字数 121 浏览 2 评论 0原文

我想创建一组多种语言的域对象,以便我可以针对不同的平台。我一直在将外部 DSL 视为一种为我的领域定义语言的方法,然后可能编写适配器来为我感兴趣的目标语言生成代码。这是解决这个问题的最好方法吗?或者维护项目的多个版本是否更简单?

I would like to create a set of domain objects in multiple languages, so that I can target different platforms. I have been looking at external DSLs as a way to define a language for my domain, and then potentially writing adapters that generate code for the languages I'm interested in targeting. Is this the best way to solve this problem? Or is it just simpler to maintain multiple versions of the project?

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

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

发布评论

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

评论(4

誰認得朕 2024-09-16 00:54:07

我认为 Apache Thrift 可以满足您的要求。

I think that Apache Thrift delivers what you are asking for.

残月升风 2024-09-16 00:54:07

很抱歉回答晚了,但正如您提到 C# 是您的主要语言一样,这种几乎完全支持基于 Visual Studio 的技术正是您所寻找的。

您必须了解您想要用 DSL 抽象什么,但除此之外,多平台支持是微不足道的。

免责声明:这是我们的技术,但它是公开开放的,并且它完全解决了问题中提出的问题。

http://abstraction.codeplex.com/

注意!请注意当前下载的“alpha”阶段,我建议您跳过压缩下载并获取最新的源代码。我将在不久的将来更新更好的构造。查看“Production/Dev/AbstractionTemplate”解决方案中的“Context”实现。

Sorry for late answer, but as you mention C# being your main language, this practically fully supported Visual Studio based technology is exactly what you are looking for.

You have to understand what you want to abstract with your DSLs, but the multiple-platform support is trivial on top of that.

Disclaimer: This is our technology, but it's publicly open and it solves exactly the problem presented in the question.

http://abstraction.codeplex.com/

Note! Mind the very "alpha" stage of the current download, I suggest you skip the zipped download and grab the latest source. I am updating better construct in relatively near future. Check out the "Context" implementation in "Production/Dev/AbstractionTemplate" solution.

心在旅行 2024-09-16 00:54:07

如果不了解您打算使用 DSL 做什么,就很难提供帮助。

可移植性是您的主要问题吗?
为了成功地针对这些不同的平台,您可能必须无论如何维护特定于平台的层(无论是否生成)。

如果您计划在 DSL 中编写整个应用程序,然后使用您自己的编译器将其转换为每个平台的可运行代码,那么这很可能是一个坏主意,因为太复杂且过度设计。

然而,如果您有一个定义良好的独立于平台的逻辑块,那么 DSL 是一个不错的选择。只需在每个目标平台上为其编写一个解释器即可(假设性能并不关键,这也比生成代码更简单、更容易)。

It is difficult to be helpful without understanding what you are planning to use your DSL for.

Is portability your main problem here?
To succesfully target these different platforms, you will probably have to maintain plaftorm-specific layers anyway (generated or not).

If you plan to write your whole application in your DSL, then use your own compiler to transform it into runnable code for each platform, well it is most probably a bad idea, too complex and overengineered.

However, if you have a well-defined chunk of platform-independent logic, then a DSL is a good choice. Just write an interpreter for it on each target platform (provided that performance is not critical, this is also simpler and easier than generating code).

夏见 2024-09-16 00:54:07

创建域的多语言版本的最佳方法是什么?

这就是(曾经是?)模型驱动架构 (MDA) 的想法。引用维基百科的模型驱动架构

模型驱动架构方法
使用定义系统功能
平台无关模型(PIM)使用
适当的特定领域
语言(DSL)。

然后,给定平台定义
对应于CORBA的模型(PDM),
.NET、Web 等,PIM 是
翻译成一个或多个
特定于平台的模型 (PSM)
电脑可以运行。这需要
映射和转换以及
也应该建模。

PSM 可能使用不同的域
特定语言 (DSL),或
通用语言 (GPL),如
Java、C#、PHP、Python等一般自动化工具
执行此翻译。

根据您的域的复杂性和 MDA 工具的可用性,这可能是一个选项(实施成本较低)。

另请参阅

What is the best way to create multiple language versions of a domain?

This is (was?) somehow the idea of Model Driven Architecture (MDA). Quoting Model-driven architecture from Wikipedia:

The Model-Driven Architecture approach
defines system functionality using a
platform-independent model (PIM) using
an appropriate domain-specific
language (DSL).

Then, given a platform definition
model (PDM) corresponding to CORBA,
.NET, the Web, etc., the PIM is
translated to one or more
platform-specific models (PSMs) that
computers can run. This requires
mappings and transformations and
should be modeled too.

The PSM may use different Domain
Specific Languages (DSLs), or a
General Purpose Language (GPL) like
Java, C#, PHP, Python, etc. Automated tools generally
perform this translation.

Depending on the complexity of your domain and the availability of a MDA Tool, this might be an option (with a lower implementation cost).

See also

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