19
Dao (programming language)

Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

Embed Size (px)

Citation preview

Page 1: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

Dao(programming language)

Page 2: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

2/19

Step aside✔ borrows heavily from various languages✔ every idea rethought (with substantially

different results from the origin)✔ e.g.

⚫ enums (Ruby)⚫ ranges (Python)⚫ defer (Go)⚫ „future“ concurrency (Scala)

Page 3: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

3/19

Language “market“✔ functional prog. concepts, advanced

typing system, immutability etc.⚫ expressiveness, readability and safety⚫ required control (run-time→ compile)

✔ broadening adoption of scripting

languages (increase in code's size)⚫ readability and controllability more

important than ease of use

Page 4: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

4/19

Design✔ VM (with GC), interoperability✔ fast exec. in mind and prepared for JIT✔ UTF-8✔ sophisticated type system (inference,

compile-time, templates, any, type

holders)✔ modularity (OOP, modules, interfaces)✔ control flow

Page 5: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

5/19

Design details✔ modules (Dao, C, C++)✔ higher-order functions, code sections (with

X, Y), code deferring✔ classes, interfaces (abstract, concrete),

mixins, wrapped types✔ invar, casting, recursive…✔ exception handling, concurrency means

Page 6: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

6/19

Example 1

0$ dao -e 'io.writeln("Hello world!")'Hello world!= none0$ dao -e ' "Hello world!" '= Hello world!0$

Page 7: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

7/19

Example 20$ cat ex2.dao#!/usr/bin/daoroutine main(... as args) { io.writeln(args) return 2}0$ ./ex2.dao( )2$ ./ex2.dao abc 5 7( "abc", "5", "7" )2$

Page 8: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

8/19

News 1✔ index ranges [ ] → [ ) (like Python)✔ removed function & class decorators✔ enhanced concrete interface „replacing“

function & class decorators✔ removed AOP („replacable“ by mixins,

interfaces, …)

Page 9: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

9/19

News 2✔ removed BNF syntax macros✔ removed customized verbatim strings

(e.g. foreign lang embedding)✔ many internal simplifications and

optimizations

Page 10: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

10/19

Interfaces✔ any object matching the whole signature

of an interface can be casted to that

interface✔ a concrete interface for an interface is

similar to a mixin

✔ casting is good in Dao

Page 11: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

11/19

Example 3aload timeinterface DateTimeX { routine add(invar self: time.DateTime, ...: tuple<enum<years, months, days>, int> as vargs) => time.DateTime}interface DateTimeX for DateTime { routine add(invar self: time.DateTime, ...: tuple<enum<years, months, days>, int> as vargs) => time.DateTime { self.add(vargs, ...) return self }}

Page 12: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

12/19

Example 3bload web.html import html

io.writeln( document { head { meta(http_equiv=$content_type, content='text' / 'html; charset=utf-8') } body { h1(style='font-size: 50pt') { 'My page at ' + (string)((DateTimeX)time.now()).add(years=3) } }})

Page 13: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

13/19

Example 3c<!DOCTYPE html><html><head> <meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body> <h1 style="font-size: 50pt"> My page at 2019-11-05 10:58:17.254210 +1:00 </h1></body></html>

Page 14: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

14/19

Example 4interface Callable { routine ()( ... ); }interface Callable for routine { routine ()( ... as args ){ io.writeln( "Callable<routine<>>()" ); self( args, ... ) }}routine Test( par: string ){ io.writeln( "Test", par ) }const T: Callable = Test;T( "ABC" );

Page 15: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

15/19

Example 5interface TestUnit { routine Run() }interface Testing { routine RunTest() }interface Testing for TestUnit { routine RunTest(){ io.writeln( "Testing<TestUnit>::Run()" ) self.Run(); } }class OneTest { routine Run(){ io.writeln( "OneTest::Run()" ) } }var test: Testing = OneTest()test.RunTest()

Page 16: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

16/19

Use

✔ bioinformatics✔ computational mathematics✔ parallel and distributed systems✔ „fat“ embedded (e.g. IoT)✔ GUI✔ games✔ fun!

Page 17: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

17/19

Use

Page 18: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

18/19

Project

✔ http://daoscript.org (powered by Dao)✔ https://github.com/daokoder/dao✔ subprojects (dao-modules, JIT, Graphics -

3D, SQL, SDL, CXX, Studio, Emscripten

web, ...)✔ 6 main contributors, 7 other contributors

(data from Nov 2016)✔ reference VM (exe 9896 B, lib 926192 B)

Page 19: Dao - Konference OpenAlt Pacner - Dao.pdf⚫ ranges (Python) ⚫ defer (Go) ⚫ ... (Dao, C, C++) higher-order ... tuple as vargs) =>

19/19

?