Language Oriented Programming

__Language-oriented programming__ (__LOP__) is a style of computer Computer programming in which, rather than solving problems in general-purpose programming languages, the programmer creates one or more domain-specific languages for the problem first, and solves the problem in those languages - wikipedia

- Racket (programming language) - Original paper by Martin Ward - pdf

# Concept

The concept of language-oriented programming takes the approach to capture requirements in the user's terms, and then to try to create an implementation language as isomorphic as possible to the user's descriptions, so that the mapping between requirements and implementation is as direct as possible - wikipedia

A measure of the closeness of this isomorphism is the "redundancy" of the language, defined as the number of editing operations needed to implement a stand-alone change in requirements.

It is not assumed ''a-priori'' what is the best language for implementing the new language. Rather, the developer can choose among options created by analysis of the information flows - what information is acquired, what its structure is, when it is acquired, from whom, and what is done with it.

c2.com

Language Oriented Programming just got a face-lift (Nov, 2004). Sergey Dmitriev has published and article titled Language Oriented Programming: The Next Programming Paradigm. See www.onboard.jetbrains.com . His argument is that LOP will be the next programming paradigm after OOP - c2.com

It seems pretty compelling to me (but then again, I'm the editor of the article, and an employee of Jet Brains). We're looking for feedback, discussion, and especially criticism. I'm sure the wikizens have an opinion on this. What say ye?

I was going to respond on Lambda The Ultimate, where there's currently a forum discussion on this topic, but Wiki lets me link more easily...

First off, there's a large amount of prior research in this direction, and not just in the Lisp world. I think it's worth taking a look at:

Ml Language (ML initially stood for "Meta Language", and was designed to make construction of compilers and DSLs easy). There's a good presentation on how to write a DSL in Ocaml in a day at www.venge.net .

Rebol Language. Rebol was initially supposed to be a universal data-exchange language. Everything Isa dialect in Rebol, allowing you to adjust the language on the fly. There's native BNF (Backus Naur Form) support, and execution can alter the parsing of subsequent tokens (this fact makes Rebol impossible to compile, but also makes it ideal for DSLs). From the sample Rebol code I've seen, it looks a bit easier than the Language Oriented Programming examples in the article.

Preprocessors + combinator libraries in Haskell Language. The two that come to mind are Haskell Db and WASH. Haskell Db is a replacement for SQL that lets you write Relational Algebra expressions directly in Haskell. WASH is a webapp framework that's kind of like Active Server Pages for Haskell, except it tends to integrate a bit better because Haskell code is already declarative. There's also Fudgets, a GUI library in pure-functional style.

D-expressions in Dylan Language. There's a paper on this by Jonathan Bachrach, and it's the implementation strategy in Functional Developer. This is a way to tap into the Abstract Syntax Tree of parsed Dylan code fragments, except it actually works at a slightly higher level (the skeleton syntax tree). It then provides a Generic Function interface to manipulate code fragments. Basically all of Dylan syntax is represented as D-expressions in Functional Developer, which is an elegant approach that unfortunately leads to impenetrable error messages when using that IDE. DSLs like the Dylan User Interface Manager are done using Dylan macros.

David Moon's ideas on defsyntax (www.archub.org ). I'm not sure I think this is a terribly great approach; BNF already provides a good mechanism for defining syntax, and providing an ad-hoc alternative just seems like a needless fragmentation.

The internals of Parrot Code. Parrot is written in Cee Language, but it's C that's heavily preprocessed by various Perl Language scripts. As a result, there's a DSL to define PMCs, to define opcodes, to define JIT operations, and so on. Dan Sugalski gave a presentation about the use of DSLs in Parrot at some recent convention.

As for whether Language Oriented Programming is a good idea, I see two big Stumbling Blocks For Domain Specific Languages (content moved there, hope you don't mind.)

Previously, discussion of LOP on this wiki was based on Helmut Leitner's interpretation of it. See www.wikiservice.at for information about that. The 'new' LOP is technically derived from the same source, which was an article titled Language Oriented Programming by Martin Ward (www.dur.ac.uk ). However, Helmut took a very different approach to it, so his LOP is not the same as Sergey Dmitriev's LOP.

Xactium has some interesting technology that realizes this vision (their whole tool is defined using itself). A book can be freely downloaded from their website (www.xactium.com ). It seems that this technology has migrated over to this other website (www.ceteva.com ). There you can find everything formerly located at Xactium's site and much more.

The early access to Meta-Programming System is started in June 2005 at www.jetbrains.com .

Would the opposite be "attribute-based" programming, such as a Business Rules Metabase?

Not necessarily. The definition at the top of Business Rules Metabase states, "[r]ather than coding Business Rules in a generic language Java, C++ etc.[, p]ut them in a high level language/database explicitly for the purpose of storing and enforcing business rules." I would interpret a high level language for storing (and representing) and enforcing business rules as being something that could conceivably employ Language Oriented Programming.

If it's a language, I wouldn't call it a "___base". I dissagree with that definition.

Didn't this used to be called 'metalinguistic abstraction'? Why did it need a new name? -- Bryan Edds

Hi Bryan, I see 'metalinguistic abstraction' is an abstract concept that doesn't tell you how to construct the language. It also assumes, from what I read that an application specific language is the results. My concept is more concrete by providing a dictionary and rules, so you can see it as an specific implementation of the 'metalinguistic abstraction'. On the other hand, it has a more general forcus as a cross-application meta-language, with a special focus on reusable libraries and modules. -- Helmut Leitner

The article about language oriented programming is full of nonsense and tautology. First, programming has always been "language oriented" so the article title and concept is meaningless. That is how you program: you use a computer programming language. The title "language oriented programming" is redundant, since programming has always been oriented around programming languages. Second, in the article he says he never thinks of programs as a list of things to do (set of instructions). This is complete nonsense. What is the first thing that comes to mind when you want to build an input form on a website: first I want the user to input his data, then I want to collect the data, then I want to store it in a database. These are all very procedural ways of thinking, and this model works well.

.

# See also