Aleph (programming language)

from Wikipedia, the free encyclopedia

Aleph is an object-oriented , functional programming language . It puts conventional programming on a broader basis. This unites interactive development and compilation . Working with Aleph is problem-oriented and thus allows the mixed use of basic techniques from Lisp , Forth and Java .

On the initiative of the e-Vocation e. V. started Aleph in 2005. In the meantime, dialects have developed, of which Pagkalos (Greek: beautiful ) is the most advanced.

History of origin

Aleph is the continuation of an evolutionary process. Its foundations were laid in 1969 by Charles Moore using the Forth language. For the first time, a programming language was defined for a purely virtual machine . All data is processed via a stack . As a result, a Forth machine approaches the ideal Turing machine much more than conventional machines.

The rapid development of new processors and the available memory space made it possible to use parser and compiler generators . Languages ​​such as Pascal , C , C ++ etc. could now easily be generated for the existing processor. These conventional languages ​​support the common notation for simple calculations. Forth was now considered too illegible and fell behind.

Accelerated by falling prices for hardware and the ever increasing demands on software, conventional languages ​​became more and more complicated. More and more syntactic elements were devised. The introduction of the complex data types required strict tests. The development culminated in object-oriented programming . The following overview shows how Aleph and Pagkalos developed from the branching relationships of the programming languages:

History of Aleph

Java and Forth use the physical machine indirectly . Either via C / C ++ or directly via the assembler. Physical addresses must always be observed. Aleph has a virtual machine made out of pure Java code. Therefore, physical conditions are there, but not usable. Aleph cannot even address a specific address indirectly; Java is always in front of it and forbids physical contact.

Naming

The name Aleph is derived from the abilities of the language. Aleph makes every accessible Java element available immediately and without compilation. Because Java is also referred to as the language of the Internet, there is an overwhelming amount of Java programs on the Internet. Such large quantities are often referred to as infinite . As wrong as this view is mathematically, it is true of the name. Georg Cantor used0 "Aleph-0" to designate the first level of the hierarchy of infinities. It is the cardinal number or cardinality of all infinite but countable sets. In Cantor's honor and because Aleph can also work with large quantities, it bears this name.

The language concept

There is both a compiler and an interpreter for Aleph .

Aleph's concept of language is closer to that of a natural language than a programming language. With this, Aleph could not be viewed as context-free . In fact, Aleph is context-free when requested. Aleph shares this ability with Forth.

This extension results from the lack of grammar. There isn't even any syntax in the strict sense. The rules are determined by the programming itself. That makes Aleph a really object-oriented language.

Object-oriented and functional

The basis of object-oriented programming is the separation of data and program. A requirement that leads to a dilemma. Even Java cannot guarantee this separation completely, because how should a program then load a class and then use the (static) methods? If the class is a date, it must not contain any executable sequences; there was no separation of data (class) and program (method).

From Aleph's point of view, this state of affairs is not consistent. There is no data at all in the programs. There are only functional objects. The minimal function of such an object is to provide a value as an argument for processing. The processing object can again only use the value as a functional object. The only place where data (values) exist is on the stack. However, programs always receive the elements from the stack packed into objects. It is the legacy of Lisp that Aleph takes on here.

notation

The natural notation is that of all stack machines - postfix . This form is considered difficult to read, and such applications are expensive to maintain. The notation of conventional programming languages ​​is prefix , in the form y = sin (x) , only a few lines contain infix expressions.

Aleph also allows the use of the prefix notation. The Polish mathematician Jan Łukasiewicz came up with the different notations. It is thanks to him that the notations

  1. / (sin (x) cos (y))
  2. sin (x) / cos (y)
  3. y cos x sin /

are synonymous. The bracketing of terms is no longer necessary with the postfix notation. Translating a prefix expression (1.) to a postfix expression (3.) is simply to flip the first expression and leave the parentheses out.

Program examples

It is always difficult to give meaningful examples of programs in a short article. Therefore, there is no hello world program here , but a comparison is made.

Calculate the faculty

The calculation of "5 factorial", or 5! takes place via 5 × 4 × 3 × 2 × 1. In general, the algorithm for n!:

The implementation in classic programming languages ​​is with

int fak(int n) {
    if (n == 0)
        return 1;
    else
        return n * fak(n - 1);
}

made quickly.

Aleph does have variables, but they are much broader than those in conventional programming languages. The concept of Aleph is based on avoiding variables. The implementation in Aleph can also be done with variables. Because there are no argument lists, a variable must be declared locally. This is only possible indirectly in Aleph and leads to the following source code:

: fak
   "x" variable "x" is            // Variable "lokal" deklarieren
   "x" find if execute endif
   0 =
   if   1
   else "x" find if execute endif // Variable suchen "ausführen"
        1 - fak
        "x" find if execute endif
        *
   endif
   "x" find if forget endif       // Variable "vergessen"
  ;

Aleph variables can also "contain" entire programs. They can contain values, but also all of the compiled code that provides the value. Therefore the variable has to be executed in this example .

With this approach, using variables leads to confusing code. Aleph can better play out his strengths without variables:

: fak
   dup 0 =
   if   drop 1
   else dup  1 - fak *
   endif
  ;

A test with

5 (long) fak .

then gives the result 120. Casting with (long) is necessary because Aleph always selects the least powerful data type of the subordinate machine (Java). With 5 this is “byte” and not “long”. Would be easier

5.0 fak .

That would contradict the approach (natural numbers), but Aleph handles different data types automatically as long as possible.

grind

Aleph treats his commands verbatim . Therefore there are no “ while ”, “ for ” or “ do… while ” constructions. They can of course be defined, but the basis is the " loop ". A loop is left with the command "leave". If the condition is "true", the loop is exited.

The following example shows a loop that counts from 1 to 10, outputs each step and at the end keeps the values ​​for the termination condition on the stack.

: count
   0              // Anfangszähler
   loop
    1 ndup 1 ndup
    = leave       // Schleife verlassen, wenn Endwert erreicht?
    1 +           // Zähler erhöhen
    dup . " " .   // Zähler ausgeben
   endloop
   "fertig " .    // Hinweis auf "Ende erreicht" ausgeben
 ;

// Bis 10 zählen und danach mit .S den Stackinhalt anzeigen

10 count .S

The ad is

1 2 3 4 5 6 7 8 9 10 fertig Stack = [ 10 10 ]

It is very easy to create all established constructions of loops from the combination of condition and the “leave” command.

Areas of application and distribution

According to the initiator, the Aleph is intended for educational purposes. Whether for beginners or advanced in programming is not said, however. The broad concept of the language should probably make it more interesting for advanced learners.

Aleph is useful for quick application drafting. The interaction of the often very extensive class libraries can be checked easily and intensively with Aleph. Whether the finally tested composition is then put together in a new class is irrelevant.

Because every Java element is available in Aleph, programs formulated in C / C ++ can even be used in Aleph via the Java native code interface. This also makes computationally intensive applications in Aleph useful.

Aleph is not found in the big IDEs like Eclipse and NetBeans .

Web links

Wikiversity: Programming in Aleph  - Course Materials