DSL environment to do HTTP restful API call

DSL environment to do HTTP restful API call

We have a DSL

We would like to create an environment to enter our language

As we enter a program using our language, we would like this environment to allow us make a real-time http restful calls to help us determine specific field values in the environment.

As we enter the program, we would like to smart copy (eg clear out some fields) from other programs that were previously entered in this environment.

Upon finishing entry of our program, we would like to validate our DSL entry, and have the program convert what we entered into a series of http restful calls that will let an external system know what we created.

I think we have become relatively well versed in MPS, but we are confused at the highest level.  Any high level 'go do this' would be greatly appreciated.  At a high level what is the environment described above written in?  (MPS, Embedrr, Swing)?
0
9 comments
Hi,
a very basic and probably the simplest way to do a REST call within MPS is to create a little tool using the baseLanguage. Create a new class, open a connection to your HTTP server and write a REST request on that connection.
If you have more REST stuff to do, you may consider using a REST client framework. Add the jar(s) in the lib dir in your language or solution (depending on the decision if you do the REST in your language or create a runtime solutions), import the java stubs and call the library methods.
0
Custom persistence might be another option here, although I can imagine a severe performance bottleneck.  Of course, if the REST call is really over the wire to a remote server, performance in the editor is going to be painful no matter what approach you take.  If you are connecting to server running on the local machine (typical in most development environments), it won't be as much of an issue.  But even in that case, keep in mind the implications of running your solution against a remote server when it's deployed.  Your users will not be happy at all if they have to wait a second or two every time a code completion menu has to populate!

From the little info you've given, I'm questioning if this is a good fit for MPS, or maybe you're thinking at the wrong level of abstraction for an MPS-based approach.  Could you give us more details on what you are trying to do, we can probably help you determine a good solution.
0
Hm, as I understood from (yes, the little) info, most of all steps should be done in MPS locally and only at some defined points a REST communication should be done. That would be an argument against the custom persistence.
0
What you mean here, Mike, is generating whatever information rjc wants to
retrieve using REST from language models itself, right? So both server-side
information will be generated and client-side code completion will be also
available by making use of local models' information. Did i understood you
right?


On Fri, Jul 26, 2013 at 12:48 AM, Jens Nerche - Meta Programming System <
jetforum@jetbrains.com> wrote:

* Meta Programming System<http://forum.jetbrains.com/forum/Meta-Programming-System>
* > * DSL environment to do HTTP restful API call<http://forum.jetbrains.com/thread/Meta-Programming-System-873>
* 4:47 pm<http://forum.jetbrains.com/thread/Meta-Programming-System-873?message=Meta-Programming-System-873-3>  Jens
Nerche <http://forum.jetbrains.com/user/jensnerche>

Hm, as I understood from (yes, the little) info, most of all steps should
be done in MPS locally and only at some defined points a REST communication
should be done. That would be an argument against the custom persistence.

   Mike Haney <http://forum.jetbrains.com/user/txmikester> @ 4:41 pm<http://forum.jetbrains.com/thread/Meta-Programming-System-873?message=Meta-Programming-System-873-2>

Custom persistence might be another option here, although I can imagine a
severe performance bottleneck. Of course, if the REST call is really over
the wire to a remote server, performance in the editor is going to be
painful no matter what approach you take. If you are connecting to server
running on the local machine (typical in most development environments), it
won't be as much of an issue. But even in that case, keep in mind the
implications of running your solution against a remote server when it's
deployed. Your users will not be happy at all if they have to wait a second
or two every time a code completion menu has to populate!

From the little info you've given, I'm questioning if this is a good fit
for MPS, or maybe you're thinking at the wrong level of abstraction for an
MPS-based approach. Could you give us more details on what you are trying
to do, we can probably help you determine a good solution.

  JetBrains Forum | Build #172 (Jul/18/2013 5:34PM) | Feedback<http://confluence.jetbrains.net/display/JETF/Feedback>
0
That's right.  It's the REST calls for code completion that rjc mentioned that concerned me.  In most cases, you would want to model that data and pre-generate an accessory model or runtime solution for use in the editor.  Even if the data is too dynamic to do that, you should still be able to extract at least some meta-concepts to use as a metamodel and help the editor out, instead of having to lookup every option dynamically.
0
Thank you for your responses

Items created with our language are then callable by name + value pair parameters.  Created items can be called externally or they can be used within the language to create new items.  So anything we create could in theory become usable as part of our language immediately.

As we create an item we would give it attributes (a1, a2, a3, etc).  As we created an item, we were planning to store those externally.  We were planning to store those and the source code in the internal MPS db.

Within MPS or some environment, as we are filling in a specific field, mps would http an external system for all created language elements of type 'a2', we would receive a list to populate there (I guess we could also query MPS db).   At that point, based on attributes, we would load the original source code, a copy, or just the name of the program.

eg
New1 = step1 + step2 + step3
New2 = New1 + step4
New3 = New2 + step5

As we create new1, new2, new3 we want to give then attributes so we can find them later.  We also want to treat then as 'language elements' – so they are in par with step1, 2, 3.  Sometimes we want to display the source code of New1,2 sometimes not.

So we want to use the language itself to create more language elements, and we want to do this dynamically (what is created can be used right away).  Ideally I would like to make no separation: that everything created is a language element that other developers can immediately take advantage of.

--

