领域特定语言的有趣示例

发布于 2024-10-22 11:36:20 字数 317 浏览 4 评论 0原文

我正在考虑为我的本科项目使用领域特定语言做一些事情。我的一个问题是我真的找不到任何可以深入研究的有趣示例。有人有 DSEL 的任何好的示例吗(最好是开源的)?

另外,我想关注的一个领域是使用 DSEL 解决并发问题(协程等)。有没有人在 DSEL 中使用这个的好例子?如果这是 DSEL 的愚蠢应用,请解释原因......

另一个值得探索的潜在领域是数据库编程。这又是一个用 DSEL 探索的愚蠢领域。例如,向 C# 添加一些疯狂的数据库操作语法是否是一个好的项目?

编辑:我会考虑实现的通用语言是 Java、Python、Scala、C# 等。可能不是 C++ 或 C。

I'm considering doing something with Domain Specific Languages for my undergraduate project. My one problem is I can't really find any interesting examples that I can root around in. Does anyone have any good examples of DSELs (preferably open source)?

Also, one area I would love to look at is solving/addressing concurrency problems (coroutines etc) with DSEL's. Are there any good examples that anyone uses of this in DSELs? If this is a stupid application of DSELs please explain why...

Another potential area to explore would database programming. Again is this a stupid area to explore with DSEL's. For example, would adding some crazy database manipulation syntax to C# say be a good project to undertake?

EDIT: General languages I would be looking at implementing in would be Java, Python, Scala, C# etc. Probably not C++ or C.

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

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

发布评论

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

评论(2

許願樹丅啲祈禱 2024-10-29 11:36:20

Linda 实现可以被视为 eDSL。像 CL-STM 这样的 STM 实现肯定是 eDSL。

与并发性无关,但非常有用的是嵌入式 Prolog 实现,其中有很多用于 Scheme、Lisp 和 Clojure。解析 eDSL 已经被提到过 - 其祖先 Parsec 绝对值得深入研究。

编辑:通过您的实施语言列表,您错过了最有趣的 eDSL 机会。最强大、最灵活的 eDSL 是通过元编程构建的。 Scala 风格(甚至 Haskell 风格)的 eDSL 基于高阶函数,即迷你解释器。它们的设计更加复杂,灵活性更差,并且受限于宿主语言的语法。

Linda implementations can be considered as eDSLs. STM implementations like CL-STM are certainly eDSLs.

Unrelated to concurrency, but extremely useful are embedded Prolog implementations, there are plenty of them for Scheme, Lisp and Clojure. Parsing eDSLs had been mentioned already - and their patriarch Parsec definitely worth digging into.

EDIT: with your list of implementation languages you're missing the most interesting eDSL opportunities. The most powerful and flexible eDSLs are made with metaprogramming. Scala-style (or even Haskell-style) eDSLs are based on high order functions, i.e., on mini-interpreters. They're more complicated in design, much less flexible and limited to the syntax of your host language.

指尖上得阳光 2024-10-29 11:36:20

如果您追求 C++,boost::spirit 是一个有趣的例子。引用:

Spirit 是一组 C++ 库,用于
解析和输出生成
作为特定领域实施
嵌入式语言(DSEL)...

(不过我不知道你所说的“解决并发问题”是什么意思。我不知道你如何解决一般的“并发问题”,或者 DSEL 如何提供帮助。)

boost::spirit if you're after C++ is an interesting example. Quote:

Spirit is a set of C++ libraries for
parsing and output generation
implemented as Domain Specific
Embedded Languages (DSEL)...

(I have no idea what you mean by "solving concurrency" though. I don't see how you can solve "concurrency problems" in general, or how a DSEL could help.)

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