|
|
Dao Programming Language
Now the extending modules for Dao are gradually enriching, with modules for: CGI web programming, MYSQL database handling, Lapack and GSL numeric computing, GraphicsMagick image processing, MathGL mathematics plotting, OpenGL 3D graphics, SDL multimedia, VTK 3D model and data visualization, XML docuemt handling and Zlib data compression etc. It worths mentioning that, most of these modules that wrap a C/C++ library are wrapped by an automated tool that generates the wrapping codes directly from the header files of those library, and this automated tool is written in Dao. Moreover, Dao has also included a module with functionality similar to the Ctypes module for Python. This module is based on the FFI library, and allows directly calling C functions of a C library from Dao without wrapping the library. List of features:
Here are little pieces of codes just to show how Dao look like:
# explicitly typing:
# declare variable with type: var1 : double = 0.0; var2 : map<string,float>; # implicitly typing: # define variables by enumerations: list1 = { 1, 2, 3 } map1 = { "CD"=>123, "AB"=>456 } tuple1 = ( 123, "ABC" ) # tuple with named items tuple2 = ( index => 123, name => "ABC" ) vector = [ 1, 2, 3 ] matrix = [ 1, 2; 3, 4 ] tuple2.name = "another name"; stdio.println( matrix[1,:] ); # second row
# function with parameter annotation:
routine Bar( a, b : int, c = "DEFAULT" ) { stdio.println( "parameters:", a, b, c ) } class Point { var X, Y, Z = 0.0; routine Point( x=0.0, y=0.0, z=0.0 ){ X = x; Y = y; Z = z; } } # different ways of constructing class instances: p1 = Point( 1, 2, 3 ); # calling constructor p2 = Point{ 1, 2, 3 }; # enumerating fields p3 = Point{ Z=>1, X=>2, Y=>3 }; # enumerating fields by names
# generators and coroutines with typed interfaces:
# int => tuple<int,int> routine gen1( a = 0 ) { k = 0; while( k ++ < 3 ) a = yield( k, a ); return 0,0; } routine gen2( a = 0 ) { return gen1( a ); } g = @gen2( 1 ); stdio.println( 'main1: ', g( 1 ) ); stdio.println( 'main2: ', g( 100 ) ); stdio.println( 'main3: ', g( 200 ) );
# functional methods:
# method( parameter(s) )->|variable(s)|{ inlined_function } a = { 1, 2, 3 } b = map( a ) -> { 10*x } # produce { 10, 20, 30 } b = map( a ) -> |x| { 10*x } # equivalent to above # map() can take more than one lists as parameters: b = { 11, 22, 33 } c = map( a, b ) -> |x,y| { x + y } # function composition c = map( a, b )->|x,y|{ x + y, x - y }->|u,v| { u * v }
view count 52184 times
created at 2009-02-19, 17:46 GMT modified at 2009-09-22, 00:03 GMT |
fu: A little bit game development in Dao! Thanks to ClangDao, it has become very easy to create bindings for C/ C++ libraries. The latest one i ... (May.14,07:08) dao: Dao 1.2 Beta1 is released! After a very long time of development, the first beta release for Dao 1.2 is finally available ( http ... (May.06,23:37) fu: ... Just to mention: a couple of demos (including the 2000 line one) has been successfully ported to IPho ... (May.19,02:43) fu: ... Yes, it is getting mature, and more libraries and modules are coming out, hehe:) For GameKit, unfor ... (May.19,02:38) Pompei2: ... This is cool news and really shows that ClangDao is getting mature, thumbs up. Too bad for this litt ... (May.18,09:17) fu: ... Not completely, but mostly. New revisions will be regularly pushed to the repository on google code ( ... (May.08,22:38) Pompei2: ... If I understand it correctly, you want to completely switch? If so then: (May.08,08:46) |