English Source:
http://www.onboard.jetbrains.com/is1/articles/04/10/lop/
Chinese Source:
http://blog.9cbs.net/chelsea/archive/2005/02/17/290486.aspx
Language Oriented Programming: The Next Programming Paradigm
Sergey Dmitriev, JetBrains
It is time when the software development is started, and the contour of this revolution is getting clearer. The next generation programming is close to us, but there is still no complete formation - different parts have different names: intional programming, MDA, Generative Programming, etc .; I suggest that all these new methods are merged into one name: ' Language-oriented programming ', and this article will explain the main principles of this new programming model
Today, the mainstream programming method has some intrinsic assumptions like our ropes on the neck, although most of the programmers have not realized it; even in the programming field, we are still in a stone era; we With our trust, the stone ax (object-oriented programming) can meet our needs, but when it is used to deal with the most difficult problems, it will crack into debris; in order to go beyond the stone, we have to tame the fire, only this, we In order to create new tools, inspire a new era of creation, and the explosion of new technology
I will discuss the limitations of the programming, it is forced to think about the computer like a computer, not to think about the computer like programmers; this is a serious, rooted limit, need to spend a huge effort to overcome it; when I say this will be I didn't have an extraordinary when the next large model conversion; we need to completely redefine the method of our writing programs
In this article, I expressed my point of view and I am currently working on Language Oriented Programming (LOP); first I will show the current mainstream programming method, then I will use the example to explain the concept of LOP, they are based on I have A LOP implementation: The Meta Programming System (MPS). This article is intended to give you a glimpse of LOP, the purpose is to stimulate your interest in this idea and hope to get feedback and discussion.
Part I. Language Oriented Programming Overview
Language Oriented Programming and The Meta Programming System
Ideally, make a programmer means that I can do anything about the computer, I have a complete freedom, complete control; but in fact, today's programmers have only very limited freedom; of course, I can do it on the computer. Do anything, but some things take me for many years, and they actually need less time; there must be something wrong
Programmers are limited because they deeply depend on programming infrastructure they can't easily change: programming language and development environment; if I need some language extensions, I can only wait for language designers to update it; if I need My IDE has some extra power, I can only wait for suppliers to add new features; these dependencies limit my complete freedom; of course, I can write my own compiler and IDE, actually, this is me The reason why INTELLIJ IDEA was launched because I was tired of relying on existing weak Java IDE; however, this will cost a lot of time and effort, and it is obvious, it is not feasible to most of the programmer; theoretical There is a huge difference between freedom and actual freedom; when I talk about freedom, I refer to the actual freedom to obtain freedom is to reduce our dependency level; for example, a main goal of Java is to reduce the operation The system's dependence, the freedom to developers deployed on different operating systems; therefore, in order to get freedom on language and environments, we need to reduce their dependence
Why is this a problem? Any gener-purpose language, like Java and C , give us the ability to do anything with your computer; this is the fact, at least theoretically, but General-purpose's language tends to be as follows. Production efficiency is low; as an alternative, we can use Domain-Specific Languages (DSLS, AKA 'Little Languages), which is carefully designed to have high productivity in a particular problem domain, such as writing database queries with SQL; The field is related, and it is also their weakness, because the programs in any real world will include many different areas.
Between General-purpose and DomainSpecific; I need all the freedom, I hope to do anything, there is very high production efficiency; there is no good way to do this; ideally I can use different languages for each particular part of the program, and they can work together, and the development environment will fully support these languages, including all other productivity tools, navigation, and mainstream languages.
In order to get this independence, I need to have freedom of creation, reuse, modifying the language and the environment; in order to make this freedom are feasible, it needs to be easily obtained; if we solve the development of language and environment Question, will be a huge progress on programmers; this is the entry point of language oriented programming
To understand what language oriented programming is, let's take a look at today's mainstream programming method, it is basically like this:
Reflections: You need to program a problem, so you have formed a concept model that solves this problem in your mind.
Select: You have chosen a language to write a solution for a language of General-Purpose.
Program: You write solutions by mapping your concept model to programming languages
Programming is the bottleneck, because most of the case is not easy and natural; this approach has proven to be inefficient in the complex design of programmers; relative, the following is the way to work:
Thinking: You need to program a problem, so you have formed a concept model for solving this problem in your mind: You have chosen some specific DSLS to write solutions
Create: If there is no suitable DSL to fit your problem, you create a DSL to adapt to your problem.
Program: You write solutions by bringing your concept model to DSLS to DSLS
Now, this step is Much Less of A bottleneck, because DSLS greatly simplifies how to translate problems into something you can understand; it seems that difficulties have been simply transferred to "create" this step, however, through joint use Tool support and use LOP to itself, which will make this step more simple
The motivation behind LOP is basically like this: I want to work with the concepts and intentions I am trying to solve the problem, rather than being forced to translate my thoughts into a language that can be understood by a gener-purpose. (Such as: class, method, cycle, condition, etc ...); In order to achieve this goal, I need to use Domain-Specific Languages; how to get them? Create them;
I have begun to develop a generalized platform to design DomainSpecific Languages with tool support and development environments; it will allow programmers to define languages as they are written as they write; this platform will fully support LOP, Select the freedom to use the most suitable language for each part of the program, instead of tie them on a fixed general-purpose programming language
MPS is just an example of Language Oriented Programming, although I use MPS here to do an example, and actually LOP can be implemented in many different ways, you may know some alternative methods; LOP's concept is not equivalent to its implementation Just like the concept of OOP is not equivalent to Java or C or SmallTalk.
What is wrong with mainstream programming
You know this ancient proverb: "if it a a in't broke, don't fix it". The mainstream programming method is obviously incomplete, I have seen many of the problems that it brought, and most of them are in such a fact: The language of General-purpose has no way to fully support any field, and there is also no unified Domain-Specific Language; the following is three worst problems that will be resolved by LOP:
Time Delay to Implement Ideas
For me, the most serious problem is that in my exact know how to solve a problem, and I have a long time difference between the solution to the computer through a program, I can use a few hours. Time to other programmers interpret questions and solutions, and how long is the solution to the computer will take a long time; this is because of another programmer, I can use a natural language with very rich ability, but Computer, I can only use a very expression ability. General-purpose's programming language; today's programming language can only express dozens of concepts, and natural language can express thousands of concepts; therefore, to another procedure Interpretation of the problem, I can express the high-level thinking, and to the computer, I must express every detail of each step.
In mainstream programming, most of the time is "programming", in fact, in the future, the method of expressing abstract terms in programming, which is very difficult, not much creative, or More or less is a waste of time, and today, a large number of development time is spent on object-oriented design (OOD), which is indeed a creative in terms of programmer's expression, inheritance, association and other aspects. Process; the purpose of this practice is to use object-oriented terms, such as classes, and methods, to express the program; the process of OOD is necessary, because such as classes, etc., such as classes, etc. It is necessary and creative, but uses Language Oriented Programming, OOD does not need
Understanding and mosttaining existing code
The next question is to understand and maintain existing code; no matter whether it is written by another programmer, the problem is the same; because the language of General-purpose needs me to translate the high-level field concept into a low-level programming language character, in In the final program, many highly summarized perspectives, the blueprints are lost; when I re-read the program later, I have to understand what I originally intent by reverse engineering, what is the model in my mind; at least, I have to re-build information in the process of translation to General-Purpose's programming language in my mind.
The traditional way to solve this problem is to write a comment or other form of document to record design information and model information. There are several factors that have proven this is a fragile solution, including at least the cost of writing these auxiliary documents, and The documentation and code are gradually a trend; and there is another fact that it is not widely recognized, that is, the documentation does not directly connect to the concept it records; the comment and source code are bound to the same place, but the concept may In multiple places in the source code; other types of documents are completely separated from the source code, only indirect reference source code; ideally, the code should be self-description, I should only read the code itself to understand the code , Not any comment and external document
Domain Learning Curve
The third main problem is to extension related to the field of language; for example, the main method of extending the language in OOP is to use class libraries; the problem is that the library is not expressed in terms related to the field concept, but using low-level Abstracts of General-Purpose are express, such as classes, such as classes, etc. A good common example is the GUI library and the Database library.
Learning these libraries is not a simple task, even if you are an expert; because the mapping from the field to language is not straightforward, you must learn this map; this means a steep learning curve; usually we try to use a lot Guide and documents to solve this problem, but learning these will spend a lot of time; when a class library is complicated, it has become more difficult to learn, the programmer will lose its motivation
Even after the complex map is mastered, it will still be easy to misuse the class library, because the development environment (like a compiler and editor) cannot help you use the class library correctly, call one for these tools, call one The method of the GUI object and the method of calling a DB object: they are only the method calls on the object, there is no more meaning; remember which classes and methods should be called, in what order is called, etc. They are all responsible for users. Even if you are both expert in the field expert, it is also a very long problem of using the program written programming; relatively simple field concepts need complex measures to call correctly; for example, Any developer who used Swing is clearly clear; writing a simple program has spent too long, complex procedures are even worse
Details of LOP
What is a propram in lop?
Today, the programmer of 99% believes that programming is to write a string of computers that can be implemented; we are educated to be based on the computer model, so they use the terminology of the instruction set to "think"; This programming point is defective, it confuses the purpose and means of programming; I will demonstrate why LOP is better than the traditional programming method, but first I must clarify the following fact: a LOP program, not a string of instructions So what is it?
When I have a problem to solve, I think about the solution in my mind, this solution uses words, tags, concepts, ideas, or any name you like, how to solve the problem in my mind; I almost Never imagine them into a bunch of instructions, but I am a collection of specific concepts in the field of work; for example, when I think when I think the GUI field, I imagine "this button to go there, this input domain To this, there is a list of some data in this combo box "; I even just draw it in my mind, I don't have to use any speech.
The reason why I think this kind of idea is a solution because I can use enough details to explain this model to another, so that he can sit down and write a program to solve this problem (such as using java); I don't It is necessary to explain this program, which can be any form; for example, in order to explain how to lay out a GUI form, I just need to draw this form; if the painting has enough details, the painting itself represents The solution is a solution; the expression related to this field should be the program. In other words, there should be a way to allow us to use this expression as a real program, not just means to communicate with other programmers; then this exports my definition of the procedure: A program is any one for one There is no dismissal solution, or more accurate: A program is an exactly defined model for any use of a problem with a problem with a problem in a certain field.
That is, the programmer should have the main reason for the freedom of creating their own language: so they can express the solution in a more natural form; General-Purpose language is unambiguous, but too redundant and easy error The natural language (such as English) is very rich, but it is difficult to use because it is too uncertain too. We need to create a formal, precisely defined, field-related language; So Language Oriented Programming will not just write a program, but also the language to create the program; our program will be written closely to the problem domain instead of the computer instruction set, so they will be very easy to write Programs and text
People habitually think that the program is stored as a text, that is, a byte stream; why shouldn't it be? After all, there are countless tools to edit, display, operation text; today's core part of today's programming language is a text-oriented, parser, compiler, and row-oriented debugger; but the text is only a manifest form of the program; Text; forcibly put the program into the text, causing a lot of questions you may not know; we need a different way to store and work with our procedures.
When the compiler compiles the source code, it is called a tree structure called an abstract syntax tree; when the programmer reads the source code, they have the same thing in the mind; we still have to consider the program Tree structure; this is why we have to have curly brackets, square brackets, parentheses, etc .; this is why we need to format and indent code and comply with coding specification, because this will be easier to read source code
Why do we use text storage? Because the most convenient and most common methods of current, reading and editing procedures are still using a text editor; but we will pay a price for this, because the text of the program indicates a major disadvantage, where the most important thing is that the text-based programming language is very difficult Extension; if the program stores in the form of text, you will need an unambiguous text-oriented to resolve the program; when the new feature is added to the language, the extension of the maintenance language has become increasingly difficult; we will need to invent more Multi-type parentheses, operators, keywords, sequential rules, nesters, etc .; language designers spend numerous time to think about grammar, and try to discover new methods for extended language.
If we plan to make the creation language easy, we need to leave the program's representation and storage from the program itself; we should directly save the program as a structural map, because this allows us to make anything we like to language; sometimes, sometimes, We don't even need to consider text storage at all; a good example of today is an Excel Spreadsheet. 99% of people do not need to process storage formats. When this is a problem, there will always be a variety of import export features; Today, the real reason we use text is that we have no better editor than the text editor, but we can change this.
The problem is that the text editor is very stupid, and does not know how to work with the program's graphic structure; but use the correct tool, the editor will be able to work together directly with the graphics structure, and let us freely use any editor We like visual expressions; we can make procedures into text, tables, pictures, trees, or any other form; we can even use different expressions for different purposes, for example, graphical representation to browse, text The chemical representation is used to edit; we can use the field-related representation of different parts of the code, such as using graphical mathematical symbols for mathematical formulas, using graphical charts for the chart, use rows and columns for Spreadsheets, etc. To use the most suitable form of performance in the problem domain, it can be text, but not limited to text; the best performance form relies on how we think the problem domain; the flexibility of performance will also make our editor more powerful than ever, because Different expressions have different ways to edit their What is a language in lop?
Finally, I should clarify what I think is "Language"; in LOP, a language is defined by three main elements: structure, editor, and semantics; structures define abstract syntax, support concept, And how to arrange them; editors define specific syntax, how to draw and edit language; semantics definition behavior, how it is interpreted, and how it is converted into executable code; of course, language can also have other aspects, Such as constraints and type systems
Part Ii. Introduction To Meta Programming System
Creating Languages in MPS
I have explained why we need to easily create a new language, but how can we make it easy? If you have this problem, and use the language oriented programming to itself, you will soon see the answer; this calls for a little self-referential bootstrapping, Which can see Tricky, but be patient. Once you understand this, You will get the true power of LOP (a LOP's meta-level)
Review the concept of LOP: make it easier to create DSLS, and these DSLs will make the writing program easier; but just like I have explained, 'program' unlimited in LOP means you have used the typical "a bunch of" Program of instructions; any problem with a problem in a certain field is 'program'; so if you imagine the field of "Creating a New Language", then 'Program' in this area, It is a definition of a new language that can be thought of as a solution, just like a solution in any other field;
Therefore, applying LOP thinking, making the "Creating New Language", which is to create a specific focus on "Creating a new language" domain DSL; we can make new languages by applying these Language-Building DSLs More easily; let us see a few examples of language-building languages, making you better understand how they work; just an overview, I will describe them more detailed in the future article.
Structure language
Minimal and minimum, we need to define the 'structure' of a new language; what we are we can write "precise definition" procedures; language structure does not mean its text form of text form - like I mentioned, This language does not even have text representations and only graphical representation. When practical LOP, most cases, you will work in two levels of programming: Yuan level and program level; you define language in the meta level, Write a program in the program level; when defining a new language structure, you will use a Language-Structure DSL to define your new language, at this time, you will work at the same time in this Language-Structure DSL program. Hierarchical and new language
In MPS, each node of the program level has a "type", simple connection to another node of the meta level; this node of the program level is called a "instance" of this type; the meta-level " Type node defines this type of instance to have the relationship and attributes; describes the language of such a hierarchical language structure, it is simply referred to as "StruCTure Language"
Using Structure Language Defines a language of a language, you should just enumerate all types of this language; the type is simple to represent the characteristics or concepts of this language; each concept should use its name, the internal properties of the instance , The relationship between examples and other nodes (usually connected) to define
There are two possible associations; the first is the association of similar polymerization, which forms a parent-tree structure of a conceptual model; the second is non-polymerizable, free-form association, which can be connected to any other node in the system; There are two endpoints: source and goals; related roles, you can define the name of each role, multiple of each endpoint, the type of each target node; multiple sex can be 1, 0..1, 0 .. N, 1..n, etc., let you confine the association how much connection can be created; the associated target type can be used to constrain which type nodes can be connected together
Therefore, using the new language writing program includes: Creating an instance of the concept in a language, assigning the attribute of the instance, connecting the nodes in the program together according to the relationship defined by the language concept; all of these will be supported by the powerful editor, you can Define this editor for your language
Editor Language
So what should the interface to write and operate the concept model? Our language requires several types of editors, but we don't want a universal editor; experience shows that the general editor can not be useful as we hope; we want to write a model quickly, so we need to be special for our language Conceptual customized editor; somewhat, editor is part of the language, and our goal is easy to create a new language, then create a new editor should be very easy; in essence, we need a creation editor The language of the device, in the MPS, it is called Editor Language
When people listen to me, our program will be stored as graphics and we need a specific editor, I am sure that many people think that I will talk about the graphic editor, the fact is not such a way, although the program is a graphic form, the editor is not necessarily It is not to depict the program into a graph; in fact, the graphic editor is useful if the graphic editor is (that is, when it is suitable, for example, the database table); instead, our Editor Language has a better source of inspiration , Satirical is that it comes from a text editor
If you use a text editor to browse a typical program, you can imagine the editor is divided into a rectangular unit; some units contain the required identity such as keywords, currency, parentheses, etc., other units contain user-defined identities, such as The name of the class and method; the large unit consists of small units, and the method block contains the statement, and the statement may contain its own nested block; in fact, any good construct in any mainstream programming language can be decomposed into a rectangular unit Collection; then, in Editor Language, you don't need to imagine these units, because the editor is a simple advantage of the use of the unit consisting of the rectangular unit; first, when work directly in the program graph, not the program text At the time, the unit can be perfectly imitated and even exceed the standard text editor; second, the unit is not limited to text, you can put into the unit into the color picker, mathematical symbol, chart, vector illustration, or anything else; final Layout in this unit form is optional, and the programmer can provide different mechanisms, the unit form of layout is just a useful default setting.
Therefore, Editor Language helps you define the layout of the unit corresponding to each concept in the language; you can define which parts are constant, such as parentheses or other modified symbols, which are variable, need users to define; Editor Language Help you add a powerful feature in your own editor, simply complete, reconstruct, navigate, syntax highlight, error, and anything else you think; so you can add the current editor such as Intellij IDEA Waiting for your own language; this is possible, because the programs and languages are constructed as graphics, and we have special Editor Language help us create a powerful editor.
Transformation Language
Structure Language and Editor Language have jointly provide some features that you can use them with others, such as painting UML diagrams, or write other types of documents; however, most of our time we want our code to do something, Therefore, we must find a way to make it possible; there are two main ways to do this: explanation and compile
DSLS Support Interpretation helps define how the computer should interpret the program, the compilation method supported by DSLS helps define how to generate executable code for the program; I will discuss the explanation method in future articles, now I want to explain how MPS is Support compilation
Compiling means to get the source code and generate some form of executable code; there are a variety of possible forms for the result code; in order to generate the executable code, you can generate a local machine code, or generate a virtual machine node code Or, you can generate the source code of another language (such as Java, C ), then convert with an existing compiler to an executable code; similar, you can even generate source code for some explanatory language, with Existing interpreter explanation
In order to avoid handling such a wide object format, our method is to do everything with MPS; first, you use Structure Language in MPS to define a target language, this target language and target format should have direct One-to-one mapping; for example, if your target format is a machine code, you should use MPS to define a target language for the machine code; if the target format is a Java source code, you should define a kind of Java target language; goal Language does not have to support all functional features of the target format, only a simple one-to-one mapping for the language characteristics you need, you can compile two phases: a simple translation from the target language to the final result, one More complex from the original original language to the intermediate target language; the translation stage is slightly, so we focus on the more interesting stage; at least, the current problem is simplified in order to convert the model from a language to another A language; however, it is possible to be completely different from the target language. So we need a model to convert DSL to help us; in MPS, this DSL is called Transformation Language
There are three main methods of code generation, we will use them to define model conversions; the first is traversal, you enumerate all nodes in the source model, check each, and generate some target model based on the viewed information Target node; second way is to use templates and macros to define how to generate target languages; the third way is to use mode matching to find transitions on which nodes in the source model
We combine these ways to support any way by defining DSLS; these DSLs will work together to help you define conversions from a language to another; for example, traversal inspiration, it Make the enumeration node and the collection information from the conceptual model is simple and easy; you can imagine it into some kind of SQL for a concept model; as an extra reward, having a powerful query language is not just a code generation Useful (for example, enable editor smarter)
Templates
Template method works Similar to Velocity or XSLT; template looks very like target language, but allows you to add macros in any part of the template; macro is inherently executed when it runs the conversion; macro allows you to check the source model (Use Model Query Language "and use the information obtained" Fill "to get the final target code
In Figure 5, you can see the definition of the template for the concept "Property" generated Java code, the template adds Field Declarations, Getters, Setters, etc .; this template is the generator of the code from Structure Language to Java. Part
Since the template looks like the target language, you can imagine the template is written in a special language based language-based language; this is also its factual working method; we actually use a generator to generate a template language for you. It is not manual to create a template language for each possible target language; it is basically a copy target language and adds all template specific features, such as macro, or even the template editor is also generated from the target language editor, so you are the same No need to handle code
When you use a template language, you can think it is written in the target language, just some part of the code is parameterized, or by macro; this technique is greatly helped to simplify the code. Generate; templates can also be used on other tasks, such as reconstruction, code optimization, more ... Patterns
Model mode matching method gives us a powerful method of finding model as model query language; you can imagine the regular expression of the concept model; similar to the template method, we are based on the source language mode language; mode language It looks like a source language, just adds some features to help you define a flexible standard that handles complex source models; you can imagine this method into a powerful "find replace" technology; once again, mode language is not It is useful to generate the code, for example, they are very useful in writing automated code inspection tools for the source language editor.
Remember Model Query Language, and Pattern Languages supported automatic completion, reconstruction, reference check, error survey, etc. The code generation has never been so powerful.
USING LANGUAGES TOGETHER
The chapter of the previous code generated has brought some interesting questions about how these languages work together; in fact, there are several ways to work together; in the MPS, all concept models know each other; since the language is also a concept model So, it means that all languages are known to each other, and can be attached together.
Languages can have different relationships between each other; you can create new languages by extending existing languages, inheriting all concepts, modifying some, and adding your own concept; a language can reference the concepts in other languages; You can even insert a language into another language; I will discuss further details in future articles.
Platforms, Frameworks, Libraries, And Languages
We support Language Oriented Programming system requires more functions to be more useful. It should provide programmers to rely on all things provided by current programming languages: collection, user interface, network, database connection, etc.; Not only is the language itself to select the language only, for example, most of Java is not a language provided, but there are thousands of Framework and API for Java programmers to choose; they are not Java language, but the whole Java platform; MPS will also have its own support platform
Before I enter the details, let's briefly talk about Frameworks; what is Framework? In mainstream programming, it usually means a category library that is packaged in a pile and method; let us see this more, see what we will see under LOP's lens.
Why do we want to pack classes and methods into a library? The programmer will tell their professor once told them: "Rearrange"; but this is only left in the original position: Why do we need to reuse class libraries? The answer is that the class library is useful in solving a particular type of problem, such as making user interfaces, access database, etc. You can say that the class library corresponds to a field; you, we see contact, Class Libraries Are Wannabe DSLS! This Sad facts really make me frustrated
Today's Domain-Specific Languages exists in the form of class libraries, except that they are not a language, there is no language advantage, and have all limitations of classes and methods; special, classes and methods directly bind to specific runtime behavior, while specific The runtime behavior cannot be modified and expanded because the behavior is defined by the concept of "class" and "method"; because they are not a language, the class library is rarely supported by the environment (such as compilers and editor) smart support us. Should be loyal to Wannabe DSLS or should you use true DSLS freedom when you need DSLS? Of course, it is free; each class library is a complete DSL candidate for our platform; for example, all type libraries of JDK should be DSLS on the MPS platform; some of these DSLs are not so start now. Emergency needs, but some other have a strong impact on the function and reusability of the platform from the beginning; I will introduce three most important platform languages provided with MPS: The base language, The Collection Language, and The User Interface Language
Base Language
The language we need is to correspond to the simplest programming field, a gener-purpose command programming; this simple language should support almost universal language features such as arithmetic, condition, cycling, functions, variables, etc.; in MPS We have such a language, it is called Base Language
The demand for this language should be obvious, for example, if we want to add two numbers together, we should be able to simply say "A B" can be; we don't need to use it everywhere, but almost All procedures will have some components to use it, where it is the most suitable tool for completing the work.
Base Language is so named because it is a lot of language that needs basic programming support such as variables, statements, loops, etc. It can be used in three ways: you can expand it to create your own based on it Language, you can quote its concept in your program, you can also generate your code as Base Language; there will be several available builders to convert Base Language into other languages such as Java, C , etc .; Not every language needs to use Base Language, but in many cases, it is a good starting point.
Collection Language
The following most important languages we need are the language works with the collection; the demand for collection support is generally existing; each major mainstream language provides a set of support for a collection, for example, in Java You have java.util, you have STL in C ; everyone needs a collection; if each DSL provides its own support for collection, then there will be a Babylon of different collections, they are not compatible with each other; That is why MPS must provide a single Collection Language for everyone to use.
In a lot of mainstream languages, a collection is not a language characteristic but a library, an example is a java.util package of Java; this support technology is present, but it is inconvenient, messy, and easy error
Yuck! Today, most Java code is taken in a row, and repeatedly handled the collection of code to make a mess, Figure 6 shows an example, how the Collection Language is a library; example is a calculation group Algorithm for convex hull for a given point; more about the details of Collection Language will mention User Interface Language in later articles
User Interface Language is the next most important DSL in our platform; interesting is that the Editor Language mentioned earlier can be used by others to provide user interface, but a language specially designed for graphical user interface Will be more flexible; the benefits of this language are huge; Java Swing code is an excellent example of a class library that wants to become a DSL: Function is, but it is easy to be misuse, and Swing code is completely messy Many developments today include GUI Builder to simplify the creation of the user interface; User Interface Language will bring this task to a higher level; I will discuss more details in future articles.
Getting Started with MPS
I have been able to hear some response to LOP: "It sounds good, but our project has stepped into the right track, now switch to LOP is not feasible", or "sounds good, but use a LOP. After testing method to start a real life, the project risk is too big ", or" sounds good, but when can it be prepared for its golden period? Don't forget that OOP has used it for 20 years to become mainstream "
Good news is that we don't need to take a piece of unknown, you can take the water first; you can just apply a small piece of LOP in your project to see if there are some practical benefits, then if You like you can use more; in the future, you can test two possible LOP applications in MPS:
Using MPS on Java Applications
There is already an Intellij IDEA prototype plot allows you to include the conceptual model of MPS in your project; when you edit the model, the model will automatically convert into a Java source code in the background; therefore, you can use MPS to write Java applications Part of the module, I like to use multiple points, I like to use less and use less; this means you get all the power of MPS, such as the ability to create and use specific DSLS, do any language extension you want, At the same time, the customized editor with automatic completion, error is highlighted, reconstructed, etc.; the plugin will be closely integrated with the IDEA, allowing you to embed Java code in your MPS model, navigate to the Java code embedded or generated Even the debugging of the conceptual level, just like JSP debugging support already available in IDEA; more integration features are planning; this will be an important new tool for Java developers using Idea
Configuring and scripting your applications
There is a model I have seen, and a form of configuration is required when an application starts, which may be a simple profile, or a more complete deployment descriptor file; Finally, the configuration change is more complex, the application last Need a scripting language; for simple profiles, XML is very popular; for scripting languages, you can create your own, or borrow a General-Purpose's scripting language, like Vbscript, Python / Jyphon, TCL, JavaScript, or LISP Each of these programs has at least some of the standard defects of the mainstream programming method: long realization time, steep learning curve, difficult to expand, lack of environmental support, etc. As an alternative, you can use MPS to create you Your own configuration / scripting language; your application's users will have an easy-to-use, smart editor to write their scripts, including syntax highlight, error, code completion, navigation, etc. Special time to create and integrate this language to your application; in order to use this application, you can distribute MPS runtime
Conclusion
The idea behind LOP and MPS is not fresh, actually more than 20 years; language oriented programming itself has been proposed for at least 10 years; fresh is that these thoughts have been in software development community silent penetration, and their The times finally arrived; adopt this article, I hope to provide a seed that enables these ideas to produce new discussions, opinions, criticism, experiment, research, and final real life.
And, therefore, I invite you to participate in this new model in any way you can do; add comments behind, or send email to me: mps_article@jetbrains.com; in http: // www. JetBrains.com/mps can find more, please pay attention to the update; pay attention to browse the website, magazine, blog, books from LOP, magazine, blog, books, etc., and think about how easy it is to think about your own project, see you Multi-frequently designed and use small specific use classes and methods patched language; how do you think it? I would like to know
When I use the concept of LOP to develop MPS itself, I have seen how language oriented programming is thoroughly improved the first-hand information of software development; MPS is not ready for the real world, but it has successfully achieved the purpose There is still no documentation, except this article; I will quickly release more articles, discuss MPS in-depth; I plan to test the MPS next month, so your ears should be kept open There have been other projects that use similar methods, especially from IntendIal Software and XACTIUM.
Therefore, adventure is pleasant, let me see what you can find
Acknowledgements
I would like to thank Rob Harwood for his help in editing this article I would also like to thank the following people for their reviews, comments, and suggestions:. Igor Alshannikov, Florian Hehlen, Jack Herrington, GuillaumeLaforge, Vaclav Pech, Thomas Singer, Dmitry Skavish, David Stennett, And Timur Zambalayev.about the Author
Sergey Dmitriev (http://www.sergeydmitriev.com) is The Co-Founder and CEO of JetBrains Inc. (http://www.jetbrains.com), Makers of The Intellij Idea Java IDE.
References
Articles: [1] Donald E. Knuth. Literate Programming. The Computer Journal, 27, 97-111, May 1984. [2] M. Ward. Language Oriented Programming.Software - Concepts and Tools, 15, 147-161 1994, Http://www.dur.ac.uk/martin.ward/martin/papers/middle-out-t.pdf
Intentional Programming articles: Charles Simonyi The Death of Computer Languages, The Birth of Intentional Programming 1995.ftp:.. //Ftp.research.microsoft.com/pub/tr/tr-95-52.doc alsoftp: // ftp. research.microsoft.com/pub/tr/tr-95-52.psJohn Brockman Intentional Programming:... A Talk With Charles Simonyi Edge 2000.http: //www.edge.org/digerati/simonyi/simonyi_p1.htmlMicrosoft Research Intentional programming.http: //www.cse.unsw.edu.au/~cs3141/ip.asf (Video) Charles Simony: INTENTIONAL Programming: asymptotic fun? Http://www.hpcc.gov/iwg/sdp/ Vanderbilt / position_papers / simonyi.pdf
Books: Krzysztof Czarnecki and Ulrich W. Eisenecker Generative Programming:. Methods, Tools and Applications.Addison-Wesley, 2000. ISBN:. 0201309777.Jack Herrington Code Generation in Action Manning, 2003. ISBN:. 1930110979. http: // www .codegeneration.net / cgia / Xactium Applied Metamodelling:. A Foundation for Language Driven Development 2004.http:. //albini.xactium.com/content/index.php option = com_remository & Itemid = 28Other Resources on the Web:? [3] Matt quail. Totally Gridbag.http: //madbean.com/blog/2004/17/jack Herrington. Code generation network.http://www.codegeneration.net/ [4] intional softwarehttp://www.intentsoft.com [5] Xactiumhttp: //www.xactium.comIntentional Programming interviewsSergey Dmitriev.http: //codegeneration.net/tiki-read_article.php articleId = 60Charles Symonyi.http:? //codegeneration.net/tiki-read_article.php articleId? = 61krzystof czarnecki.http://codegeneration.net/tiki-read_article.php? ArticleId = 64andy evans.http: //codegeneration.net/tiki-read_article.php? ArticleID = 68
See Also:
"Thinking In Current Paradigms, Platforms, Frameworks, And Libraries"
"Thinking In Current Programming Languages" My understanding:
The layering solves all problems in the computer, then when the problem becomes so complicated, let's see what the result will be?
Look at our status quo, General-Purpose's language (Java, C ...) ruled the world, but the domain-purpose (Matlab, SQL ...) language developed in a field also plays an important role. So what can we get? Combine, layered, good! That's it, we can join a layer that can define the Domain-Purpose language, then we will get a variety of languages that are easy to solve in various fields. At the same time, these languages we define are based on a bottom layer: perhaps Is a language production of GENENRAL-PURPOSE, who cares? Speaking here, I think of .NET, it should be said that Microsoft's greatness is that it has been doing this in its territory (Windows), maybe it thinks that the computer is Windows, if it really thinks, then it gives it Its own sense of behavior is the same as us: giving human beings with the greatest freedom, whether the theory is above, or to operate the above, let the computer truly serve us! However, maybe the fact is not this. So far, the computer is still a machine based on the execution binary instruction of the transistor chip. We still have to start from this fact, not from Windows! I think, if this is really a revolution, then create the first general-purpose hardware platform similar .NET's thing is the airline!
Alternatively, the pop of the plugin is implied, look at Eclipse, look at NetBeans, then what is it? If you use it, we just need to customize your own DSLS, just this! !
The above is the revelation of this article!