Programming language

Source code

As Charta is a software environment, the development of software is an important issue. Therefore considerable effort is and will be taken to ensure high quality in the process of developing software. A first step in the right direction is to acknowledge the fact that software is made up of highly structured source code. Regardless from how the user will be able to enter the source code to its software, from an information modeling point of view the best way to store and manipulate source code is in a form that closely resembles the logical structure of that source code.

Because Charta allows modeling and storing data in an object oriented manner it is natural and straightforward to model source code as objects. This approach is fundamentally different from traditional programming languages that take text files as their input. Text files have no inherent structure that resembles the logical structure of source code: a text file is just a list of character strings. Automated processes that work on source code, like compilers, will be easier to implement when they can work directly on structures of objects instead of first having to extract that structure from text files. In essence the first tasks of a traditional compiler can be skipped altogether.

An extra advantage of storing source code as objects is that source code will not be bound to a specific representation because such a representation will not be stored at all. Also, all generic functionality that will be implemented for objects in Charta can be applied directly to source code too. For instance, it will be easy to query for all functions that meet certain conditions like having a specific return type or taking a specific number of parameters.

Source code editor

It is natural to store source code as a set of objects. This way the programmer can make effective use of standard techniques to query, visualize and manipulate data for various aspects of source code. Those techniques include viewing data in trees and tables with advanced options to sort and filter that data.

However, working solely with objects is certainly not the most convenient way for the programmer to view or enter all aspects of source code. Hence, to enter the body of a function, an algorithm, it will be very inconvenient to only have trees and tables available to enter such an algorithm.

An editor has been designed to allow the entry and modification of algorithms in a more natural way. This editor is still very much in development so a lot of issues still have to be resolved. However, the current implementation serves as a good prototype of the possibilities of the structured entry of algorithms. In fact, algorithms are just one example of hierarchically structured data. In the future the editor can also be used to edit other data that is also structured hierarchically like XML documents, scientific literature and books.

The editor mainly performs three tasks on algorithms. First it has to render the object hierarchy underlying an algorithm into a more readable form. In the current version of Charta this is already implemented reasonably well. Because source code is stored without any representation the editor is able to render the function body in any way that is desired. Currently the editor provides a mainly textual and a more graphical representation of the function body. Issues like indentation to clarify the logical structure of source code is handled automatically. In the future the user will able to configure the view to his or her desire. Also different views corresponding to the syntax of various popular programming languages will be available.

Next, the editor translates user input to actions on the object hierarchy. The code editor gives suggestions for the possibilities at the current position of the caret. When the programmer selects a suggestion, the code editor inserts a reference to the selected code element. The editor controls the input by the user, but leaves room to make mistakes or leave unfinished statements. For example, when you start typing a place holder is inserted in the code object hierarchy. If you leave it to do something else like making a variable declaration, the place holder remains in the code to be finished.

The third task of the editor is to allow the traversal of the function body with the caret and to allow entry and deletion of the various code components. This part of the editor currently has considerable room for improvement. For instance, the traversal with the caret does not always work as is intended, there is no undo/redo option and using the copy and paste functionality has its issues. However, none of these issues really prevent the effective use of Charta at this stage.

One important aspect of the editor is that edit actions operate on the logical units of the hierarchical structure of the code. Two examples of these logical units are compound expressions and if statements. With one press on the delete or backspace button one can delete a complete compound expression or if statement. To indicate on which unit an edit action will operate the editor shades logical units during caret traversal. For instance, placing the caret at the right of a while statement will cause the whole while statement to be shaded including all the statements that are contained within the while statement. Pressing the backspace key will then remove the while statement together with all the statements it contains.

Variable declarations

The declarations of variables can be manipulated through a standard data manipulation control: variables are declared outside the source code editor in a table control. Parameters and the result type of a function are also declared in a table control that is placed below the source code editor.

Objects

Although the programming language provided by Charta will be object oriented in the future, for now it is only possible to create functions that are global and are not tied to a specific class. However, these functions can work on objects. Functions can create new objects and alter the data fields of existing objects.

Because functions and classes in Charta are objects themselves they can also be created by functions.

Running functions

Once a function has been written it can be run and tested immediately by pressing the run button. The parameters that the function needs can be entered in the table where the parameters are declared. In the same table the result of the function will be displayed. When the result type is complex, a new control will be created in the control vault to display the result value. For instance, when the result of a function is an array of values, then the result will be displayed in a table control. When, interestingly, the result type of a function is also a function, then a complete function editor panel will be created to edit the newly created function.