GithubHelp home page GithubHelp logo

impossiblereality / koto Goto Github PK

View Code? Open in Web Editor NEW

This project forked from koto-lang/koto

0.0 0.0 0.0 3.06 MB

A simple, expressive, embeddable programming language, made with Rust

License: MIT License

Rust 100.00%

koto's Introduction

Koto

Docs Crates.io CI Discord

Koto is an embeddable scripting language, written in Rust. It has been designed for ease of use and built for speed, with the goal of it being an ideal choice for adding scripting to Rust applications.

Koto is versatile enough to be useful in a variety of applications, although there has been a focus during development on interactive systems, such as rapid iteration during game development, or experimentation in creative coding.

Current State

The language itself is far enough along that I'm happy to share it with the wider world, although you should be warned that it's at a very early stage of development, and you can expect to find missing features, usability quirks, and bugs. Parts of the language are likely to change in response to it being used in more real-world contexts. We're some distance away from a stable 1.0 release.

That said, if you're curious and feeling adventurous then please give Koto a try, your early feedback will be invaluable.

Getting Started

A Quick Tour

import io.print, test.assert_eq

# Numbers
x = 1 + 2.5 + 100.sqrt()
assert_eq x, 13.5

# Strings
name = "Koto"
print "Hello, $name!"

# Functions
square = |n| n * n
print "8 squared is ${square 8}"

add_squares = |a, b| (square a) + (square b)
assert_eq (add_squares 2, 4), 20

# Iterators, ranges, and lists
fizz_buzz = (1..100)
  .keep |n| (10..=15).contains n
  .each |n|
    match n % 3, n % 5
      0, 0 then "Fizz Buzz"
      0, _ then "Fizz"
      _, 0 then "Buzz"
      else n
  .to_list()
assert_eq
  fizz_buzz,
  ["Buzz", 11, "Fizz", 13, 14, "Fizz Buzz"]

# Maps and tuples
x = {peaches: 42, pears: 99}
assert_eq
  x.keys().to_tuple(),
  ("peaches", "pears")

y = # Maps can also be defined using indented `key: value` pairs
  apples: 123
  plums: 99

fruits = x + y # Maps can be combined using the `+` operator

fruit, amount = fruits.max |(_, amount)| amount
print "The highest amount of fruit is: $amount $fruit"

Learning the Language

While there's not yet a complete guide to Koto, there are some code examples that are a good starting point for getting to know the language.

Reference documentation for Koto's core library can be found here.

You're also welcome to ask for help in Discussions, or on the discord server.

Installation

The most recent release of the Koto CLI can be installed with Cargo:

cargo install koto_cli

REPL

A REPL is provided to allow for quick experimentation. Launching the koto CLI without providing a script enters the REPL.

» koto
Welcome to Koto v0.1.0
» 1 + 1
2
» io.print "{}, {}!", "Hello", "World"
Hello, World!
()

A help system is included in the REPL. Run help for instructions.

Language Goals

  • A clean, minimal syntax designed for coding in creative contexts.
  • Fast compilation.
    • The lexer, parser, and compiler are all written with speed in mind, enabling as-fast-as-possible iteration when working on an idea.
  • Fast and predictable runtime performance.
    • Memory allocations are reference counted.
    • Currently there's no tracing garbage collector (and no plan to add one) so memory leaks are possible if cyclic references are created.
  • Lightweight integration into host applications.
    • One of the primary use cases for Koto is for it to be embedded as a library in other applications, so it should be a good citizen and not introduce too much overhead.

Editor Support

koto's People

Contributors

ales-tsurko avatar alisomay avatar irh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.