Last update January 16, 2008

Other Languages

Other programming languages can be examined to find useful features to include in D.

(These were originally posted by Mark Evans to the D newsgroup.)


"C-- has to strike a balance between being high-level enough to allow the back end a fair crack of the whip, while being low level enough to give the front end the control it needs. It is not clear that a path exists between these two rocks; th e ghost of UNCOL lurks ominously in the shadows [6]. Yet the increasing popularity of C as a compiler target language (despite its unsuitability) suggests strong demand, and provides an existence proof that something useful can be done."


I was amused that CIL is written in OCaml. OCaml just continues to amaze. The CIL license is loose, so this tool might have uses for D.


"Cyclone is a programming language based on C that is safe, meaning that it rules out programs that have buffer overflows, dangling pointers, format string attacks, and so on. High-level, type-safe languages, such as Java, Scheme, or ML also provide safety, but they don't give the same control over data representations and memory management that C does (witness the fact that the run-time systems for these languages are usually written in C.) Furthermore, porting legacy C code to these languages or interfacing with legacy C libraries is a difficult and error-prone process. The goal of Cyclone is to give programmers the same low-level control and performance of C without sacrificing safety, and to make it easy to port or interface with legacy C code."


"Efficiency and flexibility. Dylan can be used as a dynamic prototyping language(like Smalltalk) or an efficient compiled language. Functional Developer, Functional Objects' Dylan compiler, generates code as good as that of most C compilers. Still, it provides an interactive prototyping environment like those found in Smalltalk or Common Lisp."

This design paper is a good read. The lesson for D is to think more about the fast prototyping side and not view flexibility as the enemy of efficiency. Really they are part of the same team and cover different parts of the field.

Functional Patterns

"Patterns for how to integrate a functional style of programming into an object oriented environment."


Another item showcasing integration of high-level and low-level language paradigms. You can have both.

From the FAQ:

"...have you tried real-time video grabbing and processing in Matlab? Have you tried to train a one-million weight convolutional neural network in Matlab?"



"Sather has parameterized classes, object-oriented dispatch, statically-checked strong (contravariant) typing, separate implementation and type inheritance, multiple inheritance, garbage collection, iteration abstraction, higher-order routines and iters, exception handling, assertions, preconditions, postconditions, and class invariants. Sather programs can be compiled into portable C code and can efficiently link with C object files. ICSI maintains a stable public class library and a growing body of contributed code including classes for mathematics, data structures, GUI interfaces and compiling; the Sather compiler, written entirely in Sather, is one such contribution. Sather has a very unrestrictive license which allows its use in proprietary projects but encourages contribution to the public library. A language-aware browser allows new users to explore the library with integrated documentation."

Oz the language

"Concepts, Techniques, and Models of Computer Programming"

by PETER VAN ROY SEIF HARIDI (c) 2001-2003

"One approach to study computer programming is to study programming languages. But there are a tremendously large number of languages, so large that it is impractical to study them all. How can we tackle this immensity? We could pick a small number of languages that are representative of different programming paradigms. But this gives little insight into programming as a unified discipline. This book uses another approach.

"We focus on programming concepts and the techniques to use them, not on programming languages. The concepts are organized in terms of computation models. A computation model is a formal system that defines how computations are done. There are many ways to define computation models. Since this book is intended to be practical, it is important that the computation model should be directly useful to the programmer. We will therefore define it in terms of concepts that are important to programmers: data types, operations, and a programming language. The term computation model makes precise the imprecise notion of 'programming paradigm'. The rest of the book talks about computation models and not programming paradigms. Sometimes we will use the phrase programming model. This refers to what the programmer needs: the programming techniques and design principles made possible by the computation model.

"Each computation model has its own set of techniques for programming and reasoning about programs. The number of different computation models that are known to be useful is much smaller than the number of programming languages. This book covers many well-known models as well as some less-known models. The main criterium for presenting a model is whether it is useful in practice. Each computation model is based on a simple core language called its kernel language. The kernel languages are introduced in a progressive way, by adding concepts one by one. This lets us show the deep relationships between the different models. Often, just adding one new concept makes a world of difference in programming. For example, adding destructive assignment (explicit state) to functional programming allows to do [sic] object-oriented programming. When stepping from one model to the next, how do we decide on what concepts to add? We will touch on this question many times in the book. The main criterium is the creative extension principle. Roughly, a new concept is added when programs become complicated for technical reasons unrelated to the problem being solved. Adding a concept to the kernel language can keep programs simple, if the concept is chosen carefully. This is explained in Section 2.1.2 and Appendix E.

"A nice property of the kernel language approach is that it lets us use different models together in the same program. This is usually called multiparadigm programming. It is quite natural, since it means simply to use the right concepts for the problem, independent of what computation model they originate from. Multiparadigm programming is an old idea. For example, the designers of Lisp and Scheme have long advocated a similar view. However, this book applies it in a much broader and deeper way than was previously done."


One of the Cyclone people (Greg Morrisett) also works on a "typesafe assembly" project, "TAL." His work should be quite interesting to D, because it centers on implementing high-level (functional) language features in a strongly typed and compiler-optimized fashion -- all the way down to the back end nitty-gritty for Intel chips. We are not talking about virtual machines or JIT here, this is real compilation. Functional power is possible in D. - Mark

"The goal of the TAL project is to extend the paradigm of type-directed compilation to its limit. We compile high-level languages that include features such as higher-order polymorphic functions, datatypes, modules, objects, and subtyping into a series of typed intermediate languages and finally into a Typed Assembly Language (TAL). Unlike any other compiler, we not only use typed intermediate languages but also typed target languages." "The assembly language type system is powerful enough to express high-level abstractions such as closures and abstract datatypes and yet flexible enough to permit traditional low-level optimizations such as loop invariant removal, strength reduction, and redundant move elimination. Furthermore, just as the more familiar typed source and intermediate languages catch programmer errors, so does our typed assembly language. It helps to ensure that complicated backend transformations such as the optimizations above as well as register allocation and more general instruction selection and scheduling are performed correctly." - Functional C++


"TXL is a generalized source-to-source translation system suitable for prototyping computer language processes of any kind. It has been used in rapid prototyping of new programming, specification and command languages, as well as in a wide range of software engineering and optimization tasks.

"TXL takes as input an arbitrary context-free grammar in BNF-like notation, and a set of show-by-example transformation rules to be applied to inputs parsed using the grammar.

"TXL automatically parses inputs in the language described by the grammar, no matter if ambiguous or recursive, and then successively applies the transformation rules to the parsed input until they fail, producing as output the transformed source."

TXL includes both a C and C++ grammar.


"Today's safe programming languages, like C#, are great for weeding out many bugs in programs. Unfortunately, such languages are not suited to programmers who want to control the memory layout of their data structures or the lifetime of program's resources (like memory). Programmers who need this control are stuck with C or C++. Vault is a safe version of the C programming language, being developed at Microsoft Research, which provides the same level of safety as languages like C#, but allows a programmer to retain control over data layout and lifetime."

More References

F LanguageMark Evans2 Jul 2003 NG:D/14183
Transframe LanguageMark Evans29 Mar 2003 NG:D/12285
TXLMark Evans19 Feb 2003 NG:D/11050
Typesafe Assembly LanguageMark Evans22 Feb 2003 NG:D/11161

FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: January 16, 2008 22:02 (diff))