According to its tagline, Chaos-lang is a “purely functional programming language that achieves zero cyclomatic complexity.” Since it is not object-oriented, it uses only functions and data types.
Chaos might look familiar in some places. It takes inspiration from many different programming languages, combining their best features into one cohesive language.
by Manfred Steyer (SOFTWAREarchitekt.at)
by Andrey Goncharov (Hazelcast)
Programming language features
One of the language’s key features is its zero control structures. Therefore it has no if..else
and no switch..case
.
Refer to the documentation on decision making and adding a function. Functional returns look like:
func myFunc(num a, num b)
// your code
end { x > 0 : f1(x), default : f2(x) }
According to the docs, it may seem ” unnecessary or inconvenient”, but it also provides clean, testable, error-free code. Chaos will warn the user about any untested functions in the executed program for complete test coverage.
In addition to this, it offers immutability on every variable by default.
C extensions
Chaos uses Occultist as a module manager, which went online on April 17, 2020. With the dependency manager, you can install Spells. A spell is a library that can either be a module or a Chaos C extension.
C extensions can extend the capabilities of C to Chaos via a dynamic library.
From the documentation:
Chaos C Extensions are the Chaos modules that written in C (to harness the capabilities of C) which sits under the spells
directory of your project root. They have either .so
or .dylib
or .dll
file extensions. Depending on your operating system.
In its essence, a Chaos C Extension is a dynamic C library that includes Chaos.h header and exports some of its functions to be used as functions in Chaos Language.
View some examples in the documentation, the anatomy of a spell, and see the template repository.
SEE ALSO: Programming with Beef: Open source language takes inspiration from C#
Testing out the magic
Learning a new language that is finding its footing can be fun. While you will experience some bumps and rough landings, it’s always worth diving into something new and exploring a different way of thinking.
Find this project on GitHub. Begin with the Hello World and read the documentation for more information. Help track any potential issues, request features, and take note of potential bugs.
On macOS, you will need Homebrew before installing. Windows users require the Chocolatey package manager.
What do you think of this programming language and its design?
The post Chaos: Functional programming language with C extensions appeared first on JAXenter.