Jetbrains 和 Jetbrains 之间的主要区别是什么? MPS 和 Eclipse Xtext?

发布于 2024-08-28 08:24:19 字数 593 浏览 5 评论 0原文

我在几个项目中使用了Eclipse Xtext。我喜欢在 Ecore(元)模型上轻松定义语法,并让一切为您生成,包括很棒的 Eclipse 插件编辑器,但我对底层的 EMF 框架,所有内容都硬连线在静态字段中。

最近我遇到了 Jetbrains 的 MPS(元编程系统)。它基于完全不同的哲学。 Xtext 用于创建基于文本的 DSL,为您生成解析器(并实例化这些 EObject),而在 MPS 创建的语言中,可以直接编辑底层模型结构。到目前为止我明白了。

有没有人使用这两种 DSL 工具的经验来指出它们在使用、预期用例和受众、复杂性、学习曲线方面的主要差异(说实话,要开始使用 Xtext,应该对 EMF 的内部结构有很多了解) ,代码生成等?

I have used Eclipse Xtext in several projects. I loved the ease of defining a grammar over an Ecore (meta)model and letting everything generated for you including awesome Eclipse plugin editor, but I was quite uncomfortable with the underlying EMF framework with everything hard-wired in static fields.

Lately I came across Jetbrains' MPS (Meta Programming System). It's based on completely different philosophy. While Xtext is for creating text-based DSLs generating a parser for you (and instantiating those EObjects), in MPS-created language one edits directly underlying model structure. So far I get it.

Has anybody experience with both those DSL tools to point out the main differences in terms of working with them, intended use cases and audience, complexity, learning curve (to be honest, to start using Xtext one should know quite a lot about EMF's guts), code generation etc?

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

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

发布评论

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

评论(3

夏了南城 2024-09-04 08:24:19

Xtext 是一种传统的基于解析器的方法,适用于普通文本文件。这些可以邮寄、存储并与任何版本控制系统进行比较,甚至可以使用您最喜欢的命令行工具在编辑器之外进行修改。
它与 Eclipse EMF 紧密集成,并且与 Eclipse 生态系统中的一大堆工具配合得很好。最近,它演变成(并且仍在这样做)某种“编程语言开发工具包”,它允许您支持所有类型的附加工具。

另一方面,MPS 使用基于投影的编辑器,当您在环境中工作时,该编辑器“看起来”像文本。底层存储格式是特定于工具的(读:没有特殊程序就无法使用),并且不解析纯文本文件。这提供了一些巨大的优势,例如嵌入任意语言(例如,Java 中的 SQL 中的正则表达式)。该工具链能够以模型到模型转换的形式生成,作为编辑器,一开始感觉不寻常,但也很强大。

这两种工具都以某种方式将您锁定在它们的世界中(MPS/Eclipse)。尽管您可以在无头模式下运行两者,但无法在另一个 IDE 中轻松启动 Xtext 编辑器。 MPS 也是如此。我认为 Xtext 是“更开放”的,因为它一方面可以处理普通文本文件,另一方面可以很好地与现有工具(一般是 EMF 和 Eclipse)配合使用。

这能回答你的问题吗?如果您有更详细的问题,我会尽力给您更准确的答案。

Xtext is a traditional parser-based approach that works with ordinary textual files. Those can be mailed, stored and compared with any version control system and even modified outside the editor using your favorite command line tool.
It tightly integrates into Eclipse EMF and works pretty well with a whole bunch of tools you can find in the Eclipse eco-system. Recently, it evolved (and is doing so still) into some kind of "programming language development toolkit" where it allows you to support all kind of additional tooling.

MPS on the other side works with a projection-based editor that just "looks" like text while you are working within the environment. The underlying storage format is tool-specific (read: unusable without special programs) and does not parse plain text files. This offers some great advantages such as embedding of arbitrary langauges (e.g. Regex inside SQL inside Java). The toolchain enables generation in form of model to model transformations that -as the editor- feel unusual at the beginning but are powerful, too.

Both tools are somehow locking you into their world (MPS/Eclipse). Even though you could run both in a headless mode, one cannot easily launch the Xtext editor inside another IDE. The same is true for MPS. I would argue that Xtext is "more open", since it works with ordinary text files on one hand and plays well with established tools (EMF and Eclipse in general) on the other hand.

Does this answer your question? I will try to give you more precise answers if you have more detailed questions.

执手闯天涯 2024-09-04 08:24:19

MPS 的主要思想不是使用投影编辑器,而是使用基于文本的编辑器。这是语言的兼容性。例如,您可以使用元组扩展 Java,而另一个人可以使用异步方法调用扩展 Java。在基于文本的工具(如 XText)中,不可能保证两个扩展能够很好地协同工作,因为生成的语法可能不明确。 MPS 使这成为可能。您只需将语言添加到项目中,就像添加库一样。

The main idea of MPS isn't using a projectional editor instead of a text based one. It's the language compasability. For example, you can extend Java with tuples, and another person could extend Java with async method calls. In text based tools (like XText), it's impossible to guarantee that two extensions work well together, since the resulting grammar might be ambiguous. MPS makes this possible. You just add language to your project like you add libraries.

似狗非友 2024-09-04 08:24:19

我认为 Jetbrain 的 MPS 一开始更容易学习。您不需要使用配置文件,例如 xtext 中的工作流程文件。

主要区别在于,在 MPS 中,您可以直接编辑模型,并且该模型会在语法/编辑器视图中向您显示。在 xtext 中,您编辑语法并生成/解析模型。

我认为MPS更强大。您可以更轻松地组合语言并扩展它们。投影编辑器的一大优点是您可以隐藏信息或显示从模型检索到的附加信息。您还可以使用不同的视图,例如表格或图表(MPS 2.1 中出现)。

版本控制可以通过MPS来完成。有一个适用于树模型的合并/差异工具。

In my opinion Jetbrain's MPS is easier to learn at first. You don't need to work with configuration files like the Workflow-Files in xtext.

A main difference is that in MPS you edit the model directly and this model is shown to you in a syntax/editor view. In xtext you edit the syntax and the model is generated/parsed.

In my opinion MPS is more powerful. You can combine languages much easier and extend them. A big advantage of projectional editors is that you can hide information or show additional information retrieved from the model. You can also used different views like tables or graphs (coming up in MPS 2.1).

Version control can be done with MPS. Theres a merge/diff tool that works on the tree-model.

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