Skip to content

pedrocava/rata-lang

Repository files navigation

Rata

Rata Logo

Rata combines what I love about three languages:

  • Modern, tidyverse R just feels nice to code with.
  • Python is the go-to data engineering language for a reason, it sets a really high bar. I also enjoy some aspects of its syntax.
  • Elixir is a language designed with such good taste, it constrain users in a paradoxically freeing way. There is a real joy in Elixir. The BEAM virtual machine is a natural fit to data engineering workloads because it allows one to easily write fault-tolerant, parallel code.

This is being vibe coded and takes a lot of inspiration from T.

Code Examples

module BirdCount {
  # Get today's bird count (first element)
  today = function(counts: [int]) {
    if Vector.is_empty(counts) {
      return nil
    } else {
      return Vector.first(counts)
    }
  }
  
  # Increment today's count by 1
  increment_day_count = function(counts: [int]) {
    if Vector.is_empty(counts) {
      return 1
    } else {
      today_count = Vector.first(counts)
      rest_counts = Vector.rest(counts)
      return Vector.prepend(rest_counts, today_count + 1)
    }
  }
  
  # Check if any day had zero birds
  has_day_without_birds = function(counts: [int]) {
    Enum.some(counts, ~ .x == 0)
  }
  
  # Calculate total birds across all days
  total = function(counts: [int]) {
    Enum.sum(counts)
  }
  
  # Count busy days (5+ birds)
  busy_days = function(counts: [int]) {
    counts 
      |> Enum.keep(~ .x >= 5)
      |> Vector.length()
  }
}

Fibonacci Sequence

module Math {
  fibonacci = function(n: posint) {
    if n <= 2 {
      return 1
    } else {
      return fibonacci(n-1) + fibonacci(n-2)  
    }
  }
  
  # Generate first 10 fibonacci numbers
  first_10_elements_fib_sequence = 1..10 |>
    Enum.map(fibonacci)
}

Project Status

Rata is still highly experimental and my side-project. Wanna talk about it? Hit me up on twitter X.

Documentation

About

A vibe-coded, functional, R and Python inspired language built with Elixir.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages