Building a Nice syntax editor for dsl


I have a dsl and I'm deciding how to build an editor.  From scratch, xtext, mps...  I would like to have a text editor, with syntax highlighting, code completion, drop down code completion, and a linked graphical view of the dsl.

In exploring MPS, I've done the calculator demo, and played around with the Robot project.

I don't know if I'm missing something, but the projectional syntax editors that are generated are not very user friendly.  For example, with the Robot syntax, I can't simply mouse select a big block of text(syntax) and delete it, although in the tutorial video, it looks like he does this.  Is this what you end up with?

MPS seems like a lot of work to learn, and it may be worth it, but if I end up with editors that are very hard for my users to use, then I'm not sure I want to do that.  I would expect that my users will want to mouse over portions of our dsl to highlight and delete portions.

I would rather have an editor like intellij for my dsl, that works great, has syntax highlighting, code completion, and drop down completion.  But that still understands the basic operations of text editing that users expect.

Please help me to understand the big picture here, and point me in the right direction.

Or is this just a bug with MPS on the Mac, that you can't select with the mouse in the editors?
this is the kind of selection I can't do with the mouse...
It's all about tradeoffs and what your needs are.  If you are building a single DSL or a couple and don't need tight language integration/extension capabilities, but do need the familiarity of pure text editing, then I would recommend Xtext.  In my experience, Xtext is harder to work with from the language designer's point of view, and doesn't have nearly the capabilities, but the end user experience is hard to beat for these use cases.  And for simpler DSLs, it's even not that bad for the language designer, but as the complexity increases you will quickly find yourself pulling your hair out (at least I did).

When you need to develop or use several languages that integrate with and extend each other, then you will quickly find Xtext limiting for your use case. Most extension scenarios you can fake pretty well in Xtext, although sometimes it takes significantly more work.  But one thing you can't do is extend languages that weren't designed with extension in mind.  This is totally possible (and in most cases rather easy) with MPS through annotations, and this capability only works because of the way MPS edits the AST directly through the projectional editor.  It's a powerful - and addictive - feature.  Once you start realizing the real power of being able to do this, you'll find more and more uses for it, and it's pretty hard to go back.

I highly recommend Markus Voelter's new DSL book (I believe it's linked on the main MPS page).  He goes into a great amount of detail on the pros/cons of both approaches, as well as many of the practical considerations for implementing various kinds of dsls.

Both Xtext and MPS are excellent products, and you can't go wrong with either one provided you do your homework up front and make sure you pick the one that best suits your needs.  Creating a DSL can involve a significant investment of time, especially the first time around, so it's important to make sure you understand these tradeoffs and pick the right tool up front.
Thanks Mike.  I appreciate the distinctions between XText and MPS.

Can you answer my question of whether the projectional editors are working on my system.  Are you able to select multiple nodes with your mouse as shown in the post above yours.  I can't do that type of selection with my mouse, but in the demo videos, it appears he is making those types of selections.  I understand that projectional editors are different to work with, I'm just trying to figure out how different.
Hello xcoyle,

Your system works fine! You cannot select the projected nodes with mouse like text. But you can select multiple statements from a list by using the keyboard with shift + up/down. This short cut works in most text editors, too.
Thanks Fabma

I guess my question then is to Jetbrains.  If multiple statements are selectable by various means, why would you leave out the most common way of multiple selecting.  For any editor I create, a user will try using the mouse first.
I think this is just a technical restriction. Creating a general drag and drop behavior for the editor which just enable allowed actions is probably not an easy task.
And I would really not agree, that using the mouse is more useful than selecting things with the keyboard. In normal text editors I do the copy and paste actions just with the keyboard, since it is more precise. Just try the short cuts [Ctrl] + Shift + Cursor|Page up/down|Pos 1|End in a text editor. You can do things much faster than with a mouse if you are used to it.

Please sign in to leave a comment.