6 releases
0.1.23 | Aug 14, 2020 |
---|---|
0.1.22 | Aug 9, 2020 |
#429 in Programming languages
23 downloads per month
110KB
2K
SLoC
binks is an interpreted dynamically typed enbededd scripting language trying to be as simple as python and as clean looking as possible, written 100% in rust
Features
- simple and clean syntax
- embedded
- easy types extension
- easy dynamic libraries loading
Syntax
binks's syntax is inspired by Python, Rust and Dart.
variables are declared by the "let" keyword and can change their type throughout the program.
function are declared by the "fn" keyword followed by the name, the arguments in parenthesis and the code in to block that start with { end end with }
if/elif/else and while loop written with the keyword (if,elif...) followed by the boolean value (no need in parenthesis) and the code in a block that start with { end end with }
calling code from dynamic libraries is done by using the "extern" keyword followed by the path the function name and the argument it takes is this pattern: extern "path":"func":arg1,arg2,arg3
type extension is done by using the "extend" keyword followed by the type to extend and then all the functions you want to add in a block, all function need to have at least one argument and can be called with a method call syntax
use "binks:IO.binks" as Io
fn fib(n) {
if n == 1 || n == 2 {
return n - 1
}
return fib(n - 1) + fib(n - 2)
}
Io.println(fib(5))
extend str {
fn str_method(self) {
self = ": )"
}
fn str_method_2(self) {
if self == ": )" {
self = "0_o"
}
}
}
let s = ": ("
s.str_method()
s.str_method_2()
Io.println(s)
let x = 10
if 1 + 3 > 3.6 {
Io.println("if statement!")
}
while x > 0 {
x = x - 1
if x == 5 {
continue
}
Io.print(x)
Io.print(" ")
}
Io.print("\n")
class XCounter {
fn XCounter(self, x) {
self.x = x
}
fn print_x(self) {
Io.println(self.x)
}
fn increment(self) {
self.x = self.x + 1
}
}
let o = new XCounter("hello")
o.print_x()
o.x.str_method()
o.print_x()
let o2 = new XCounter(1)
o2.increment()
o2.print_x()
if o < o2 {
Io.println("false")
}
if o != o2 {
Io.println("true")
}
if o > o2 {
Io.println("false")
}
Installing
latest version:
requirements: rust, git
$ git clone https://github.com/omrihhh/binks.git
$ cd binks
$ cargo build --release
then add target\release to your path
stable:
requirements: rust
cargo install binks
Running
$ binks <path> <stack size (2 by default)>
Try it online
Next steps
important features i want to implement for the language to be and feel more complete
- while loop
- for loop
- classes
- more complex classes and objects
- operator overloading
- default/named function arguments
- imports
- syntactic sugar for index and update (array[1], array[0] = 1)
- lambda functions
- libstd
- embedded
Dependencies
~1.5MB
~25K SLoC