Stefan Kuhn | 1 Oct 01:53
Picon

Internal DSL w Scala-Interesting ideas?

hi folks,

for my master studies I'm going to do a small project about domain 
specific languages. I suggested to examine how internal and externals 
DSLs work together. Coming down to earth, I would like to do that on a 
small example. I already got some experience with external DSLs (EMF, 
GMF, openArchitectureWare), so I can spend around 60-90 hours for an 
internal DSL in scala.

Do you have a good idea for an internal DSL? Something useful maybe? :) 
Or something where higher abstraction by an external DSL would be nice? 
Maybe graphical?

-stefan

Nermin Serifovic | 1 Oct 03:12
Picon

Anybody from Greater Boston area interested in starting a Scala user group?

Hello,

I am trying to figure out how many people would plan on attending meetings and also if there is anyone who would be willing to help in organizing the group?

Thanks,
Nermin

Meredith Gregory | 1 Oct 03:30
Picon
Gravatar

Re: Internal DSL w Scala-Interesting ideas?

Dear Stefan,

A really convincing and compositional language for graphs would be fantastic. i put together a bunch of desiderata for such a language. You can see some of my notes at theses Google docs.

i took it a bit further and built a little prototype with a lift frontend. You can find a little write up with pointers to source at this blog entry. (That was done nearly a year ago and lift has marched on so there might be bitrot. If you are interested and can't get it working, just give me a shout.)

The key idea i was following in my approach was to reverse engineer the graph polynomial discussed here to find a good compositional account of graphs. The polynomial is evidently extremely potent and has the added intriguing property of being very much reminiscent of the Kauffman Bracket -- which is almost certainly not an accident.

Some of my colleagues have considered other compositional models of graphs. Notably Philippa Gardner and Giorgio Ghelli have taken a process algebra based approach to modeling graphs and querying for them pretty far.

Finally, as some motivation, while notations like dot are easily understood they are essentially not scalable. The fact is that graphs are decidedly not made of nodes and edges. Graphs are made of graphs, and nodes and edges. Scalable models will have to take the compositional nature of graphs into account. That will also have the added advantage of taming some of the notorious complexity associated with graphs.

The applications of a good DSL for graphs are endless, but especially prominent, now, in the life sciences.

Best wishes,

--greg

On Wed, Sep 30, 2009 at 4:53 PM, Stefan Kuhn <qn.666 <at> gmx.net> wrote:
hi folks,

for my master studies I'm going to do a small project about domain specific languages. I suggested to examine how internal and externals DSLs work together. Coming down to earth, I would like to do that on a small example. I already got some experience with external DSLs (EMF, GMF, openArchitectureWare), so I can spend around 60-90 hours for an internal DSL in scala.

Do you have a good idea for an internal DSL? Something useful maybe? :) Or something where higher abstraction by an external DSL would be nice? Maybe graphical?

-stefan




--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com
Bill Venners | 1 Oct 04:35
Favicon
Gravatar

Re: Internal DSL w Scala-Interesting ideas?

Hi Stefan,

If you want to compare two existing external/internal DSLs that are
kind of similar, you can look at FeatureSpec with GivenWhenThen in
ScalaTest 1.0 (an internal DSL) and Gherkin in Cucumber (an external
DSL). A way to parse Gherkin steps in Scala has recently been added to
Cucumber, though I'm not sure how mature that is. Most people probably
use Ruby do to the Cucumber stuff.

Both the FeatureSpec and Gerken approach is I think more geared
towards higher level testing, like integration, acceptance, functional
tests more than unit testing. But people can use either for unit
testing if they want. The FeatureSpec internal DSL is more geared
towards programmers who are going to be writing and maintaining the
specifications/tests, whereas the Gherkin external DSL is more geared
towards non-programmers maintaining the specifications and programmers
maintaining the tests. Non-programmers might include
business/marketing people or software quality assurance engineers. But
again, programmers may do the external DSL anyway because they might
like it.

Info on FeatureSpec is here:

http://www.artima.com/scalatest/doc-1.0-SNAPSHOT/org/scalatest/FeatureSpec.html

Info on Cucumber and Gherkin is here:

http://cukes.info/

Note that the output of a FeatureSpec run with ScalaTest or some
Gherkin run with Cucumber looks almost identical. (Although my
scaladoc for FeatureSpec is black and white, if you actually run the
examples you'll also even see almost the same colors in the
FeatureSpec output as shown in the Cucumber examples.) The difference
is one input is an internal DSL, more suited for programmers, and the
other an external DSL, more suited for non-programmers.

Bill

On Wed, Sep 30, 2009 at 4:53 PM, Stefan Kuhn <qn.666 <at> gmx.net> wrote:
> hi folks,
>
> for my master studies I'm going to do a small project about domain specific
> languages. I suggested to examine how internal and externals DSLs work
> together. Coming down to earth, I would like to do that on a small example.
> I already got some experience with external DSLs (EMF, GMF,
> openArchitectureWare), so I can spend around 60-90 hours for an internal DSL
> in scala.
>
> Do you have a good idea for an internal DSL? Something useful maybe? :) Or
> something where higher abstraction by an external DSL would be nice? Maybe
> graphical?
>
> -stefan
>
>

--

-- 
Bill Venners
Artima, Inc.
http://www.artima.com

Ross Judson | 1 Oct 07:05
Picon

Re: Closures and Concurrency

It's arguable that if you intend to use a local variable on multiple threads, you should be requird to choose an appropriate synchronization mechanism. When doing so, you need to be aware of additional methods required to use the value appropriately.

val changes = new AtomicInteger()

instead of

<at> volatile var changes = 0

and then
changes set newValue

instead of
changes = newValue

