Functional language with Lisp style syntax and some syntactic sugar for great readability.
Ark is a hobbyist language not to be taken seriously or used in production!
Ark will eventually be strongly typed and will be a good hybrid between classical imperative OOP and Functional language styles - leaning more towards the functional paradigm - aiming to get the best of both worlds.
Why am I creating this language? Mostly to learn. I love de-mistifying things that we commonly take for granted. Language implementation is no exception and there is so much to gain by having a better understanding of what goes into building a programming language and how they work.
;; this is a comment
let a = 1
print a ;; 1
let a = 2,
b = (** a 2)
print b ;; 4
let a = "G'day world"
(out a) ;; G'day world
Strings are enumerable and can be used in a for-in
enumerator expr.
let a = [1,2,3,4]
(out (len a)) ;; 4
Arrays are enumerable and can be used in a for-in
enumerator expr.
;; addition
(+ 1 2) ;; 3
;; substraction
(- 1 2) ;; -1
;; multiplication
(* 2 3) ;; 6
;; division
(/ 6 3) ;; 2
;; modulo
(% 5 2) ;; 1
(< 1 2) ;; true
(< 1 0) ;; false
(> 1 0) ;; true
(> 1 2) ;; false
(>= 1 0) ;; true
(>= 1 1) ;; true
(>= 1 5) ;; false
(!= 1 2) ;; true
(!= 1 1) ;; false
(^ 1 1) ;; 0
(^ 1 2) ;; 3
(& 3 1) ;; 1
(<< 1 2) ;; 4
(>> 2 1) ;; 1
(>>> 3 1) ;; 1
(| 3 1) ;; 3
~0 ;; -1 (bitwise compliment)
(and true false) ;; false
(and true true) ;; true
(or true false) ;; true
(or (> 1 2) (!= 1 3)) ;; true
(lambda sum : a b -> (+ a b))
(sum 4 6) ;; 10
(lambda filter : c f -> {
let a = []
(i:c) {
if (f i) {
(add a i)
}
}
send a
})
;; filter nums greater than 3
let nums = (filter [1,2,3,4,5] lambda : x -> (<= x 3))
(print nums) ;; [1,2,3]
Shorthand syntax to generate a range from a lower to an upper bound.
1..5 ;; [1,2,3,4]
1...5 ;; [1,2,3,4,5]
A range expression resolves to an Array.
for x in 1...5 {
(out x)
}
;; 1
;; 2
;; 3
;; 4
;; 5
With index identifier:
for x, i in 1...5 {
(out x i)
}
;; 1 0
;; 2 1
;; 3 2
;; 4 3
;; 5 4
This is probably my favourite feature of Ark. Using sends
adds so much clarity. You will see below how data flows
from the left to the right. Rather than nesting function calls, expression are evaluated from the left to the right...
[1,2,3,4] -> (pow 2) ;; [1,4,9,1,6]
-> (filter lambda | x -> (< x 5)) ;; [1,4]
-> (lambda | x -> Point(x:x, 0)) ;; [Point(1,0), Point(4,0)]
- Strong typing
- Structs
- Standard Library
- File I/O
- Network I/O (TCP/IP, HTTP)
- I/O Streams
- Regex
- Math
- Data Structures (Stacks, Queues, Heaps, etc)
- Dependency management (inspired by Golang github urls)
- Unit Testing Framework
- Static Analyser for IDE Integration
- Syntax Themes for Sublime, Atom, etc
- Open Ark prompt
$ ./ark
- Or, execute an ark file
$ ./ark [file]
- ⌨ Have fun!