Actor Beam Community
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
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!
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
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] {
...
}
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.
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).
So far, we are going to publish papers & articles on ActLang to get early feedback