Skip to content

A dynamic general-purpose high-level functional-programming language with familiar syntax that compiles to native binaries.

License

Notifications You must be signed in to change notification settings

divs1210/rudralang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

!!EXPERIMENTAL!!

rudralang

A dynamic general-purpose high-level functional-programming language with familiar syntax that compiles to native binaries.

Code Examples

Implementation of the Ackermann function:

ns!(ackermann,
  {} =>

  letfn A := [m, n] =>
    cond(
      zero?(m) => inc(n)
      zero?(n) => A(dec(m), 1)
      :else    => A(dec(m), A(m, dec(n)))
    )

  defn!(main!, {}, [_, m, n] =>
    let [m, n] := map(string->number, [m, n])
    println!("A(" m ", " n ") = " A(m, n))
  )
)

Check out other sample programs.

Goals

  • Ergonomic familiar syntax, destructuring everywhere
  • Extensible top-level functions are polymorphic by default
  • Immutable data structures by default
  • Concurrency-friendly mutability using Clojure-like atoms
  • Full numeric tower example: no integer overflows, pow(-1, 0.5) is 0+i
  • Recursion-friendly many algorithms are simpler when defined recursively - they should be written as such

Notes on this implementation

This repo contains a compiler written in Clojure.

It compiles Rudra source to Chez Scheme, and then to a native binary via chez-exe.

Installation

Install Leiningen

Leiningen

Clone this repo

$ git clone git@github.com:divs1210/rudralang.git

Install Chez Scheme

Mac

$ brew install chezscheme

Others

There are compiled binaries available for all major platforms, otherwise build it yourself from source.

Install chez-exe

It's really easy to build from source.

Usage

Go to the rudralang repo

$ cd path/to/rudralang

Configure

Update config.edn to point to the correct chez-exe path.

Compile a sample program

$ lein -compile samples/fact.rudra

Run it

$ target/fact 5

REPL

In the rudralang directory, run:

$ ./repl

License

Copyright © 2021 Divyansh Prakash

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.

About

A dynamic general-purpose high-level functional-programming language with familiar syntax that compiles to native binaries.

Topics

Resources

License

Stars

Watchers

Forks