|
Note: The following text is a just a copy of a text I wrote in pure ASCII. It has only been formated. Also some spelling errors have been corrected.
Looking for a New Programming Paradigm ====================================== F.J. Elmer 4. March 2005 1. Problems ----------- I'm a passionate Java programmer in my job and at home. My standard development environment is Eclipse 3 (also at my job and at home). I really appreciate the code completion and navigation features of Eclipse. Of course the most important feature of Eclipse is the refactoring tool. It allows to improve the code in a way which I never want to miss. Nevertheless, I'm not satisfied the way to develop software. Below some topics are discussed. 1.1 Programming Errors ---------------------- They should be detected as early as possible. Eclipse's on-the-fly compilation helps a lot. But in a heterogenous environment errors are often detected only at runtime (e.g. a Web application developed with Java, JSP, Struts, and various configuration files). In my opinion this is a regression. But even if you are developing only in one language there are still lots of possibilities to write syntactically correct code which breaks at runtime. A language and a compiler should be designed in such a way that errors are detectable as early as possible. Therefore I like languages with strong types like Pascal and Java. Many scripting languages are not strongly typed (e.g. Python) which is fine just for experimenting or developing small tools but not for larger projects. 1.2 Comments ------------ Comments explain the code for humans. But often the comment is no longer reflecting the actual code. Eclipse shows errors in Javadoc of a method. But this works only for simple errors like wrong @param tags. There should be a language which allows to write comments that could be checked by the compiler or which is a part of the language or which makes comments superfluous. Formalizing pre- and post-conditions is a good examples for such types of comments. They are a part of Eifel. They can be added in Java with assert statements. Aspect-oriented programming is also a way to deal with these pre- and post-conditions. But there are two disadvantages: 1. They are checked at runtime, not earlier! 2. They are optional. That is, they may be or may be not specified by the programmer. 1.3 Coding Standards -------------------- For most programming languages the format of the code is not important. For example, in Java the code of a class can be filled in a single line or be wrapped in an arbitray way. But code has to be formated and layouted in a way that it is easy readable for humans. Especially the tree-like structure of code blocks should be visible. Some languages like Python use indentation as a part of the syntax to define code blocks. Nevertheless, there a various ways to format code. Formatting rules are usually part of a coding standard. They help to establish a consistent style of the code. This is especially important in projects with several programmers. A consistent look helps readability. In Eclipse formatting rules can be specified and applied to the code. But there is a problem with long statements. If they are not wrapped it is difficult to read because one has to scroll the text. Wrapping around comes in conflict with indentation. Usually wrapping indentation is choosen in such a way that it is hopefully distinguishable from block indentation. 2. Concepts ----------- Some of the above mentioned problems have to do with the concepts of a programming language. For example, a language is strongly typed or not. A language is object-oriented, procedurale, functional, and/or declarative etc. I'm not discussing this aspect of a programming. I want to discuss the traditional concept of programming environment. The traditional way to create software is the following: 1. Write one or several text files (called source files) in one or several programming languages (programming languages might be mixed in a single source file). 2. Run a compiler to create an executable program. Sometimes a linker should also be invoked. This process is often coordinated by some make scripts. Ant has become a standard for doing this in the Java world. 3. Run the executable program. This is a text-centric paradigm. The software is a stream of characters. The source files are the master files from which the executable program can be (re)created. What does the compiler? First, it parses the source file and creates a so-called abstract syntax tree (AST). By the way, there exists an Eclipse plugin which shows the AST of a Java source file. In a second step the executable code is created from the AST. A new programming paradigm would be AST-centric. The master file is no longer a text but a the abstract syntax tree. The most important question is, how to create an AST? Eclipse with its on-the-fly compilation approaches this goal in the traditional way: The programmer writes some code and Eclipse interpretes the code as some kind of "commands" for AST editing. For example, entering '{' together with code completion creates a new subtree of a block statement in the AST. Since Eclipse 3 blocks can also be folded and unfolded like directories of a file system in a file browser. Nevertheless, there are still to much freedom for a programmer (see coding standards). With this AST-centric view the question rises: Do they exists other ways to editing and visualizing an AST? Visual programming tries to do this in a less text-centric way. But in most cases these approaches didn't reach a level as powerful as the traditional paradigm of programming. Typical problems were the following: 1. The AST visualization isn't complete. Some information is hidden and visible only if one clicks on a visual element. 2. The AST visualization isn't as compact as a pure textual representation. 3. Some parts of the AST are still represented as texts using some syntax like in a traditional language. 4. It is difficult the edit an AST efficently compared to traditional text editing. Intentional programming is also an approach to edit an AST directly. It is an experimental system developed at Microsoft for a long time. Now the inventor Charles Simonyi has founded its own company. But you can not buy such a programming environment. It is used like Eclipse where entering a command in the traditional syntax of a text-centric language manipulates the AST. It seems to be more restrictive than Eclipse. But it is unclear whether it goes beyound what Eclipse already could. It is claimed that intentional programming captures the semantic intentions of the programmer better than Eclipse or the traditional text-centric paradigm. |
|