SK is a high-level interpreted programming language designed to handle incomplete, approximate, or partially known information as first-class entities. Unlike traditional languages, SK does not assume all variables have exact values. Instead, it tracks uncertainty explicitly throughout calculations, decisions, and control flow.
The language is designed for safer, more honest, and analyzable computation in contexts where data may be noisy, incomplete, or evolving.
The final version of SK is in the works with a full scale Rust interpreter, this interpreter can run files but also features a REPL mode. For more information on the language features and installation please take a look into the docs.
- Install the SK interpreter by running
cargo install sk-lang- or download the latest binaries here!
Please consider taking a look to the docs here: documentation
SK started as a Python-based prototype. This is now deprecated.
In order to run the python sk tests:
python3 sk.py <testname> # only after 'test-', inside ./python-prototype/This project is under the MIT License, please see LICENSE for more information!
SK supports several kinds of values:
- Known values – exact, fully determined numbers or objects:
let number = 3
let string = "hello!"
let boolean = true- Intervals – ranges of possible numeric values:
let temperature = [18..24] // temperature can be any value between 18 and 24- Unknown values – undefined, but tracked:
unknown x
// or
let x = unknown- Symbolic values – formulas that may depend on unknowns or intervals:
symbolic area
area = side^2- Quiet symbolic values – similar to symbolic, but it keeps the formula always hidden
quiet volume
volume = side^3- All arithmetic operators propagate uncertainty:
let a = 2
unknown b // 'Same as' let b = unknown
symbolic z = a + b
print(z) // → a + b
print(resolve(z)) // → 2 + unknown
b = 3
print(z) // → 2 + 3
print(resolve(z)) // → 5- Zero propagation and Exponentiation edge cases:
0 * unknown = 0
0 ^ 0 = 1 // YES it is, Okay?!- Knowledge Operators:
let val = [10..20]
let check = val > 15
print(check) // → partial
print(certain(check)) // → false
print(possible(check)) // → true
print(known(val)) // → false- Interval Operators (moved to the
mathlibrary):
let A = [0..10]
let B = [5..15]
print(width(A)) // → 10
print(mid(A)) // → 5
print(union(A, B)) // → [0..15]
print(intersect(A, B)) // → [5..10]- Control flow respects uncertainty:
let x = [0..1]
if x > 0.5 -> merge { // merge is an 'if policy'
result = "high"
} else {
result = "low"
}-
In order to solve uncertain cases, ifs can have different policies:
strict(Default) Doesn't run any branchmergeRuns both branchespanicRunetime Error
-
Scopes:
let a = 10
{
let a = 15
let b = 67
print(a) // → 15
}
print(a) // → 10
print(b) // Error! 'b' is out of scope- Functions can accept uncertain values and propagate uncertainty:
fn addUp(n) {
n * (n + 1) / 2 // No 'return' keyword! it returns the last value of the block
}
let result = addUp(50)- Functions operate seamlessly on known, interval, unknown, and symbolic values.
- Note that all functions are private by default, use the
pubkeyword to allow other files to use them
print()input()str()converts anything to a stringnum()converts, when possible, to a numberpanic!or simplypanic(not recommended), throws a run time error and finishes program execution
let n = 10
loop {
if n <= 0 {
break
}
print(n)
n = n - 1
}- The
loopstatement includes thebreakandcontinuekeywords
- SK features a multiple file import system for better organization and scalability
import "utils.sk" as utils
import "server.sk" as server -
For more control it also features the
askeyword to name aliases. Also note that all functions are private to other files by default, using thepubkeyword at the start of a definition makes them public -
SK includes many standard libraries, written directly in rust, such as:
mathrandosfs(i.e. the file system library)timeunitsspecial case, look at point 9
Please consider taking a look to the docs for more information: documentation
[Runtime Error]: Use of undefined variable 'myvar' (files/test.sk:6:8)
|
6 | print(myvar) // Error...
| ^^^^^Although not fully implemented, SK will support the usage of units for any variable, This does only work if imported the special units library
import units
let velocity = [0..20] m/s
let period = 50 s-
Some ideas yet to come:
- Constrains
unknown x > 0 // x is unknown but positive unknown x % 2 == 0 // x is unknown but even
- The
explainprimitive function
let z = a + b * c explain(z) // returns // z depends on: // ├─ a (known: 2) // └─ b * c // ├─ b (unknown) // └─ c ([1..3])
-
array type + for loops
-
the match statement (like in rust)
-
the
observeprimitive function
let temperature = [10..15] let measurement = temperature + 2 observe measurement = 15 // thus, temperature is now 13
- Any proposed ideas are welcome!
SK has a language support extension for Visual Studio Code that includes small refinements to make working with SK easier.
- Download the latest version in here or build the extension yourself inside
extensions/vscodewith:
cd extensions/vscode/
vsce package- Then, inside vscode, go to Extensions (
Ctrl + Shift + X) and select the option from the menu (...) ->Install from VSIX...
Proud member of HackClub!
https://flavortown.hackclub.com/projects/8834
Took many cool ideas from this other project, so ty! @cyteon MODU Programming Language