Dylan (programming language)
Dylan | |
---|---|
Paradigms : | object-oriented |
Publishing year: | 1992 |
Developer: | Apple , Carnegie Mellon University |
Current version : | 2019.1 (March 31, 2019 ) |
Typing : | strong, dynamic |
Important implementations : | Gwydion Dylan, Open Dylan |
Influenced by: | CLOS , LISP , EuLisp , ALGOL , Scheme |
Affected: | Goo , lasso , python , ruby |
Operating system : | cross-platform |
opendylan.org |
Dylan ( Dy namic Lan guage ) is a programming language , which in the early 1990s by a group led by Apple initiated and has been specified.
The aim was
- the best aspects of Lisp and Smalltalk to combine
- to offer users of static programming languages an attractive dynamic alternative
- to be usable on small machines
- to offer high dynamics during prototyping and development
- To offer tools that provide commercial performance in production code.
Dylan was originally intended for use on Apple's Newton PDAs, but was replaced there by NewtonScript , an in-house development based on the programming language Self , due to deadline and presumably also prestige reasons .
Differentiation from other programming languages
Dylan's object-oriented paradigm is in the tradition of Common Lisp and differs from most object-oriented programming languages (such as C ++, Java, Python, Ruby) in the abstraction principle of polymorphism , which is implemented differently in both cases.
Programming languages such as Java encapsulate data in objects, such as a fraction class that contains numerators and denominators. Operations that work with these objects, such as addition, are also seen as a property of the object / class and are managed in the class itself.
As the following pseudocode section shows, both data and methods (operations) are part of the object.
Bruch a;
a.nenner = 10;
a.zaehler = 1;
Bruch b;
b.nenner = 1;
b.zaehler = 5;
a.addiere(b);
With virtual methods, this approach enables polymorphism . This means that an object "brings its own operations" and the programmer does not have to specify at runtime, e.g. B. an addition should be carried out for different objects.
For example, if you have two classes Bruch
and KomplexeZahl
, both of which Zahl
have the parent class that betrag()
defines a method , the amount of a complex number or a fraction a.betrag()
can also be calculated without having to differentiate in the source text whether it is a
a fraction or a complex one Number acts.
This approach promises a degree of abstraction, because a well-implemented class does a lot of work for the programmer. An object itself "knows" best how to calculate its amount.
The disadvantage of this approach is that operations that cannot be assigned to exactly one object now have to be put in a class. The addition of two numbers A
and B
is such a case. Corresponds A+B
to A.addiere(B)
or B.addiere(A)
.
Multiple dispatch
Dylan implements the polymorphism in a different way. Operations and methods are defined outside of the class, and A.addiere(B)
now takes its place addiere(A,B)
. Within the class, only data fields are described and access rights are distributed.
With minor deviations in the calculation of the Class Precedence List , Dylan's Multiple Dispatch is an exact adoption of the multi- methods from Common Lisp .
define class <Bruch> (<object>)
slot nenner;
slot zaehler;
end;
define method addiere(a :: <Bruch>, b :: <Bruch>) => (ergebnis)
// Implementierung
end;
If a class is implemented for complex numbers, the method addiere
can easily be extended to include other data types.
define method addiere(a :: <KomplexeZahl>, b :: <KomplexeZahl>) => (ergebnis)
// Implementierung
end;
define method addiere(a :: <Bruch>, b :: <KomplexeZahl>) => (ergebnis)
// Implementierung
end;
define method addiere(a :: <KomplexeZahl>, b :: <Bruch>) => (ergebnis)
// Implementierung
end;
Another method can now work and calculate with numbers independently of classes:
define method rechteck_umfang(laenge, breite) => (umfang)
2*(addiere(laenge, breite))
end;
It should be noted that the classes for the parameters are laenge,breite
not specified. When the calculation is carried out, the correct implementation of is found automatically addiere
. This is called Multiple Dispatch and corresponds to the tradition of object-oriented programming in languages of the Lisp family, such as in Common Lisp with the Common Lisp Object System CLOS .
Implementations
Gwydion Dylan
Gwydion Dylan, named after a wizard from a Welsh legend, was originally developed at Carnegie Mellon University . It is a compiler that generates C code. This code must be translated into machine code using a C compiler. This allows Gwydion-Dylan programs to run on many platforms. However, the implementation is less complete than Open Dylan.
Apple Dylan / Harlequin Dylan / Functional Developer / Open Dylan
After Apple finally stopped the development of Dylan in 1998, the source code went to the English company Harlequin. Harlequin was taken over by Global Graphics shortly afterwards and the development of Harlequin Dylan was spun off into an independent company, Functional Objects (also "FunO"). The Dylan implementation with IDE was henceforth sold under the name "Functional Developer". In 2004, Functional Developer was finally handed over to Gwydion Dylan Maintainer as an open source project (FunO completely ceased its business activities at the beginning of 2006). The software has been called Open Dylan since December 10, 2011 in version 2011.1.
In addition to an interactive shell (similar to Ruby's IRB or BeanShell ), the IDE offers an object browser with which the status of running programs can be analyzed. Both tools can be used on local Dylan programs as well as on other computers.
The IDE is currently only available on Windows , but the compiler now also runs on Mac OS X and Linux .
Mindy
Mindy is a Dylan interpreter whose development has since been discontinued. It was used to compile the first version of the Gwydion compiler . The name is a recursive acronym for MINDY Is Not Dylan Yet.