Koto 0.15
Koto 0.15 has been released, bringing new language features, improved support for general purpose scripting, and runtime performance improvements.
Many thanks to the contributors who helped to make this release happen!
Koto?
Koto is a free and open-source programming language which aspires to be an ideal scripting language for Rust applications.
If this is the first time you're reading about Koto, for some background information you could take a look at the About Koto page, or you could read the language guide.
Type Checks
The let
keyword has been introduced to allow for type-checked assignments:
# Assignments in Koto usually don't require a keyword
x = 5
# let assignments can include a type check:
let x: Number = 5
let y: String = 'hello!'
Type checks are performed at runtime, and will throw an error if a check fails. For applications that want to use type checks as assertions only in debug builds, a runtime setting allows them to be disabled.
Additionally, type checks can be added anywhere that named values can be created:
for i: Number, c: String in 'xyz'.enumerate
print i, c
extract_lines = |s: String| -> Tuple
s.lines.to_tuple
See the guide's section on type checks for more information.
Optional chaining
The ?
operator has been introduced to simplify expression chains where null
might be encountered as an intermediate value.
For example, given a map containing some data:
planet =
Before 0.15, if you wanted to get an optional value from the map, and then perform an operation on the value, you would need to first access the value and then guard the operation with an if
check:
name = if satellites = planet.get
if innermost = satellites.first
innermost.to_uppercase
# PHOBOS
With optional chaining, you can use the ?
operator to short-circuit the expression when null
is encountered.
name = planet.get?.first?.to_uppercase
# PHOBOS
name = planet.get?.get?.to_uppercase
# null
See the guide's section on optional chaining for more information.
Running external processes
The core library now includes support for running external processes, making Koto more useful for general purpose scripting.
print os.command
.args
.wait_for_output
.stdout
# ...
Performance improvements
Koto's runtime is significantly faster in 0.15 with benchmark improvements generally in the range of 15-30%.
Koto is also now single-threaded by default which has sped up runtime execution by a modest amount, see here for information on how to enable the multi-threaded runtime if needed.
LSP Server
It's also worth mentioning that koto-ls
, an LSP server for Koto, is now available.
See the news post for more information.
...and more!
These are some of the release highlights, see here for the full list of changes in 0.15.