15 comments
Comment actions Permalink

Dr Gary Thomspon wrote:

can you write java extesnions with mps?

regards

gary

In MPS we don't use java, we use baseLanguage which looks like java

(without anonymous and inner classes and some other features, so it

easily can be serialized not only to Java but also to C# or some other

langue) that is extended by collectionLanguage, modelQueryLanguage.

0
Comment actions Permalink

Konstantin Solomatov wrote:

Dr Gary Thomspon wrote:

>> can you write java extesnions with mps?

>> regards

>> gary

In MPS we don't use java, we use baseLanguage which looks like java

(without anonymous and inner classes and some other features, so it

easily can be serialized not only to Java but also to C# or some other

langue) that is extended by collectionLanguage, modelQueryLanguage.

In other words, yes. You can extend the base language with new concepts

which generate java code. It is not exactly extending java, but it is

the same effectively.

--

Rob Harwood

Software Developer

JetBrains Inc.

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Hi,

In other words, yes. You can extend the base language

with new concepts

which generate java code. It is not exactly extending

java, but it is

the same effectively.

I understand. But implementing a non-trivial language from scratch is a complex task, and I would rather be interesting in extending common java usage by developing simple "macros", possibly directly usable from within IDEA. I think this kind of usage would provide a easier learning curve, since it would allow the creation of examples that are at the same time simple and useful.

MPS' abstract language framework is for sure much more general, but it is also quite complex.

Francesco

0
Comment actions Permalink

I understand. But implementing a non-trivial language from scratch is a complex task, and I would rather be interesting in extending common java usage by developing simple "macros", possibly directly usable from within IDEA. I think this kind of usage would provide a easier learning curve, since it would allow the creation of examples that are at the same time simple and useful.

Fully agree. I'm sure this is the only way to get a large couple of

users use MPS.

Tom

0
Comment actions Permalink

Thomas Singer (MoTJ) wrote:

>> I understand. But implementing a non-trivial language from scratch is

>> a complex task, and I would rather be interesting in extending common

>> java usage by developing simple "macros", possibly directly usable

>> from within IDEA. I think this kind of usage would provide a easier

>> learning curve, since it would allow the creation of examples that are

>> at the same time simple and useful.

Fully agree. I'm sure this is the only way to get a large couple of

users use MPS.

Personally, I don't really see extending Java as something "core" to the

value proposition for MPS and I personally don't agree that it should

really be the focus of MPS at this point to make that task as simple as

possible.

However, I can see the value in extending Java with macros. Extending

Java with macros is a relatevely simple thing, and there are a few

different macro systems available. I've even implemented one myself (I

guess I will release it as open-source pretty soon).

I can also see how it could make it easier to refactor your way from a

100% Java program to a program with more and more DSLs as you progress,

if you had a way to add your own constructs to Java.

However, I do think that going that way would be unnecessarily messy. I

would rather keep my Java source in pure Java (without extensions) and

implement whole parts, as suitable, of the system in a suitable DSL. I

do not really want one source file with Java mixed with special language

constructs that everyone reading that source file needs to understand.

Code in something in between Java and a DSL might not be so nice and I

think there's a big risk of that making the code more complex.

Finally, I guess you could do it in MPS. I tried myself to extend the

base language by adding a "property" concept.

What I wanted is something like:

property String firstName;

That would expand into (generate) a private field firstName, and a

getter and setter for it. This would be a typical Java statement macro.

I did this by creating a new language, in which I created a new

ClassConcept (I called it ClazzConcept with an alias clazz) that

inherited ClassConcept from the baselanguage, but added a list of

properties to it as well as the other concepts that can exist in a

class. I also made a PropertyDeclaration concept that merely contained a

link to a FieldDeclaration. I then wrote the editor for the

PropertyDeclaration and ClazzConcept and could then write code in the

baselanguage but with these new properties.

Ok, the base language is not really Java, but it's pretty close.

-Karl

0
Comment actions Permalink

Karl

As long as we are limited to toying with MPS, all discussions are

theoretical and not well founded.

Show us how to introduce MPS into a smallish-but-real-enough project.

Show us how to refactor to MPS.

Show us how to benefit from MPS.

Show us what an ideal smell is, to be cured by MPS.

Till then, ...

It reminds me of all the AspectJ discussions in the IDEA forums. Nobody

could come with a "look: here is a project I refactored to AspectJ. See

how better it is now". I'm sure it would have changed a lot.

Alain

0
Comment actions Permalink

Hello Alain!

Karl

As long as we are limited to toying with MPS, all discussions are

theoretical and not well founded.

Show us how to introduce MPS into a smallish-but-real-enough project.

Show us how to refactor to MPS.

Show us how to benefit from MPS.

Show us what an ideal smell is, to be cured by MPS.

Till then, ...

I'll try my best.

A friend of mine is running a company who's developed a very good

application for doing technical analysis of financial instruments, like

stocks, currencies, commodities, etc.

Currently, all technical indicators are written in C#. C# is not very

suitable for these mathematical indicators and this makes indicator

creation a more complex task than it needs to be, especially for

financial guys who have no idea about C#.

My friend and I are planning to introduce one or a few DSLs to the

product (like a few competing products have). One DSL would be

specialized at writing techinical inidcators. Another DSL might be

specialized at writing trading systems based on the indicators, etc.

These DSLs could and would be used within the company when creating new

indicators. Over time, the existing indicators could be moved to the new

language, to make the codebase cleaner. New indicators could also be

created in this language by customers and by third party developers.

After languages have been created for writing indicators and trading