A variety of methods on AtomicInteger exist to properly guarantee thread safety. With <at> volatile, how would you guarantee:

changes = changes + x

You can't unless you carry along the implementation of AtomicInteger. At the compiler level, translating <at> volatile to operations on AtomicInteger would have to recognize common expressions and invoke the "right" methods on the Atomic classes. You can't translate the code above in a simple manner, like:

changes.set(changes.get() + x)

It needs to be translated as:

changes.addAndGet(x)

RJ

On Tue, Sep 15, 2009 at 2:50 PM, Bill Venners <bill <at> artima.com> wrote:
Hi David,

Reusing the atomic classes is a good idea.

Bill

Ross Judson | 1 Oct 07:17
Picon

Re: Internal DSL w Scala-Interesting ideas?

You might find grgen to be of interest...it appears to be an efficient implementation of generative graph structures for .NET. It's likely to be instructive when implementing a graph DSL for Scala.

http://www.grgen.net

RJ

On Wed, Sep 30, 2009 at 9:30 PM, Meredith Gregory <lgreg.meredith <at> gmail.com> wrote:
Dear Stefan,

A really convincing and compositional language for graphs would be fantastic. i put together a bunch of desiderata for such a language. You can see some of my notes at theses Google docs.

Picon

Re: Internal DSL w Scala-Interesting ideas?

Stefan Kuhn <qn.666 <at> gmx.net> writes:

> hi folks,
>
> for my master studies I'm going to do a small project about domain
> specific languages. I suggested to examine how internal and externals
> DSLs work together. Coming down to earth, I would like to do that on a
> small example. I already got some experience with external DSLs (EMF,
> GMF, openArchitectureWare), so I can spend around 60-90 hours for an
> internal DSL in scala.
>
> Do you have a good idea for an internal DSL? Something useful maybe?
> :) Or something where higher abstraction by an external DSL would be
> nice? Maybe graphical?

What I've been thinking about (since we're using it a lot in our app :-)
is some kind of reporting/analytics DSL. Some mix between SQL (group by,
order by etc) and excel (pivot tables). We need something more advanced
than what can (easily :-) be done in straigt SQL: Grouping into
intervals, converting between different units of measure etc.

Basically, get a (potentially large, but in-memory) bunch of objects
into a list and be able to slice'n dice any way you see fit....

/Jeppe

Florian Hars | 1 Oct 09:17
Picon

Re: a little sugar for Option

Tony Morris schrieb:
> def f(v: Option[Int]) {
>   printf(if(v.isDefined) "=" + v.get else "=?")
> }

Far too verbose.

def f(v: Option[Any]) {                                       
   printf((v :\ "=?")((x,y) => "=" + x))                     
}

- Florian

Bill Venners | 1 Oct 09:15
Favicon
Gravatar

Re: Closures and Concurrency

Hi Ross,

On Wed, Sep 30, 2009 at 10:05 PM, Ross Judson <rossjudson <at> gmail.com> wrote:
> It's arguable that if you intend to use a local variable on multiple
> threads, you should be requird to choose an appropriate synchronization
> mechanism. When doing so, you need to be aware of additional methods
> required to use the value appropriately.
>
> val changes = new AtomicInteger()
>
> instead of
>
> @volatile var changes = 0
>
> and then
> changes set newValue
>
> instead of
> changes = newValue
>
Yes. The compiler already does that kind of thing on IntRef, though
IntRef doesn't have getters and setters, just a public field.

> A variety of methods on AtomicInteger exist to properly guarantee thread
> safety. With @volatile, how would you guarantee:
>
> changes = changes + x
>
> You can't unless you carry along the implementation of AtomicInteger. At the
> compiler level, translating @volatile to operations on AtomicInteger would
> have to recognize common expressions and invoke the "right" methods on the
> Atomic classes. You can't translate the code above in a simple manner, like:
>
> changes.set(changes.get() + x)
>
> It needs to be translated as:
>
> changes.addAndGet(x)
>
I think you mean incrementAndGet, but regardless, that's not what
volatile means. Volatile doesn't offer any atomic operations, just
that threads will read what other threads write. But if you want to
get an increment a variable as one atomic operation, then you can't
use volatile. So I think all the compiler would need to do is call set
and get, because if it were to do this kind of thing, it should stick
100% to what volatile means elsewhere.

But your initial point is correct, it can be argued that the behavior
we have now is OK and people just need to take care of making things
work themselves. That's what I do right now in my multi-threaded
tests. I make my own atomic integers. The problem is that because
volatile in Scala is an annotation, you can put it on a local
variable, and it will compile. So it *looks* like it is volatile. In
Java, because volatile is a keyword, it won't compile if you try and
put it on a local variable (and of course it wouldn't make sense
because Java doesn't have true closures anyway).

Bill

> RJ
>
> On Tue, Sep 15, 2009 at 2:50 PM, Bill Venners <bill <at> artima.com> wrote:
>>
>> Hi David,
>>
>> Reusing the atomic classes is a good idea.
>>
>> Bill
>
>

--

-- 
Bill Venners
Artima, Inc.
http://www.artima.com

Tony Morris | 1 Oct 09:21
Picon

Re: a little sugar for Option


Florian Hars wrote:
> Tony Morris schrieb:
>   
>> def f(v: Option[Int]) {
>>   printf(if(v.isDefined) "=" + v.get else "=?")
>> }
>>     
>
> Far too verbose.
>
> def f(v: Option[Any]) {                                       
>    printf((v :\ "=?")((x,y) => "=" + x))                     
> }
>
> - Florian
>
>
>   
I'm not sure if you are joking. The beauty of this is that I can pretend
you are.

--

-- 
Tony Morris
http://tmorris.net/


Gmane