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
zkl: "1" + 2

zkl: "string".dir() # ask string to look at itself and tell us what it sees
string : StringConst
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


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

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" })
zkl: vm.vms # ask the VM for a list of the active VMs
zkl: fiber.resume()
Fiber is done
zkl: vm.vms

zkl: var socket = Network.TCPClientSocket.connectTo(""); \
zkl: ...> socket.write("GET / HTTP/1.0\r\nHost:\r\n\r\n")

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: ...> }
zkl: fact(5)
zkl: ^D

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


All rights reserved