领域特定语言 (DSL) 对于普通程序员来说是否有害?

发布于 2024-08-24 19:46:02 字数 1432 浏览 5 评论 0原文

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

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

发布评论

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

评论(5

忘你却要生生世世 2024-08-31 19:46:02

DSL 将把程序员从非编程的事情中解放出来。更清晰的职责分离始终是一个好主意。程序员应该编程(例如,实现 DSL),其他领域专家应该做他们擅长的事情。我个人正在尽我所能,使这个行业转向更广泛地使用 DSL。我不想编写业务逻辑代码。我喜欢实现编译器。所以我不害怕。我期待着有一天,每项小任务都需要自己的小 DSL。

DSLs will liberate programmers from doing a non-programming stuff. Cleaner separation of responsibilities is always a good idea. Programmers should program (e.g., implement DSLs), and other domain experts should do what they are good in. I am personally doing whatever I can to turn this industry towards a wider use of DSLs. I do not want to code business logic. I love to implement compilers. So I'm not afraid. I am looking forward for a time when every little task will require its own little DSL.

深海不蓝 2024-08-31 19:46:02

总是需要真正的、知识渊博的程序员来构建这些 DSL,并随着需求的变化向它们添加新功能。没有问题域是静态的。

There will always be a need for real, knowledgeable programmers to construct those DSLs and to add new capabilities to them as requirements change. No problem domain is static.

何时共饮酒 2024-08-31 19:46:02

我不担心,DSL 距离被普通企业 IT 部门接受还有很长很长的路要走。

I wouldn't worry, DSL's are a long, long, long ways away from being embraced by your average corporate IT department.

无悔心 2024-08-31 19:46:02

我是一名开发人员,经常设计自己的 DSL 和 DSL2Text 转换,以加快工作中许多无聊部分的速度。为此,我使用 Eclipse 插件(即 EMF、XText、ACceleo 等),如本网站 http://lowcoupling 中所述.com/dslengineering

I am developer and I frequently design my own DSLs and DSL2Text transformations to speed up many boring parts of my job. To this end I use the Eclipse plugins (i.e. EMF, XText, ACceleo, etc.) as explained in this site http://lowcoupling.com/dslengineering

ら栖息 2024-08-31 19:46:02

我认为 DSL 实际上会提升软件工程工作的水平。原因如下:

  1. 考虑 ORM 或 SQL DSL。它以您的本机编程语言模拟 SQL 访问。它降低了复杂性,允许更高级别的构造,更具可读性并且不易出错(与 SQL 字符串操作相比)。好的 SQL DSL 是可组合的。尝试使用即时 Ad Hoc 代码来实现 SQL DSL 的功能非常困难且容易出错。在这种情况下,DSL 降低了日常复杂性,并将代码级别提升为更高级别的抽象。 (与我们不想每次打开 TCP 连接时都对每个 TCP/IP 握手进行编码相同的概念)。

  2. 许多 DSL 并不适合软件程序员。当我们设计 DSL 时,通常会将它们交给领域专家(非程序员)使用。这些更简单的 DSL 不需要程序员,因此您不会在使用它们时陷入困境。软件领域目前正在变得简单化,因为我们的学校培养出了编写简单 ASP.Net 页面的程序员。将这些类型的平凡工作转移给非程序员将迫使学校培养更高素质的工程师。

  3. 好的 DSL 隐藏了复杂性,但它们很灵活,并且允许用户在需要时自定义/微调行为。这意味着它们不会将程序员限制在严格/平凡的编码行为中。

当问题高度复杂时,通常最好将其简化为特定于领域的问题并为其构建迷你 DSL。 DSL代码只是更相关、更容易维护,而且业务逻辑会更短、更容易验证、更容易推理。

I think DSLs in reality will elevate the levels of software engineering work. Here are the reasons:

  1. Think of ORM or SQL DSLs. It models SQL access in your native programming language. It reduces complexity, allows higher level constructs, is more readable and is less error prone (than SQL string manipulation). A good SQL DSL is composable. Trying to achieve what a SQL DSL does with Ad Hoc code on the fly is way too difficult and error prone. In this case, a DSL reduces mundane complexity and elevate the level of your code into higher level abstractions. (Same concept as we don't want to code every TCP/IP handshake every time we open a TCP connection).

  2. Many DSLs are not meant for software programmers. When we design DSLs, often they are handed off to domain experts (who are non-programmers) to use. These easier DSLs will not require programmers, so you won't be stuck using them. The software field is currently dumbed down because we have schools churning out programmers that code simple ASP.Net pages. Shifting these type of mundane work to non-programmers will force schools to produce higher quality engineers.

  3. Good DSLs hide complexity, but they are flexible, and allow users to customize/fine tune behaviors when needed. This means they won't confine programmers into rigid/mundane coding behaviors.

When a problem is highly complex, it's usually better to reduce it into a domain specific problem and construct a mini DSL for it. DSL code is simply more relevant and easier to maintain, and the business logic will be shorter, easier to verify and easier to reason.

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