Just some sample cliffhanger code, nothing to see here :)

Nov 2, 2021·

2 min read

Cliffhanger is a natural declarative stream processing language I've been working on for almost a year now (and haven't written a single line of compiler code yet ^_^). Today, I almost feel like the draft of the language is ready for general feedback :)

Here's an example CH application:

a user:
  name is an input text line after the output is "Enter your name: "
  age is an input number after the output is "Enter your age: "
  email is an input string after the output is "Enter your email: "
  name must not be false when the user is verified
  is verified when the user email is not false

output is:
  before exit:
    when the user is verified: "You've been verified, {the user name} of age {the user age}. Good luck!"
    else: "Goodbye, anonymous!"

This example application asks a user for his name, age, and email, and then prints a greeting to the user. If the user does not enter their email then the application will not verify him and output "Goodbye, anonymous".

Note the "must not be" construct that can be used to verify the integrity of the data.

As you can see from the source code, I hope to implement non-linear control flow in cliffhanger, making it an event-driven language. Cliffhanger's execution mechanism is very similar to Javascript's event loop but, instead of executing code, cliffhanger's event loop processes data mutations according to provided by developers data definitions.

Why is it a stream processing language? Because cliffhanger datapoints correspond to streams of values of that datapoint and the stream can be accessed using the plural form of datapoint name:


a message:
  subject is a string
  author is a user
  recipient is a user
  text is a string

a user message is a message

total message count is messages count  // messages is a stream of 'message' objects

In this example, cliffhanger will create a message class datapoint and messages stream for the instances of that class. This stream can later be filtered into other streams: a message is a spam if a spam word is in the message text

Cliffhanger datapoint values will be automatically updated, for example, a datapoint with a value defined like this: the last 10 messages will always point to the last 10 objects of the messages stream.

I am still working out the details of the language by periodically updating the README.md of its github project.

Cliffhanger is an experimental language. I hope to have a simple execution environment for it around or before May 2022. In the meanwhile, I would really appreciate your feedback on the language.

Thank you!