Chaos: Functional programming language with C extensions

Share
  • April 27, 2020

Chaos is a new, open source programming language, and while it still has some way to go before a stable release, it offers a glimpse at an intuitive approach to functional programming.

Its most recent version is v0.0.1-alpha.3. How do you turn Chaos into magic? Let’s have a look at its design goals and some of its features.

SEE ALSO: “The Open Source Way has proven itself as the leading way to develop software solutions”

Functional programming

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.

From its README, its inspirations include:

  • TypeScript’s type safety
  • Python’s syntax, modules and extensibility
  • JavaScript’s availability
  • Ruby’s loops and blocks
  • PHP’s dedication to server-side
  • Haskell’s immutability
  • C’s speed
  • NumPy’s matrix arithmetic
  • Perl’s regex engine
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.

Source : JAXenter