Code Generation in Swift

In the description of MPS, it is mentioned:

Through a series of steps, the generator gradually transforms the original domain-specific model into a model represented in a low-level general-purpose language, such as Java, C, JavaScript, or XML.

I was just wondering if Swift, since it too has strong support for DSL creation, would be supported in the future...

Comment actions Permalink

I suspect that us (JetBrains) will not put the efforts into implementing Swift in MPS. Technically, however, there is no obstacle preventing third-parties to do it and then share or sell the plugin.

Comment actions Permalink

The sweet spot of MPS are "business DSLs": building tools for non-programmers (subject matter experts) to describe the domain logic. The domain logic does not even need to be generated into another language for it to be valuable: MPS can perform various analyses or interpret the model.

In contrast to that, Swift (and other languages such as various Lisps and Kotlin) offer facilities for programmers to develop more expressive syntax for other programmers to use.

If you consider generating code from a business DSL, a nicer syntax of the target language helps but is not the decisive trait. Some language features can be helpful, for example, having support for inline closures helps generate code blocks without having to define extra toplevel functions. On the other hand, a complex target language might also impede generation because it might be more difficult to satisfy the compiler. As an example, generating safe Rust code that would satisfy the borrow checker is going to be more difficult than generating plain C.


Please sign in to leave a comment.