领域特定语言的有趣示例
我正在考虑为我的本科项目使用领域特定语言做一些事情。我的一个问题是我真的找不到任何可以深入研究的有趣示例。有人有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.
如果您追求 C++,boost::spirit 是一个有趣的例子。引用:
(不过我不知道你所说的“解决并发问题”是什么意思。我不知道你如何解决一般的“并发问题”,或者 DSEL 如何提供帮助。)
boost::spirit if you're after C++ is an interesting example. Quote:
(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.)