ActLang

Actor Beam Community

ActLang

ActLang is a modern functional programming language to build highly distributed applications for BEAM Virtual Machine. Inspired by Erlang's process and Akka Toolkit's Actor-based concurrency model. Actlang is a general-purpose language that makes programming fun and simpler from learning to building enterprise-grade solutions. If you are already familiar with FP paradigm for languages like Haskell, Clojure, Scala e.g, you found actlang easier to start with

Background & Motivation

A Statically Typed language with all modern features to create stable, less error-prone applications for battle tested Erlang based systems. To make programming easeir for new developers by utilizing the features of functional programming like:
Declarative Style ( what, not how) , Functions as first class citizens ( higher-order functions, transformations), immutability, basic algebric data types e.g.

Another goal of actlang is to provide a fantastic developer experience. Simply put, developers should be both highly productive and experience joy when programming. Making them free from the major problem of concurrency: "Shared Mutable State", to build a fault-tolerant system that supports the paradigm: "Let It Crash"

Unlike other programming languages and compilers, ActLang is built around the concept of early-compilation. Avoiding programmers to make bad logical mistakes.

We have some talk sessions in plan. When a video of the talk is available, we will post it here!

Getting Started

Setting up

Working with ActLang is easy! We have to first install Erlang on our system as aclang utilize underlying Beam compiler. Install the actlang compiler for corresponding OS. currently Unix-based operating systems are the primary focus: MacOS (via homebrew), Linux e.g, but compilation stuff for windows will soon be available. create a file with .act extension and you are ready to complile the code

  $ brew install erlang
  $ brew install actlang

Hello World!

Let’s write a hello world program

# hello.act

  act Hello {
    // all actions are defined here

    func start() {
        print("Hello World")
    }
  }

And now we can run the program using actlang compiler:

$ actlang hello.act
$ Hello.start()
$ Hello World

A beam file is generated in the source directly. *.beam

This beam file is used by BEAM VM to run the program. It is popular for its suitability to build low-latency, fault-tolerant, and distributed applications.

Some of the language semantics are:


  // variables ( so called values ) - type inference
  val x = 1
  > x: Int = 1

  // immutability at the core of the language
  x = 2
  > error: reassigments to an immutable varible x

  // functions are first class citizens

  val areaRectangle(width: Int, height: Int): Int = width * height
  val area = areaRectangle(width: 10, height: 12)
  > area: Int = 120

  // funcitons that don't return anything
  func doSomething() {
      print("some task...")
  }

  // higher-order functions
  val transform(arr: [Int]): [Int] = {
      arr.map(x -> x + 1)
  }

  > [1, 2, 3] => [2, 3, 4]


  // Hashmap
  val keyValuePairs = ["key1": "value1", "key2": "value2"]


  // Custom types, compositions, Algerbric data types (Sum & Product): OR, AND

  type PaymentAmount: Float
  type CardType = Visa | Mastercard
  type Currency = EUR | USD

  type Payment {
      amount: PaymentAmount,
      currency: Currency,
      cardType: CardType
  }


  val payment: Payment = (amount: 50.5, currency: Currency.USD, cardType: CardType.Mastercard)

  // No Global State

  val someValue = 10
  func calculate() {
      val x = someValue
  }

  > error: global state found for variable someValue. variable scope should be defined inside a function



  // Asynchrounous operations

  async {
    dosomthing in a different thread / process
  }

  // function to evaluate some result in future
  func doSomething() async {
    ...
  }
  
  // structured concurrency pattern  
  async {
    val result = await doSomething()
  }
  
  // multiple async operations in parallel
  async {
    async val result1 = doSomething1()
    async val result2 = doSomething2()
    val combine = await[result1, result2]
  }

  
  
  //Generic functions with possible outcomes
  func getBookingDate<T>(booking: Booking): Either[R<T>, Error] {
    ...
  }
  
  

Is ActLang Right for Me?

  1. Are you want to create highly distributed applications without worrying about concurrency
  2. Are you targeting high performance systems
  3. Do you need a language to simplify writing complex problems. Integrated with all the modern features of functional stuff

If you answered “yes!”, then ActLang might be right for you!
In particular, if you want to work with a large number of independent process unit without sharing state


Advantages Of Functional Programming:
Here are some of the benefits of functional programming that are admired by developers.

  1. Shorter code
  2. Easy debugging
  3. Modular
  4. Parallel programming
  5. Increased maintainability
  6. Code readability

Many functional programming languages are in use today in many industries. Actlang purpose is to make this paradigm easier for distributed computing as a general programming language from students to professionals

🚧 Under Construction! 🚧

ActLang is a young research project and under active development. Here are some of the things we’d like to add / Act (or perhaps continue to learn & explore).

  1. Efficient and simpler way to write multithreaded & non-blocking code.
  2. Most appreciateable features from other programming lanaugaes that help us to write better code
  3. Minimize the compile time, in parallel to show human-readable errors for faster debugging

Publications & Learning More

So far, we are going to publish papers & articles on ActLang to get early feedback