Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Language Oriented Programming with XMF

  Asked By: Pedro    Date: Sep 28    Category: Java    Views: 5990

The history of programming languages evolution has involved moving away from how the machine represents programs (i.e. assembler) to how humans conceptualize them. Contemporary languages like Java are perhaps as abstract from the machine as is possible while still remaining general purpose. The next logical step in this progression are DSLs which by their nature are going to have some level of specifity to the application being constructed.

Language Oriented Programming (LOP) is concerned with giving users the mechanism to define DSLs or to extend existing ones. XMF is an open source programming language which supports the LOP paradigm. All aspects of XMF can be easily extended or redefined at run-time allowing the dynamic construction of domain specific languages (DSLs) which can be used either standalone or weaved into existing DSLs. The following example shows how program languages defined in XMF (Java, Lisp, PHP and XOCL) can be woven together to specify a program:

parserImport Languages::MicroJava;
parserImport XOCL;
parserImport Parser::BNF;

import LispOps;

context Root
@Operation count(S:Seq(Element)):Integer

context Root


class X {

int x ;

public X(int x) {
this.x = x;

public int test() {
Vector ints = this.descending(x);
Vector ascending = this.reverse(ints);
Vector facts = this.mapFact(ascending);

with JOCL {
@Operation mapFact(s:Seq(Integer)):Integer
s->collect(n | self.fact(n))

with JOCL {
@Operation reverse(S:Seq(Element)):Seq(Element)


with JLisp {
(let ((Fact
(lambda (fact)
(lambda fact (n)
(if (eql n 0)
(mult n (fact (sub n 1))))))))

(Y Fact))

with JLisp {
(let ((descending
(lambda descending(n)
(if (eql n 0)
`(,n . ,(descending (sub n 1))))))))
(Y descending))

with JPHP {
function printCollection($collection) {
for($i=0;$i<count($collection);$i++) {
echo $collection[$i]




1 Answer Found

Answer #1    Answered By: Janelle Evans     Answered On: Sep 28

This might be a wrong take on LOP, but the thing is that LOP has not
stabilized enough yet so that people have a common language  about it.
I personally tend to agree to JetBrains' view on LOP, and their MPS
system in which LOP comes as a language design tool as compared to a
language mixing tool. That is, it gives an environment in which one
can define a DSL for each problem domain  in question. In any events,
thanks for bringing this up and I appreciate if you fill me in with
similar stuffs. My nerdy side is kicking in....

Didn't find what you were looking for? Find more on Language Oriented Programming with XMF Or get search suggestion and latest updates.