K2 is an ultra-fast programming language with execution times between 70 nanoseconds and 9 milliseconds. It features a simple syntax for basic arithmetic operations and variable management.
- Ultra-Fast Execution: Most operations complete in under 1000 nanoseconds
- Simple Syntax: Easy to learn and use
- Performance Monitoring: Built-in execution time display
- File-Based Execution: Run programs from files
- Direct Expression Mode: Execute single expressions from the command line
- Minimal Footprint: The entire interpreter is under 30KB
# Clone the repository
git clone https://github.com/JJPEOPLES/k2lang.git
cd k2lang
# Build and install
./scripts/build.sh
sudo ./scripts/install.sh# Build the Debian package
./scripts/build_deb.sh
# Install the package
sudo dpkg -i k2-language_1.0.0-1_amd64.deb# Run a K2 program file
k2 examples/basic.k2
# Execute a single expression
k2 -e "print 100 + 200"# Basic K2 program
x = 42
print x
Output:
42
Execution time: 1230 nanoseconds
# Arithmetic operations
a = 10
b = 5
sum = a + b
diff = a - b
product = a * b
quotient = a / b
print sum
print diff
print product
print quotient
Output:
15
Execution time: 1150 nanoseconds
5
Execution time: 1120 nanoseconds
50
Execution time: 1130 nanoseconds
2
Execution time: 1140 nanoseconds
src/- Source code for the K2 languagebin/- Precompiled binarydocs/- Documentationexamples/- Example K2 programsscripts/- Build and installation scriptstests/- Test files
scripts/build.sh- Builds the K2 interpreter from sourcescripts/install.sh- Installs K2 on your systemscripts/build_deb.sh- Creates a Debian packagescripts/run_tests.sh- Runs the test suite
For complete documentation, see the K2 Language Documentation.
K2 is designed for speed. Here are typical execution times:
| Operation Type | Execution Time Range |
|---|---|
| Variable assignment | 100-400 nanoseconds |
| Simple arithmetic | 70-500 nanoseconds |
| Print operation | 1000-2000 nanoseconds |
| Complex expressions | 300-5000 nanoseconds |
K2 is released under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.