Site Logo

The Radon Programming Language

Radon is a programming language that is designed to be easy to learn and use. It is a high-level language intended to be used for general purpose programming. It is designed to be easy to learn and use, while still being powerful enough to be used for most tasks. Some of the features of Radon include:

Download

Download the latest version of Radon

Release version Release date Platform Click for more
Radon 0.0.1a2 31-08-2023 Windows | Linux/Source Release Notes
Radon 0.0.1a0 05-07-2023 Windows | Linux/Source Release Notes

Getting Started

After downloading Radon, you can run it by double clicking on the executable. This will open the Radon REPL (Read Evaluate Print Loop). You can type in code and it will be executed immediately. You can also run a Radon file by typing radon filename.rn in the command line. This will run the code in the file. Before you do that though, you need to make sure that Radon is in your PATH variable. If you are on Windows, you can do this by going to Control Panel > System > Advanced System Settings > Environment Variables. Then, you need to add the path to the Radon executable to the PATH variable. If you are on Linux, you can do this by adding the path to the Radon executable to the PATH variable in your .bashrc file.

Standard Library

We are currently working on the standard library. We need contributors to help us build the standard library. If you are interested, please make contributions to the stdlib directory.

Project Structure

radon
├── core
│   ├── builtin_funcs.py
│   ├── datatypes.py
│   ├── errors.py
│   ├── __init__.py
│   ├── interpreter.py
│   ├── lexer.py
│   ├── nodes.py
│   ├── parser.py
│   └── tokens.py
├── examples
│   ├── args_test.rn
│   ├── arrays.rn
│   ├── classes.rn
│   ├── functions.rn
│   ├── import_test.rn
│   ├── new_syntax.rn
│   ├── python_api.rn
│   ├── simple.rn
│   └── syntax.rn
├── Makefile
├── radon.png
├── radon.py
├── README.md
├── stdlib
│   ├── Argparser.rn
│   ├── Array.rn
│   ├── Math.rn
│   ├── String.rn
│   ├── System.rn
│   └── Winlib.rn
├── tests
└── TODO.md
        

Syntax

# This is a comment

# Arithmetic operators
# + - Addition
# - - Subtraction
# * - Multiplication
# / - Division
# % - Modulus
# ^ - Exponentiation

# Comparison operators
# == - Equal to
# != - Not equal to
# > - Greater than
# < - Less than
# >= - Greater than or equal to
# <= - Less than or equal to

# Logical operators
# and - Logical and
# or - Logical or
# not - Logical not

# Assignment operators (Development)
# = - Assign
# += - Add and assign
# -= - Subtract and assign
# *= - Multiply and assign
# /= - Divide and assign
# %= - Modulus and assign
# ^= - Exponentiation and assign

# Variable definition
var a = 10
var b = 20
print(a + b) # 30

var c = "Hello"
var d = "World"
print(c + " " + d) # Hello World

# Conditional statement
if a > b {
    print("a is greater than b")
} elif a < b {
    print("a is less than b")
} else {
    print("a is equal to b")
}

# For loop
var x = 9 # Multiplication table of 9

for i = 1 to 11 {
    print(str(x) + " X " + str(i) + " = " + str(x * i))
}

# While loop
while x > 0 {
    print(x)
    var x = x - 1
}

# Function definition
fun add(a, b) {
    return a + b
}

print(add(10, 20)) # 30

# Anonymous function
var sub = fun (a, b) {
    return a - b
}

print(sub(20, 10)) # 10

# Single line function
fun mul(a, b) -> a * b
print(mul(10, 20)) # 200

# Class definition
class Person {
    # Constructor
    fun Person(name, age) {
        var this.name = name
        var this.age = age
    }

    fun get_name() {
        return this.name
    }

    fun get_age() {
        return this.age
    }
}

# Use a class
var person = Person("Almas", 21)
var details = "Name is : " + person.get_name() + ", Age : " + str(person.get_age())
print(details)

# Include statement
include Math # to include math library
include "examples/simple.rn" # to use a path

# builtin functions

# Utility methods
cls()
clear()
exit()

# same as include statement
require()

# Command line arguments
sys_args()

# API methods
pyapi(string)

# Typecase methods
int()
float()
str()
bool()
type()

# Type checker methods
is_num()
is_int()
is_float()
is_str()
is_bool()
is_array()
is_fun()

# String methods
str_len()
str_find(string, index)
str_slice(string, start, end)

# I/O methods
print()
print_ret()
input()
input_int()

# Array methods
arr_len()
arr_push(array, item)
arr_pop(array, index)
arr_append(array, item)
arr_extend(array1, array2)
arr_find(array, index)
arr_slice(array, start, end)