IRC: #ducky-lang at irc.freenode.net
Ducky is a BASIC-like programming language originally insipred by Duckyscript, the USB Rubber Ducky's scripting language.
#!/bin/ducky
LOG Hello, world!
NEWLINE
Simple!
#!/bin/ducky
LET a = 0; LET b = 0; LET iter = 0
LABEL loop_start
LOGVAR a
NEWLINE
LET c = a+b
LET a = b
LET b = c
INC iter
IF iter < 20; GOTO loop_start
LOG Done!
NEWLINE
#!/bin/ducky
LOG Counting...
NEWLINE
LET primes=0
LET MAX=100000
LET n = 2
LBL test_number
LET iter = 2
LET stop = sqrt n
LBL test_loop
IF !(n % iter); GOTO composite
INC iter
IF iter <= stop; GOTO test_loop
INC primes
LBL composite
INC n
IF n < MAX; GOTO test_number
LOG Number of primes below
LOGVAR MAX
LOG :
LOGVAR primes
NEWLINE
POSIX systems are supported, as are some Rockbox targets.
make
sudo make install
This installs the /bin/ducky
binary.
ducky scriptname.ds
ducky -c scriptname.ds
This will create a.out
, which contains the bytecode.
ducky a.out
ducky -a scriptname.ds
./a.out
The program consists of four parts: the interpreter, compiler, bytecode interpreter, and C transcompiler.
Executes ducky directly.
Compiles ducky to a stack-machine based bytecode.
Executes the bytecode generated by the bytecode compiler.
Translates bytecode generated by the bytecode compiler into C.
21 Nov 2015:
c - clang 26 27 27 27 27 27 27 27 27 27 - AVG 26.9
c - gcc 29 29 29 29 29 29 29 29 29 29 - AVG 29
c - tcc 28 28 28 28 28 28 28 28 28 28 - AVG 28
ducky - clang 15 15 15 15 15 15 15 15 15 15 - AVG 15
ducky - gcc 28 28 28 28 28 28 28 28 28 26 - AVG 27.8
26 Nov 2015:
Language | Compiler | Optimization Level | Scores | Mean score |
---|---|---|---|---|
Ducky | Clang | -O0 | 4 4 4 4 4 4 4 4 4 4 | 4 |
Ducky | Clang | -O1 | 15 15 15 15 15 15 15 15 15 15 | 15 |
Ducky | Clang | -O2 | 21 21 21 21 21 21 21 21 21 21 | 21 |
Ducky | Clang | -O3 | 21 21 21 21 21 21 21 21 21 21 | 21 |
Ducky | GCC | -O0 | 5 5 4 5 5 5 5 5 5 5 | 4.9 |
Ducky | GCC | -O1 | 22 23 23 23 23 23 23 23 23 23 | 22.9 |
Ducky | GCC | -O2 | 26 26 26 26 26 26 26 26 26 26 | 26 |
Ducky | GCC | -O3 | 26 26 26 26 26 26 26 26 26 26 | 26 |
C | Clang | -O0 | 28 28 28 28 28 28 28 28 28 28 | 28 |
C | Clang | -O1 | 28 29 29 28 28 28 28 28 29 29 | 28.4 |
C | Clang | -O2 | 28 29 29 29 28 29 29 28 28 28 | 28.4 |
C | Clang | -O3 | 28 28 28 29 28 29 28 29 28 28 | 28.3 |
C | GCC | -O0 | 28 28 28 28 28 28 28 28 28 28 | 28 |
C | GCC | -O1 | 30 30 30 30 29 30 29 30 30 29 | 29.7 |
C | GCC | -O2 | 30 30 30 30 30 30 30 30 30 30 | 30 |
C | GCC | -O3 | 30 30 30 30 30 30 30 30 30 30 | 30 |
- Refactor code
- Input
- Add more builtins
- Arrays?
- Functions?