Skip to content

Repository files navigation

The Radon Programming Language

A general-purpose programming language, focused on simplicity, safety and stability.

WebsiteDocumentationTestsExamples

GitHub Workflow Status GitHub license Hits Discord

Radon is a dynamically-typed, general-purpose programming language designed to be easy to learn and use, with a syntax that will feel familiar if you already know Python, JavaScript, or C-family languages. It's under active development, with a growing feature set that already includes:

  • Object-oriented programming — classes, single/multiple/multilevel/hybrid inheritance with super(), enforced public/private/protected access modifiers, abstract classes, and operator overloading via magic methods
  • async/await with real concurrency through spawn()/sleep()/gather()
  • Closures, error handling (try/catch/raise), modules and from ... import ..., and a growing Radon standard library
  • A Python interop bridge (pyapi()) for calling into and from Python code
  • A REPL with live syntax highlighting, and a CI-gated test suite covering the language itself

See the documentation for the full language guide.

Installation

git clone https://github.com/radon-project/radon.git
cd radon

# To run the repl
python radon.py

# To run a .rn file
python radon.py <filename>

Read the documentation to learn more about the language.

Quick Start

Here's a login program that asks for a username and password and checks them against an authenticator. It's a small example, but it touches most of what Radon's OOP and async/await support look like in practice: an abstract base class defining the contract, inheritance, private/protected access modifiers, and an async login flow that awaits a (simulated) network call.

import io

abstract class Authenticator {
    fun authenticate(username, password) # abstract -- every concrete subclass must implement this

    protected fun log_attempt(username) -> print("Login attempt: " + username)
}

class Network(Authenticator) {
    fun __constructor__(username, password) {
        this.username = username
        this.password = password
    }

    private fun check_credentials(username, password) -> username == "radon" and password == "password"

    async fun authenticate(username, password) {
        this.log_attempt(username)  # protected method, inherited from Authenticator
        await sleep(0.1)  # e.g. standing in for a network/database round trip

        # private method, only callable from within Network
        return this.check_credentials(username, password)
    }

    async fun login() {
        if await this.authenticate(this.username, this.password) {
            print("Log in successful")
        } else {
            print("Invalid credentials")
        }
    }
}

var username = input("Enter your username: ")
# Access password securely using get_password
var password = io.Input.get_password("Enter your password: ")

var network = Network(username, password)
await network.login()

See the classes guide and async and concurrency guide for more.

Contributing

We need contributors to help us build the language. If you are interested, please make contributions to the radon-project/radon repository.

Steps to contribute:

  1. Fork the repository
  2. Clone the repository
  3. Create a new branch
  4. Make changes
  5. Commit changes
  6. Push to the branch
  7. Create a pull request

Before making a pull request create an issue and discuss the changes you want to make. If you have any questions, feel free to ask in the issues section.

Every pull request is checked by CI, so before pushing, run the same checks locally:

python -m pip install -r requirements-dev.txt

python test.py full   # runs the test suite, mypy --strict, and ruff
# or, equivalently:
make test

Individual pieces, if you'd rather run them separately:

make lint       # ruff format --check . && ruff check .
make typecheck  # mypy . --strict
python test.py run tests/lang/<file>.rn   # a single test file

You can also join our Discord server to discuss the language and get help.

License

We are using GNU General Public License v3.0. You can check the license here.

Releases

Packages

Used by

Contributors

Languages