Kos is a general purpose scripting language, which builds on top of the most successful scripting languages, but is designed with usability in mind.
Easy to learn and easy to use.
Useful for creating standalone scripts.
Easy to embed in other applications.
Dynamically typed, object-oriented, with elements of functional programming.
Stable and reliable syntax, so your scripts will work in the future without any modifications.
Small code base and small footprint.
Simple, modern, feature-rich and powerful syntax, designed to reduce common types of bugs.
Robust support for native multithreading.
Kos is currently in development. Most language features are already usable.
Refer to Roadmap for list of features planned.
To find out more about Kos, follow these links:
- Quick Start
- Syntax Highlighting
- Tutorial
- Library Reference
- How to compile Kos from source
- Principles and ideas which influenced Kos design
- List of possible ideas for future development
- Formal description of Kos syntax
- Information on how to contribute to Kos
- Kos license
This program prints "Hello, World!":
#!/usr/bin/env kos
importbase.printprint("Hello, World!")This program prints 30 terms of the Fibonacci series:
#!/usr/bin/env kos
importbase: print,rangeconstterms=30vara=0varb=1print("Fib series:")forvariinrange(terms){print(" \(a)")constnext=a+ba=bb=next}This program prints the first 1000 prime numbers:
#!/usr/bin/env kos
importbase: print,range,enumerateimportmath.sqrt
# Primenumbergeneratorwithafixed-sizesievefunprimes(sieve_size){yield2 # Yieldtheonlyevenprimenumberfromthegeneratorconstsieve=[] # Emptyarray
# Setarraysize,fillswith 'void' values.
# Wesettohalfofthemaxnumberchecked,because
# weignoreevennumbersandonlycheckoddnumbers.constlen=sieve_size/2sieve.resize(len)constsqrt_sieve_size=sqrt(sieve_size)
# Findandyieldalloddprimesforvarnumberinrange(3,sieve_size,2){constidx=number>>1
# Yieldthisnumberasprimeifithasn't been sifted-out
if!sieve[idx]{yieldnumber
# Don't clear above square root of sieve size, because
# thesenumbershavealreadybeenclearedbylowerprimesifnumber>sqrt_sieve_size{continue}
# Markallmultiplicitiesofthisprimeasnon-primes
# Startfromsquareofprime,becauselowernumbershave
# alreadybeenclearedforvariinrange(number*number/2,len,number){sieve[i]=true # Markanon-prime}}}}publicfunmain{print("Prime numbers:")varcount=0forvaridx,primeinenumerate(primes(7920)){print(" prime \(idx + 1) is: \(prime)")count+=1}print("Printed \(count) primes")}