www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - virgil language

reply bearophile <bearophileHUGS lycos.com> writes:
For a language like D that is still in development stage, it can be positive to
take a look at other languages now and then. The "virgil" language is designed
for embedded microcontrollers (EM), that's a very different situation from the
PC (but D often looks like a superset of C, and C variants are the most used
languages for EM, beside assembly, so it's not a totally different situation).
EM often have few kbytes of ROM and even only few hundreds of bytes of RAM. So
you have to use as little memory as possible (you cross-compile it on a PC,
where you have much more resources). Despite such strong limitations, the
virgil language is quite more powerful than C, it has strong typing, full OOP,
delegates, it has quite advanced ways to reduce memory footprint, it's
high-level enough, and it has some interesting sides. This is an interesting
quotation from its docs:

http://compilers.cs.ucla.edu/virgil/overview.html
<<
Compile-time Initialization
The most significant feature of Virgil that is not in other mainstream
languages is the concept of initialization time. To avoid the need for a large
runtime system that dynamically manages heap memory and performs garbage
collection, Virgil does not allow applications to allocate memory from the heap
at runtime. Instead, the Virgil compiler allows the application to run
initialization routines at compilation time, while the program is being
compiled. These initialization routines allow the program to pre-allocate and
initialize all data structures that it will need at runtime. This computation
phase is Turing-complete, which means that the application can perform any
computation, including building complex data structures such as trees and
hashtables, building numerical approximation tables, allocating resource pools,
and generally configuring itself.
When the application's initialization routines terminate, the live fields of
the components of the program serve as the roots for computing the reachable
heap of the program. Unreachable objects and arrays that are allocated during
the initialization phase are discarded. The reachable heap is then compiled
directly into the program binary and is immediately available to the program at
runtime. The Virgil compiler also optimizes the implementation of the program
against this reachable heap and removes dead code with an optimization known as
reachable members analysis, which is described in more detail in the
publications available.


Another quotation from an article: << the Virgil compiler includes an interpreter for the complete Virgil language. After typechecking is complete, the compiler executes the application’s initialization code with the built-in interpreter. The interpreter allows the application code to perform any Turing-complete computation using the complete Virgil language, including, for example, allocating objects, initializing them, calling methods on them, etc. This phase allows unrestricted allocation; a general-purpose garbage collector ensures that unreachable objects allocated by the application are discarded. When the application’s initialization routines have terminated, the compiler will generate an executable that includes not only the code of the program, but also the data of the entire reachable heap. This initial heap is immediately available to the program at runtime on the device. During execution the program can perform unrestricted computation and can read and write heap fields, but further memory allocation is disallowed and will result in an exception.


Some articles about virgil language: http://compilers.cs.ucla.edu/virgil/ref/pubs.html Bye, bearophile
Feb 17 2008
next sibling parent reply Manfred Nowak <svv1999 hotmail.com> writes:
bearophile wrote
[about virgil and cited:]
 Compile-time Initialization[: ...]
 This computation phase is Turing-complete

AFAIR: in the eyes of Walter that would be a killer for D, because administrators would have to worry about malware acting at compile time. -manfred
Feb 20 2008
next sibling parent BCS <BCS pathlink.com> writes:
Manfred Nowak wrote:
 bearophile wrote
 [about virgil and cited:]
 
Compile-time Initialization[: ...]
This computation phase is Turing-complete

AFAIR: in the eyes of Walter that would be a killer for D, because administrators would have to worry about malware acting at compile time. -manfred

a Turing machine can operate in a sandbox
Feb 20 2008
prev sibling parent Robert Fraser <fraserofthenight gmail.com> writes:
Manfred Nowak wrote:
 bearophile wrote
 [about virgil and cited:]
 Compile-time Initialization[: ...]
 This computation phase is Turing-complete

AFAIR: in the eyes of Walter that would be a killer for D, because administrators would have to worry about malware acting at compile time. -manfred

D's interpreter already is Turing-complete. It's not D-language-complete (that is, it doesn't deal with allocations, exceptions, etc.) but it _is_ a complete Turing machine.
Feb 21 2008
prev sibling parent Robert Fraser <fraserofthenight gmail.com> writes:
bearophile wrote:
 For a language like D that is still in development stage, it can be positive
to take a look at other languages now and then. The "virgil" language is
designed for embedded microcontrollers (EM), that's a very different situation
from the PC (but D often looks like a superset of C, and C variants are the
most used languages for EM, beside assembly, so it's not a totally different
situation). EM often have few kbytes of ROM and even only few hundreds of bytes
of RAM. So you have to use as little memory as possible (you cross-compile it
on a PC, where you have much more resources). Despite such strong limitations,
the virgil language is quite more powerful than C, it has strong typing, full
OOP, delegates, it has quite advanced ways to reduce memory footprint, it's
high-level enough, and it has some interesting sides. This is an interesting
quotation from its docs:
 
 http://compilers.cs.ucla.edu/virgil/overview.html

I'd love to see the front end's interpreter get beefed up. Right now its inability to allocate, as well as the fact it doesn't discard even stack-allocated data make it unsuitable for general-purpose initialization and code generation.
Feb 21 2008