Wednesday, July 21, 2010

General language overview

In the next several posts I will try to describe the language general overview, proposed programming paradigm and basic code patterns. So let's begin.

ELENA is an object-oriented programming language with the late binding. It means that it belongs to the same class as Smalltalk rather than C# or Java. It is a non-mainstream language and is used as a testbed for experiments with the language design, dynamic and self-modifying code and so on. So don't expect it will be easy to learn. Probably someone may say it is weird but I like its dynamic nature. It has weak sides but it DOES work. And finally it is a live language in the process of developing.

Let's consider several major language features which I will discuss in more details later.

ELENA is a language with the reduced class interfaces. It assumes that there is only limited way to interact with the object on the base of protocols supported by it. Any class method should perform an atomic operation, be quite small and support only one parameter. Moreover the strong concept of reduced class interfaces limits the possible operations between classes (belonging to different modules) to the small list of well-defined messages - verbs (though it is possible to provide "subject" for each verb, i.e. with "get" verb we can use several distinct messages: int'get or game'player'get). The method cannot have more than one parameter. As a result the method parameter tends to become an active partner. The method has to ask the parameter to return the required information, so the method caller has some control of the method work (in combination with dynamic mutation we could have some kind of two-way interaction).

ELENA is a language with a reduced operational set. Practically the only supported operation is sending a message to the object with a parameter. Conditional (#if) statement extends this operation with possibility to use multi-statement blocks and loop (#loop) one just repeats it until it fails. The only way to control the flow is message chaining. An ELENA program code is a sequence of actions (sending a message) enclosed in square brackets (Unlike Smalltalk the sub code is a sequence of action as well). The execution of every next action happens only if the previous one was successful. Otherwise the control goes to the closest alternative action and the flow continues. Alternative message chains are used in ELENA not only for handling exceptional situation but (and mostly for) conditional branching. The program code could explicitly break the execution (by sending fail message) to indicate the negative result of the method.

ELENA is a dynamic language supporting different run-time code manipulations. One of them is a static mutation. It is presumed that an object may have several alternative sets of VMTs (roles) and switch between them depending on its state. Though the total number of these states can be big enough we could always select several extreme ones (such as an empty string, unassigned container). Such cases could be implemented as class roles containing the code which is applicable only in the particular state. Only in the place where it could be changed (copying the value, assigning the object) we will check the situation and switch between roles. In most cases the bulk of the code would not be affected so there could be only several quite simple roles. But in some situation the whole code is divided between roles. E.g. Boolean variable could have two (or three) roles: true, false values (and undefined one).

ELENA supports a dynamic mutation as well. It means that we can dynamically override any public object method. This mutation could be either stable or temporal (if it is included into the temporal object group) and be accessible both inside and outside the mutated object (though inside the object we can explicitly decide if we allow overriding). It is possible either extends the object with some custom code or combine it with the number of other objects (so called object satellites) into a group object (will be described in the next post).

Concept of the group objects is one of the most interesting ELENA feature and I will continue to investigate it hoping that it will help to create self-modifying systems with truly open architecture (that in my opinion may lead to creating a very complex highly adaptive autonomous programs).

No comments:

Post a Comment