[Re]introducing the Clio programming language

What is Clio?!

Clio is a functional, parallel, distributed programming language. It lets you easily scale your code, effortlessly run it on multiple threads, use network resources, host your functions, create micro-services by executing a simple command, and a lot of other cool features. It runs in the browser, and also on your servers. It has a neat, clean syntax and it encourages good practices. Below you can see our playground and a few of our examples:

(Our playground might not look great or work well on mobile phones because of Monaco editor limitations)

Why?

No really, why? Why would anyone make a new language? Does the world need a new language? Probably not, but most of the things we do aren’t done because there is a need for them, sometimes we don’t even know what we need. Sometimes we’re just passionated about something, sometimes we have a vision that we want to share with the world.

But really, why?

Because I believe a programming language can do much more than just translating what the programmer writes into what a machine can understand. Because I believe a modern programming language should take care of the common modern application problems. I believe we developers should focus on the task at hand, and solve the problem we intend to solve, instead of fighting the language.

What makes Clio different?

Well, many things. Clio has a clean syntax, it focuses on expressiveness, and is noise-free. It encourages best practices, and introduces new ways of making an application. Clio is not just another language, it’s an entire ecosystem for micro-services and distributed systems, it’s an ideology, a culture. Clio makes it easy to run your code on multiple threads, even on the browser, we take care of the boring details for you so you can focus on making the great things that you envision.

Ok, show us a few examples!

The first example I want to show you, is a real-time todo app written in just a few lines of Clio. Thanks to Clio’s micro-services and remote functions (the ability to define a function and import it somewhere else over the network!), it’s only needed to define the get, make, update and delete functions on the server-side, and export them. Clio takes care of the rest.

The Clio todo app uses Firebase Firestore to store todo items.

Any other examples? Uh, a little more scientific?

How about a multi-threaded game of life, or a multi-threaded Mandelbrot render?

128x128 game of life on left, 1024x1024 Mandelbrot set on the right (with 1000 iterations), written in Clio.

So how’s the performance??

The performance is pretty neat. V8 is very fast, and that in turn makes Clio a fast language. Clio compiles to optimized JavaScript and is most of the time slightly faster than JavaScript, because Clio does things differently, like avoiding intermediate assignments thanks to its pipe syntax. Need more than that? No problem, just use Clio’s sandwich syntax to run functions in parallel and boost your code performance!

Clio performance compared to JavaScript: Find prime numbers by trial division, use Jimp (A pure JS image manipulation library) to add a greyscale filter to a few images, calculate the Fibonacci series.

But how does it work?!

We have developed a protocol for calling functions over the network as well as a gateway and accompanying libraries facilitating the use of this protocol. The ecosystem lets the clients and workers connect using different connection protocols (TCP, UDP, WebSockets, IPC…) to accept or request function calls and tasks. The Clio compiler then generates code that uses this new protocol to provide parallelism, remote functions and micro-services.

So, how does it look like?

It looks clean. Very clean, and practical. We have pipes, implicit returns, implicit lambda parameters and a lot of other cool stuff. Let me show you a few examples of our syntax:

Function calls

In Clio, we don’t use parentheses for function calls, and we don’t use a comma for the arguments we pass to the functions:

Go on and click on the run button!

Pipes

We don’t like nesting function calls, it makes them unreadable. That’s why we added pipes!

Anonymous functions

Clio has short anonymous functions with implicit parameter declarations. How to use them? Just take an expression, prefix any of the constants with an @ and wrap it in parentheses! They’re super useful when working with array transformations such as filtering and mapping:

Indented hash-maps

We have yaml style hash-maps in Clio, here’s how they look like:

What’s the current state of the language?

Short answer: in development. I started developing Clio a little more than two years ago. We added a lot of features and we removed a lot of them, most of the time to ensure compatibility with JavaScript, or to make the language faster. The language isn’t final, and while it “works” it is not ready for production.

The Clio logo shows two lambda symbols and a pipe in-between them.

 by the author.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pouya Eghbali

Pouya Eghbali

Founder at Kenshi, Clio programming language, and CTO at Equip.