systems, I'm sure there's yet some other class of things we find that

would be more suitable to express in some DSL than in C#, and then we

can create that language.

This would be a way to refactor a product from pure Java to MPS.

Identify parts of your codebase that really shouldn't be written in

Java. It might be some workflow rules, it might be mathematical

expressions, it might be cross-sale and up-sale rules for a webshop,

etc. When you've identified such a thing, go ahead and create the right

language for that problem domain.

It's all about making sure you develop in the right language. A typical

smell that says that you're not developing in the right language is when

you can explain something you want to do to your co-developer in 1

minute, but it still takes you 5 hours to implement it in the language

you're using. If that happens, you're clearly not using the best

language to implement it.

I hope this also answers the question on how you can benefit from MPS.

-Karl

0
Comment actions Permalink

Karl

What about starting from the BowlingGame example?

It's real, simple, everybody knows it, and the game rules look like the

ideal candidate for an MPS conversion/refactoring.

Alain

0
Comment actions Permalink

What about starting from the BowlingGame example?

It's real, simple, everybody knows it, and the game rules look like the

ideal candidate for an MPS conversion/refactoring.

Sure, go ahead and do that! You've identified a small simple project

where MPS could be of help, now you just have to try it. I'm sure it'd

make a great sample.

-Karl Avedal

0
Comment actions Permalink

Karl Avedal wrote:

>> As long as we are limited to toying with MPS, all discussions are

>> theoretical and not well founded.

>> Show us how to introduce MPS into a smallish-but-real-enough project.

>> Show us how to refactor to MPS.

>> Show us how to benefit from MPS.

>> Show us what an ideal smell is, to be cured by MPS.

>> Till then, ...

>>

This would be a way to refactor a product from pure Java to MPS.

Identify parts of your codebase that really shouldn't be written in

Java. It might be some workflow rules, it might be mathematical

expressions, it might be cross-sale and up-sale rules for a webshop,

etc. When you've identified such a thing, go ahead and create the right

language for that problem domain.

It's all about making sure you develop in the right language. A typical

smell that says that you're not developing in the right language is when

you can explain something you want to do to your co-developer in 1

minute, but it still takes you 5 hours to implement it in the language

you're using. If that happens, you're clearly not using the best

language to implement it.

Karl and Alain,

This is exactly the process that has been used to develop MPS itself. It

started as purely Java, then got to the point that the first language

could be written and used, and so part of MPS was re-written in the

first language, etc. etc. For example, we are working on the languages

that will be necessary to remove the Java aspect methods from generator

definition (this includes a query language); then MPS will be re-written

to remove its own Java aspect methods.

So, Alain, while I completely agree that we need to work on more

practical examples just as you've described, the possibilities are at

least slightly more than purely theoretical. Sergey has several times

said something to the effect of "look: here is a project (part of MPS) I

refactored to MPS. See how better it is now"

--

Rob Harwood

Software Developer

JetBrains Inc.

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Karl

>

Sure, go ahead and do that! You've identified a small simple project

where MPS could be of help, now you just have to try it. I'm sure it'd

make a great sample.

>

Actually, I was suggesting a short tutorial, for you to write, and

people like me to read, try out and learn from .

(Here is a good implementation where the game rules are well delimited:

http://www.xprogramming.com/xpmag/acsIntention.htm)

Alain

0
Comment actions Permalink

Karl,

not only I understand your arguments, but also argee with many of them. The financial DSLs are a really good example.

Let me repharse some of my points

I believe that it is important that MPS is built upon an abstract and generic language model, rather than a java-centric one, for many reasons.

However, I think it is also important, for MPS' "social" and economical acceptance and substainability, to make it a "core" goal to be fully interoperable with both legacy projects and currently mainstream languages.

In a sense, macros are "the same thing" as MPS, or at least they are as powerful and as difficult to implement as MPS. They have lots of subtle issues that needs to be handled, and I think that providing IDE support, and refactoring for them is not an easy task.

Macros can too be used to concisely work with different programming paradigms or data models.

The main differences between what I call "macros" and MPS is that macros are usable in smaller chuncks.

They are bottom-up rather than top-down.

Francesco

0
Comment actions Permalink

Rob

>

So, Alain, while I completely agree that we need to work on more

practical examples just as you've described, the possibilities are at

least slightly more than purely theoretical.

When I wrote "theoretical", I meant: for outsiders like me. For the EAP

to be useful, we - outsiders - need to use MPS on real production code.

Currently, I don't really how I could do that. A good step-by-step

example could make the difference.

Alain

0
Comment actions Permalink

>>

>> Sure, go ahead and do that! You've identified a small simple project

>> where MPS could be of help, now you just have to try it. I'm sure it'd

>> make a great sample.

>>

Actually, I was suggesting a short tutorial, for you to write, and

people like me to read, try out and learn from .

(Here is a good implementation where the game rules are well delimited:

http://www.xprogramming.com/xpmag/acsIntention.htm)

Alain,

Why do you want me to do it? I'm not affiliated with JetBrains or MPS in

any way. I'm just someone who finds LOP and MPS fascinating, which I

assume makes you and me similar in that sense. So if you want me to do

it, it's only fair that I want you to do it. :-)

- Karl Avedal

0
Comment actions Permalink

Karl

>

Alain,

Why do you want me to do it? I'm not affiliated with JetBrains or MPS

in any way.

My mistake. As I didn't recognize your name from the IDEA forums, I

mistook you for a JB staff member.

I'm just someone who finds LOP and MPS fascinating,

.. and acronyms too :-)

Alain

0

Please sign in to leave a comment.