Sergey Dmitriev, of JetBrains, the company that develops the Java IDE “IntelliJ IDEA”:http://www.jetbrains.com/idea/, wrote an article on Language Oriented Programming. According to Sergey, the current programming paradigms are seriously flawed and we need a new one.
The question Sergey asked himself is why it is so that you can explain a solution to a problem to a programmer in an hour or less and it can take weeks to explain the solution to a computer. The answer, according to Sergey, is that our solution description has to fit the syntax and instructions of a language the computer understands. This instruction set usually is quite small and for many reasons that’s good; if you have to use a programming language that’s as complex as natural language, people won’t be happy. Instead, programmers tend to lean towards general purpose programming languages. These languages are not good at anything in particular, just moderately good at mostly everything. What we have to do is reformulate our solution to terms that the compiler of that general purpose language understands. This is like explaining something very specialistic to a laymen: you can’t use any terminology and shortcuts, because the layman won’t understand them. The consequence is that you need a lot more words and time to make it clear.
It’s the same with programming languages. That’s why we should work with Domain Specific Languages (DSLs). These languages contain all the “terminology” and shortcuts for that particular field and therefore a solution can be made clear much faster and effective. Take SQL(Structured Query Language) for example. SQL is a DSL. With SQL we can formulate very complex queries with just a couple of lines of code. Imagine having to do that with a general purpose language like C. It’ll be a lot more work. Each area of speciality has its own language and way of describing things, therefore they also need their own DSL. “Language” should not be taken too literally here. In some occassions a textual representation simply isn’t suitable. GUIs, for example, today are often described in code, even though they are completely visual. It would be much more obvious and efficient to draw GUIs visually (and many IDEs already offer a “language” for this; which they call a form designer).
The solution Sergey proposes is Language Oriented Programming (LOP). The idea is that you first design a programming language for a particular part of your problem solution and then use that language to describe the solution. Because writing compilers and designing languages until now never has been an easy job, a simpler method has to be figured out. Sergey shows a fairly simple way to do this. It’s not easy to describe it in a couple of sentences, so if you’re interested you can read his paper. Once you’ve developed the language that you’ll be using, a language that allows you to express yourself in the way that suits your solution, actually describing the solution is a much faster process.
Sergey is already working on an implementation of this sytem, called “Meta Programming System”:http://www.jetbrains.com/mps/ (MPS). Once released, this system (which will be part of IntelliJ IDEA) will come with three predefined languages. One imperative one, which contains the usual control structures, variables, operators etc. The second is a collection language. This language is targeted at using and manipulating collections (such as arrays and hashmaps). The third one is a language for defining graphical user interfaces.
I think it’s a very interesting idea. There are two things that I think are vital for this to succeed:
* Languages really should be very easy and fast to design. If this takes too much time, it’ll be faster to just use a general purpose langauge.
* The languages should be able to collaborate nicely. The concepts used in different languages can be completely different. There should be a way from a database manipulation language to get data from the GUI written in a GUI language.
I’m looking forward to actually seeing something like this in action.
You can find the “whole article on LOP here”:http://www.onboard.jetbrains.com/articles/04/10/lop/index.html.