You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nop平台中的XLang语言和JetBrains公司的MPS(Meta-Programming System)产品都是为了支持领域特定语言(DSL, Domain Specific Language)的创建与使用而设计的,但它们在设计理念、实现方式和技术特点上有着明显的差异。以下是对两者进行深度对比的分析:
Code in MPS is not text, but instead it is a projection of the abstract syntax (AST).
235
+
236
+
Design Principles for Domain Specific Languages:
237
+
1. Identify language uses early: 确定至少一个目标任务
238
+
2. Ask questions: Who is going to model in the DSL? Who is going to review
239
+
the models? When? Who is using the models for which
240
+
purpose?
241
+
3. Make your language consistent
242
+
4. Decide carefully whether to use graphical or textual realization
243
+
5. Compose existing languages where possible
244
+
6. Reuse existing language definitions
245
+
7. Reuse existing type systems
246
+
8. Reflect only the necessary domain concepts
247
+
9. Keep it simple
248
+
10. Avoid unnecessary generality
249
+
11. Limit the number of language elements
250
+
12. Avoid conceptual redundancy
251
+
13. Avoid inefficient language elements
252
+
14. Adopt existing notations domain experts use
253
+
15. Use descriptive notations
254
+
16. Make elements distinguishable
255
+
17. Use syntactic sugar appropriately.
256
+
18. Permit comments.
257
+
19. Provide organizational structures for models
258
+
20. Balance compactness and comprehensibility
259
+
21. Use the same style everywhere
260
+
22. Identify usage conventions
261
+
23. Align abstract and concrete syntax
262
+
24. Prefer layout which does not affect translation from concrete to abstract syntax
263
+
25. Enable modularity
264
+
26. Introduce interfaces
265
+
266
+
Internal DSL
267
+
268
+
Characteristics
269
+
Embedded language: Internal DSLs are implemented within a general-purpose programming language, and they use base language syntax and competencies to target a specific domain problem.
270
+
Reusability: Existing knowledge and syntax are used from its base language to create domain-specific language.
271
+
Flexibility: GPL and DSL are well balanced in internal DSLs as they provide flexibility to use the host language’s regular syntax, which requires less development tools and efforts as compared to external DSLs.
272
+
Challenges: Internal DSLs are possibly less optimized than external DSLs for specialized tasks as they are limited to the structure of their base code.
273
+
274
+
Advantages
275
+
276
+
Benefits the developers as they are familiar with the same language and have no need to learn the new language’s syntax
277
+
Reuse of existing libraries and tools from the base language helps in reducing the time requirement
278
+
Use of a wide range of libraries for writing internal DSLs
279
+
280
+
Disadvantages
281
+
282
+
Internal DSLs are Constrained by the syntax of its host language
283
+
Making chaos by mixing Domain-specific language with general-purpose language.
284
+
Any modification in the project may affect the performance of internal DSL.
285
+
286
+
287
+
External DSL:
288
+
Distinct language: the DSL and host languages used for specific tasks are separate from each other with their own syntax, semantics, and development tools.
289
+
Specialization: External DSLs are specialized in coordination with a particular problem domain resulting in efficient solutions for specific domain problems.
290
+
Consistency: As a result of isolation from the host language external DSLs provide data safety and increase accuracy.
291
+
Challenges: DSL has a learning curve as it possesses challenges for learning new languages and their syntax which may require additional time and effort.
292
+
293
+
Advantages
294
+
Specialized code results in resourceful and communicative solutions to targeted problem
295
+
Language separation yields a lower error rate
296
+
External DSLs have their development tools, compiler, and IDE support.
297
+
298
+
Disadvantages
299
+
Merging different languages decreases the accuracy
300
+
DSL for one project cannot be used in any other program hence limiting code flexibility.
301
+
The overhead cost of maintaining external DSLs and development tools.
302
+
303
+
[Shadow Models: Incremental Transformations for MPS](http://voelter.de/data/pub/SLE2019.pdf)
304
+
The name is motivated by the realization that many analyses are easier to do on an model whose structure is different from what the user edits.
305
+
A problem when representing information formally with models is that different tasks suggest different representations of the same information
306
+
307
+
Transformation DSL The language is functional: each function takes one or more source nodes as input and produces one or more output nodes.
308
+
局部结构变换
309
+
he result of the transformation can either be analyzed directly on the INode structure or after materializion to an MPS AST (through another COW). The latter is slower,
310
+
but has the advantage that existing MPS analyses (such as type checks) can be used unchanged; it is also the basis for visualization in the editor.
311
+
312
+
MPS models are trees with cross-references (or: graphs with a single containment hierarchy).
对应的合并策略为 Result = E x-extends Model x-extends D x-extends C x-extends B x-extends Axml格式的模型文件,下划线开头的自动生成的源码,手动编写的源码,还有Generator工具等。其中模型文件对应DSL,那么Generator工具对应的就是公式中的Genetator吗?如果不是,那公式中的Generator对应的是Nop中的哪些部分?
0 commit comments