What is possible?

  • 6
  • 46

Here are a few projects I have in mind that I would like to do with MPS:

1. Modify Java so that functions outside of classes can be written.
2. Compile Javascript to Python, C# to Java, etc.
3. Create a DSL which is essentially an almost 1:1 port of jula/javascript/any dynamic language with the exception that I will get code assist from MPS.

Are these things in the scope of what MPS can do? If so, I would appreciate if you could give me a few suggestions for the second question "c# to java". Where I should start, what problems I will likely encounter etc.
Thank you in advance
Hi, Thomas

(1) is possible and a kind of such a thing is already implemented in MPS. Please see extensionMethods language. Standalone functions are also possible to implement, and it's quite a simple task.

(2) the most common answer for questions like "can I somehow transform code from language A to B?" is "only if they don't have conceptual differences". E.g. for Java and C# you'll most probably meet problems with dependencies system - in Java classes resolution is performed in classpath by fqname, while in C# it's more strict and is based on assemblies UIDs. But Java and C# are quite similar, so maybe this won't be too hard. I can't say exactly, as I'm not an expert in C#.
Where to start depends on what you want to get. If you want to get your code on Java transformed to C#, we already have an ability in MPS to parse java files and make MPS models from it, so you could probably just write a generator for BaseLanguage to generate it into C#. Though there will be some difficulties because MPS has quite poor support for multi-target generation. But it's still possible. You can contact us if you start and have some problems.

(3) you can do this, but I think you won't be able to make code assist work better than in text editor. The thing of MPS is that all references in code are permanently resolved, while it's not a case in dynamic languages. So, maybe MPS is not the best way to do this, and it would be simpler to write language support for Idea or Eclipse.

Regards,
Mihail

Thank you, I will investigate further and see if I can use it for (2)!