This is changing by the hour, but this is what we think right now:
  • Use MPS for the editor and compilation step.
  • As we create something (as part of compile) store the attributes (telling mps in future how to use it) to external db
  • It is tempting to store/load the source code external, and just load it from the external system as needed.  Esp if we are talking thousands items.  However, don't know if it is easy to import this type of stuff to MPS, or other potential issues.

Other possibility is forgetting about MPS and doing custom work:
  • Other than a smart editor for value pairs and writing a compiler, it seems that for our language the other steps cannot be avoided.  Maybe having MPS be an external compiler to some new system.  The system could then tell MPS 'compile this'–but I do not know about speed issues, etc.


Suggestions?  questions?
0
Making the call to the remote server during the compilation sounds like a good idea.  I would also consider some caching strategy to minimize remote calls to read the database during editing.  You could handle the remote updates during the compile using a Make facet (see the docs).  That might also be a good time to refresh your cache for bringing data down from the server to use for local editing.

I'm still trying to wrap my head around the details of your approach.  It sounds like your language in MPS would have to be very generic/abstract to accomplish this.  The trick is to not make it so abstract that MPS can't do much for you with regards to validation, type checking, etc.

Your statement "As we create something (as part of compile) store the attributes (telling mps in future how to use it) to external db" caught my attention.  Remember that MPS is not a completely dynamic environment, i.e. when changes are made to the language definition, it still has to go through a generation and compilation step, although the changes are then (usually) seen immediately, without requiring a restart.

Also, although editing solution models programatically is easy enough using the SModel language, I'm not sure how this would work if your plan is to modify the language dynamically (which kind of sounds like what you want to do).  In theory, each of the language models (structure, editor, generator, etc.) are just models that could be modified through the SModel API.  In practice, I'm not sure how well MPS would cope with that - my gut tells me "not well".  But maybe that's not what you are intending, and I'm just understanding it wrong.
0
Maybe it's all possible just very difficult. It was after all possible to
create dynamic languages support in JVM. Basically there is much similarity
to that task if what you want to do is creating new concepts, modifying
behaviors etc. Or am i talking non-sense? Correct me, Mike, if i'm wrong
:-) (Does the former require reflection?) If on the other hand you just
want to create an interpreter of some sort with fixed number of fixed
language concepts then i think it could be done easier and i would anyway
suggest rather asynchronously update server information than to pull data
from there.


On Tue, Jul 30, 2013 at 12:28 AM, Mike Haney - Meta Programming System <
jetforum@jetbrains.com> wrote:

* Meta Programming System<http://forum.jetbrains.com/forum/Meta-Programming-System>
* > * DSL environment to do HTTP restful API call<http://forum.jetbrains.com/thread/Meta-Programming-System-873>
* 4:28 pm<http://forum.jetbrains.com/thread/Meta-Programming-System-873?message=Meta-Programming-System-873-7>  Mike
Haney <http://forum.jetbrains.com/user/txmikester>

Making the call to the remote server during the compilation sounds like a
good idea. I would also consider some caching strategy to minimize remote
calls to read the database during editing. You could handle the remote
updates during the compile using a Make facet (see the docs). That might
also be a good time to refresh your cache for bringing data down from the
server to use for local editing.

I'm still trying to wrap my head around the details of your approach. It
sounds like your language in MPS would have to be very generic/abstract to
accomplish this. The trick is to not make it so abstract that MPS can't do
much for you with regards to validation, type checking, etc.

Your statement "As we create something (as part of compile) store the
attributes (telling mps in future how to use it) to external db" caught my
attention. Remember that MPS is not a completely dynamic environment, i.e.
when changes are made to the language definition, it still has to go
through a generation and compilation step, although the changes are then
(usually) seen immediately, without requiring a restart.

Also, although editing solution models programatically is easy enough
using the SModel language, I'm not sure how this would work if your plan is
to modify the language dynamically (which kind of sounds like what you want
to do). In theory, each of the language models (structure, editor,
generator, etc.) are just models that could be modified through the SModel
API. In practice, I'm not sure how well MPS would cope with that - my gut
tells me "not well". But maybe that's not what you are intending, and I'm
just understanding it wrong.

   rjc(rjc) <http://forum.jetbrains.com/user/rjc(rjc)> @ Jul 23<http://forum.jetbrains.com/thread/Meta-Programming-System-873>

DSL environment to do HTTP restful API call

We have a DSL

We would like to create an environment to enter our language

As we enter a program using our language, we would like this environment
to allow us make a real-time http restful calls to help us determine
specific field values in the environment.

As we enter the program, we would like to smart copy (eg clear out some
fields) from other programs that were previously entered in this
environment.

Upon finishing entry of our program, we would like to validate our DSL
entry, and have the program convert what we entered into a series of http
restful calls that will let an external system know what we created.

I think we have become relatively well versed in MPS, but we are confused
at the highest level. Any high level 'go do this' would be greatly
appreciated. At a high level what is the environment described above
written in? (MPS, Embedrr, Swing)?

  JetBrains Forum | Build #172 (Jul/18/2013 5:34PM) | Feedback<http://confluence.jetbrains.net/display/JETF/Feedback>
0
It does sound like an internal DSL would probably be more appropriate.  For the JVM, Groovy or Scala would be good choices.  Ruby might be a good non-JVM alternative.  The book "DSLs in Action" from Manning has good coverage of all 3 of those languages for use developing internal DSLs.  There is also a book from Packt about DSLs in Groovy - can't remember the name, read it a long time ago (it's probably 3-4 years old).
0

Please sign in to leave a comment.