Dao Programming Language
for Scripting and Computing
Dao is a lightweight and optionally typed programming language with many advanced features. It includes features that can make concurrent programming very simple. It provides well designed programming interfaces for easy embedding and extending.


Try Dao in browser!

Main features:
  • Optional typing with type inference and static type checking;
  • Object-Oriented Programming (OOP) with class and mixin class;
  • Abstract interface and concrete interface to supplement class-based for OOP;
  • Code section methods as a better alternative to functional methods;
  • Support closures, anonymous functions;
  • Deferred block and exception handling by defer-recover;
  • Native support for concurrent programming;
  • Concurrent garbage collection;
  • Designed and implemented as a register-based virtual machine;
  • Portable implementation using standard C;
  • Simple C programming interfaces for easy embedding and extending ;
  • LLVM-based Just-In-Time (JIT) compiler (as an optional and loadable module);
  • Clang-based tool for automatic wrapping of C/C++ libraries;
  • Released under the Simplified BSD License.
Please see help:dao.feature for a more complete list of summarized features.

Some preliminary comparisons to other languages can be found at help:misc.comparison .

Some preliminary benchmark results can be found at help:misc.benchmarks .

Here are some simple examples to provide a preliminary demonstration of the language:
# Type alias for a tuple type:
type Address = tuple<number:int,street:string>
# Function with explicit parameter types:
routine Rout( name: string, index = 123 ) => int 
{
    io.writeln( name, index )
    return 123 
}
Rout( 'abc' )
class InheritanceBase
{
    var  address : Address = ( 123, 'Main St' )
}
class MixinBase
{
	var name = 'Joe'
}

# Derive a new class that contains MixinBase
# and inherits InheritanceBase:
class Klass ( MixinBase ) : InheritanceBase
{
    static state : enum<off,on> = $off
}
someone = Klass()
# Closure (access to outer variables):
closure = routine( x ){ io.writeln( x ) } 
for( i = 1 : 5 ) defer { closure( i ) }

routine Producer( chan: mt::channel<int> )
{
    for( index = 1 : 10 ) chan.send( index )
    chan.cap(0)
}
routine Consumer( chan: mt::channel<int> )
{
    while(1){
        data = chan.receive()
        if( data.status == $finished ) break
    }
}
chan = mt::channel<int>(2)
Producer( chan ) !!  # Start the producer tasklet;
Consumer( chan ) !!  # Start the consumer tasklet;

# Parallelized code section methods:
mt::apply( [1.0:100], 4 ){[x] log(x) }
Copyright (c) 2009-2016, Limin Fu