The zkl Programming Language

zkl is a general purpose object oriented programming language. It is imperative but borrows concepts from many programming paradigms, including functional and prototype based. It is curly-bracketed, dynamic, reflective, and threaded. It has built in garbage collection, strings, lists, dictionaries, threads, fibers (continuations and co-routines) and more. The syntax strongly resembles the C programming language while the data model is closer to that of Python and Smalltalk.
The goals of the language are rapid prototyping and programmer productivity. Program speed and the the constraints of production oriented programming are not high on the "needs" list.

>zkl # Run the zkl shell
zkl: 1+"2" # polymorphism
3
zkl: "1" + 2
12

zkl: "string".dir() # ask string to look at itself and tell us what it sees
string : StringConst
Methods:
BaseClass Method Property __sGet __sSet apply callMethod callProperty copy create dir filter find fits fmt holds inCommon index isChildOf isInstanceOf isSpace isType len matches method noop property replace resolve rfind split strip toAsc toBool toClass

...

zkl: (1).dir()
1 : Int
Methods:

...

zkl: L(1, "2", 3.4, L(5,"six"), self, fcn(x) { x + 1 }).apply("type") // List
L("Int","StringConst","Float","List","Class","Fcn")

zkl: fcn f(x) { println("%s is a %s".fmt(x,x.type)) }
zkl: f(f); f(1)
Fcn(f) is a Fcn
1 is a Int

// Threads and fibers:
zkl: print(vm," "); fcn { println(vm) }.launch()
VM#6 VM#10077

zkl: var fiber = vm.createFiber(fcn { vm.yield(vm); "Fiber is done" })
VM#18541
zkl: vm.vms # ask the VM for a list of the active VMs
L(VM#18541,VM#6)
zkl: fiber.resume()
Fiber is done
zkl: vm.vms
L(VM#6)

zkl: var socket = Network.TCPClientSocket.connectTo("www.google.com"); \
zkl: ...> socket.write("GET / HTTP/1.0\r\nHost: www.google.com\r\n\r\n")
zkl: socket.read(True).text

HTTP/1.0 200 OK
Cache-Control: private

Content-Type: text/html; charset=ISO-8859-1
...

zkl: # factorial, you can also write this with tail recursion or without using "if/else"
zkl: fcn fact(x) { \
zkl: ...> if (x == 0) return(1); \
zkl: ...> return(x * fact(x-1)); \
zkl: ...> }
Void
zkl: fact(5)
120
zkl: ^D

>zkl -c Src/Compiler/compiler.zkl
Compiled Class(Compiler) (1.4 seconds)

 

     
All rights reserved