An unorthodox scripting language.
To start using Kiwi, please follow the instructions below.
Experiment with Kiwi in a Docker container.
sudo docker build -t kiwi-lang .
sudo docker run -it -v $(pwd):/workspace kiwi-lang
To build Kiwi, use your favorite C++ compiler.
This repo uses GCC and Make.
sudo dnf update
sudo dnf install gcc-c++
sudo dnf install make
sudo apt update
sudo apt-get install g++
sudo apt-get install make
Then build with Make.
make
Download the repository and run sudo make install
to build Kiwi and run the installation script.
git clone https://github.com/fuseraft/kiwi.git
cd kiwi
sudo make install
./bin/kiwi configure install
kiwi configure uninstall
You can find a 64-bit build (named kiwi.exe
) in the latest release.
To build on Windows, you need to open a 64-bit hosted developer command prompt.
Then navigate to the source code and run build.bat
.
cd path\to\kiwi
build.bat
Note: The Windows build does not support .🥝
files (use the .kiwi
extension).
You can install the extension for syntax-highlighting in VS Code.
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
ext install fuseraft.kiwi-lang
You can find detailed information on language features in the Kiwi Wiki.
Explore the tests directory for a collection of test scripts.
To run the test suite, execute:
kiwi test
To build and run the test suite, execute:
make test
Below is a simple HTTP web application. You can find the example project here.
import "@kiwi/web" as web
import "@kiwi/fs" as fs
# HTML helpers
html = {
"shared": fs.read("templates/shared.html"),
"index": fs.read("templates/index.html"),
"contact": fs.read("templates/contact.html")
}
# A simple template engine.
fn build_html(data)
return html.shared.replace("<%content%>", data)
end
# GET /
web.get(["/", "/index"], with (req) do
return web.ok(build_html(html.index), "text/html")
end)
# GET /contact
web.get("/contact", with (req) do
return web.ok(build_html(html.contact), "text/html")
end)
# POST /contact
web.post("/contact", with (req) do
println("Received content from client:\nbody: ${req.body}\nparams: ${req.params}")
return web.redirect("/")
end)
# serve static content
web.public("/", "./public")
# server and port configuration
host = "0.0.0.0", port = 8080
# start the web server
println("Starting Kiwi Web Server at http://${host}:${port}")
web.listen(host, port)
Below is a script that generates a temporary script and executes it.
import "@kiwi/fs" as fs
import "@kiwi/math" as math
import "@kiwi/sys" as sys
try
# Look for a temporary directory. Fail fast.
if !fs.exists(fs.tmpdir())
println("Could not find temporary directory.")
exit(1)
end
# Generate a random temporary file path.
filename = math.random("0123456789ABCDEF", 10)
path = fs.combine(fs.tmpdir(), "${filename}.kiwi")
# Write a little 🥝 script.
fs.write(path, "
/#
This script will delete itself and let you know it was there.
#/
import \"@kiwi/fs\" as fs
fs.remove(\"${path}\")
println(\"Kiwi was here running as ${fs.filename(path)}.\")
")
# Run the 🥝 script.
sys.exec("kiwi ${path}")
catch (err)
println("An error occurred: ${err}")
end
I welcome and appreciate any and all contributions to the Kiwi project! Here's how you can contribute:
- Join the Discord: The Kiwi Programming Language
- Fork the Repository: Fork the project to your GitHub account.
- Clone the Forked Repository: Clone it to your machine.
- Set Up Your Environment: Follow the "Getting Started" section.
- Make Changes: Implement your features or fixes.
- Test Your Changes: Ensure all tests pass.
- Create a Pull Request: Submit it from your fork to the main Kiwi repository.
For more details, please read CONTRIBUTING.md.
This project is licensed under the MIT License.