Innovative and practical general-purpose multi-paradigm language


The Ring is an innovative and practical general-purpose multi-paradigm language. The supported programming paradigms are imperative, procedural, object-oriented, declarative using nested structures, functional, meta programming and natural programming. The language is portable (Windows, Linux, Mac OS X, Android, etc.) and can be used to create Console, GUI, Web, Games and Mobile applications. The language is designed to be simple, small, flexible and fast.


Date Description
August 30, 2017 Game : TicTacToe 3D!
August 28, 2017 Google API Shortener Application!
August 21, 2017 Ring 1.5 Released!



The language comes with better support for Natural Language Programming and Declarative Programming. The innovation comes in supporting these paradigms with new practical techniques on the top of Object-Oriented Programming and Functional Programming. No need to know anything about (Compilers and Parsing). You get the language constructs ready for use to create domain-specific languages in a fraction of time.

Natural Language Programming Library Natural Language Programming Syntax Flexibility Ring Article


Many of the Ring libraries (StdLib, WebLib, Natural Library, Games Engine, etc.) and the Ring IDE (Ring Notepad, Form Designer, etc.) are written in the Ring language itself. Ring is ready for use in production and increase the developers productivity.

Why Ring?

Why Ring?

The language is simple, trying to be natural, encourage organization and comes with transparent and visual implementation. It comes with compact syntax and a group of features that enable the programmer to create natural interfaces and declarative domain-specific languages in a fraction of time. It is very small, fast and comes with smart garbage collector that puts the memory under the programmer control. It supports many programming paradigms, comes with useful and practical libraries. The language is designed for productivity and developing high quality solutions that can scale. Why?

Designed for a Clear Goal

  • Applications programming language. Examples?
  • Productivity and developing high quality solutions that can scale.
  • Small and fast language that can be embedded in C/C++ projects. How?
  • Simple language that can be used in education and introducing Compiler/VM concepts. How?
  • General-Purpose language that can be used for creating domain-specific libraries, frameworks and tools. How?
  • Practical language designed for creating the next version of the Programming Without Coding Technology software. What?


Ring is a very simple language, and has a very straightforward syntax. It encourages programmers to program without boilerplate code. To print something using the standard output, We can use the 'See' command. Why?

see "Hello, World!" 

The Main function is optional and will be executed after the statements, and is useful for using the local scope. Why?

func main
	see "Hello, World!" 

Uses Dynamic Typing and Lexical scoping. No $ is required before the variable name, but we can use it! Why?
You can use the '+' operator for string concatenation and the language is weakly typed and will do simple implicit conversion between numbers and strings only based on the context. Why?

nCount = 10	# Global variable
func main
	nID = 1	# Local variable
	see "Count = " + nCount + nl + " ID = " + nID

Trying to be natural

Ring is not case-sensitive Why?

see "Enter your name ? " 
give name
see "Hello " + Name	# Name is the same as name 

The list index starts from 1 Why?

aList = ["one","two","three"]
see aList[1]	# print one

Call functions before definition

func one 
	see "One" + nl
func two 
	see "two" + nl
func three 
	see "three" + nl

The assignment operator uses Deep copy (no references in this operation) Why?

aList = ["one","two","three"]
aList2 = aList
aList[1] = 1
see alist[1]	# print 1
see aList2[1]	# print one

Pass numbers and strings by value, but pass lists and objects by reference.
The for in loop can update the list items.

func main
	aList = [1,2,3]
	see aList	# print one two three

func update aList
	for x in aList
		switch x
		on 1 x = "one"
		on 2 x = "two"
		on 3 x = "three"

Using Lists during definition

aList = [ [1,2,3,4,5] , aList[1] , aList[1] ]
see aList       # print 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5

Exit from more than one loop Why?

for x = 1 to 10
        for y = 1 to 10
                see "x=" + x + " y=" + y + nl
                if x = 3 and y = 5
                        exit 2     # exit from 2 loops

Encourage Organization

The language encourage organization, Forget bad days using languages where the programmer start with function then class then function and a strange mix between things!

Each source file follow the next structure

  • Load Files
  • Statements and Global Variables
  • Functions
  • Packages and Classes
This enable us to use Packages, Classes and Functions without the need to use a keyword to end these components.

We can write one line comments and multi-line comments
The comment starts with # or //
Multi-line comments are written between /* and */

	Program Name : My first program using Ring
	Year         : 2017

see "What is your name? " 	# print message on screen
give cName 			# get input from the user
see "Hello " + cName		# say hello!

// See "Bye!"

Compact Syntax

The language is not line sensitive, you don't need to write ; after statements, also you don't need to press ENTER or TAB, so we can write the next code

see "The First Message"	see " Another message in the same line! " + nl
see "Enter your name?" give Name see "Hello " + Name

The next code create a class called Point contains three attributes X,Y and Z. No keywords is used to end the package/class/function definition. Also, we can write the attributes names directly below the class name.

class Point X Y Z

We can use classes and functions before their definition, In this example we will create new object, set the object attributes then print the object values.

o1 = new point	o1.x=10    o1.y=20   o1.z=30	see O1	class Point X Y Z

Instead of using the dot '.' operator to access the object attributes and methods we can use braces { } to access the object, then we can use the object attributes and methods.

o1 = new point { x=10 y=20 z=30 } see O1  class Point X Y Z

Now we will call a method after accessing the object using { }

oPerson = new Person
	Name = "Somebody"
	Address = "Somewhere"
	Phone = "0000000"
	Print()			# here we call the Print() method
class Person Name Address Phone
	func Print
		see "Name :" + name + nl +
		    "Address :" + Address + nl +
		    "Phone : " + phone + nl

When we use { } to access the object then write any attribute name, the language will check the class for any setter/getter methods that will be called automatically.

new Number {
		see one		# Execute GetOne()
		see two		# Execute GetTwo()
		see three	# Execute GetThree()
class Number one two three
	func GetOne
		see "Number : One" + nl
		return 1
	func GetTwo
		see "Number : Two" + nl
		return 2
	func GetThree
		see "Number : Three" + nl
		return 3	

Define Natural Statements based on Object-Oriented


After the object access using { } if the class contains a method called BraceEnd() it will be executed!

TimeForFun = new journey
# The first surprise!
TimeForFun {
	Hello it is me		# What a beatiful programming world!
# Our Class
class journey
	hello=0 it=0 is=0 me=0
	func GetHello
		See "Hello" + nl
	func braceEnd
		See "Goodbye!" + nl	

We can execute code written in strings using the Eval() function

cCode = "See 'Code that will be executed later!' "
Eval(cCode)	# execute the code to print the message

We can create a list then execute code generated from that list

aWords = ["hello","it","is","me"]
for word in aWords cCode=word+"=0" eval(cCode) next

We can read text files using the Read(cFileName) function and we can write files using the Write(cFileName,cString) function.

see "Enter File Name:" give cFileName see read(cFileName) # Print the file content

The next example presents how to create a class that defines two instructions
The first instruction is : I want window
The second instruction is : Window title = Expression
Also keywords that can be ignored like the ‘the’ keyword

new App
        I want window
        The window title = "hello world"

class App

	# Attributes for the instruction I want window
			i want window
			nIwantwindow = 0
	# Attributes for the instruction Window title
	# Here we don't define the window attribute again
			nWindowTitle = 0
	# Keywords to ignore, just give them any value

        func geti
                if nIwantwindow = 0

        func getwant
                if nIwantwindow = 1

        func getwindow
                if nIwantwindow = 2
                        nIwantwindow= 0
                        see "Instruction : I want window" + nl
                if nWindowTitle = 0

        func settitle cValue
                if nWindowTitle = 1
                        see "Instruction : Window Title = " + cValue + nl


To complete the previous example, use read() to get the content of a file that contains

        I want window
        The window title = "hello world"
Then use eval() to execute the content of that file!.
Also, you can update the methods GetWindow() and SetTitle() to create Real windows using the GUI Library

Define Declarative Languages using Nested Structures based on Object-Oriented

We learned how to use Natural statements to execute our code and using the same features we can use nested structures to execute our code.

The next example from the Web library, generate HTML document using the Bootstrap library. No HTML code is written directly in this example, we created a similar language (just as example) Then using this declarative language that uses nested structures, we generated the HTML Document..
The idea in this example is that the GetDiv() and GetH1() methods return an object that we can access using {} and after each object access the method BraceEnd() will be executed to send the generated HTML to the parent object until we reach to the root where BraceEnd() will print the output.

load "weblib.ring"
import System.Web

func Main

          classname = :container
                classname = :jumbotron
                H1 {   text("Bootstrap Page")   }
                classname = :row
                for x = 1 to 3
                        classname = "col-sm-4"
                        H3 { html("Welcome to the Ring programming language") }
                        P  { html("Using a scripting language is very fun!") }

The classes that power the declarative interface looks like this

	class Link from ObjsBase
		title  link
		func braceend			
			cOutput = nl+GetTabs() + "<a href='" + 
				  Link + "'> "+ Title + " </a> " + nl			

	class Div from ObjsBase 
		func braceend
			cOutput += nl+'<div'
			cOutput += nl+"</div>" + nl
			cOutput = TabMLString(cOutput)

Transparent Implementation

Ring comes with transparent implementation. We can know what is happening in each compiler stage and what is going on during the run-time by the Virtual Machine Example : ring helloworld.ring -tokens -rules -ic

see "Hello, World!" 


Tokens - Generated by the Scanner

   Keyword : SEE
   Literal : Hello, World!


Grammar Rules Used by The Parser

Rule : Program --> {Statement}

Line 1
Rule : Factor --> Literal
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> 'See' Expr


Byte Code - Before Execution by the VM

     PC      OPCode        Data

      1     FuncExE
      2       PushC   Hello, World!
      3       Print
      4  ReturnNull


Hello, World!

Visual Implementation

The Ring programming language is designed using the PWCT visual programming tool and you will find the visual source of the language in the folder "visualsrc" - *.ssf files and the generated source code (In the C Language) in the src folder and the include folder. Forke me on GitHub

The next screen shot from the ring_vm.ssf file (Generate ring_vm.c and ring_vm.h)

The next screen shot from the ring_list.ssf file (Generate ring_list.c and ring_list.h)

Smart Garbage Collector

Avoid memory problems :-

  • Invalid Memory Access
  • Memory leaks
  • Uninitialized Memory Access
  • Dangling pointer
Rules :-

  • Global variables always stay in the memory, until you delete these variables using the assignment statement.
  • Local variables always deleted after the end of the function.
  • The programmer have full control on when to delete the variable from the memory using the Assignment statement.

  • Example:
    aList = [1,2,3,4,5]
    aList = "nice"
    After the second line directly, The list [1,2,3,4,5] will be deleted from the memory and we will have a string "nice"

  • The programmer can call the function callgc() to force running the garbage collector.
  • If we have a reference to a variable (when we pass objects and lists to functions), then deleting variables will be based on reference counting, if no references everything will be deleted, but if we have a reference, the data will stay in memory.


Free and Innovative
  • Free Open Source (MIT License)
  • Declarative programming on the top of Object-Oriented programming
  • No explicit end for statements (No ; or ENTER is required)
  • For in get item by reference not value, you can read/edit the item
  • Use exit to go outside from more than one loop
  • No keyword to end Functions, Classes and Packages
  • using { } to access objects and use attributes/methods as variables/functions
  • Clear program structure (Statements then functions then packages & classes)
  • Optional Printing for Tokens/Grammar/Byte-Code during execution
Powerful Implementation
  • Hybrid Implementation (Compiler+VM)
  • The compiler + The Virtual Machine are 15,000 lines of C code
  • The other 500,000 lines of code are related to libraries!
  • Written in ANSI C (The code is generated)
  • Developed using Visual Programming (PWCT)
  • Portable (Windows, Linux & Mac OS X, Android, etc.)
  • Comments (One line & Multi-line)
  • Not Case-Sensitive
  • Structure Programming
  • Rich control structures & Operators
  • Procedures/Functions
  • Main Function (optional)
  • Call Function before the definition
  • Recursion
  • Multi-line literals
  • Access (read/write) string letter by index
  • The list index start from 1
  • Range operator ex: 1:10
  • First Class Variables, Lists, Objects and Functions
  • Store/Copy Lists/Objects by value (Deep Copy)
  • Pass Lists/Objects by reference
  • 8-bit clean, work on binary data directly

  • Dynamic Typing
  • Weakly typed
  • Lexical Scoping (Global, Local & Object State)
  • Default scope for variables inside functions (Local)
  • Default scope for variables outside functions (global)
  • Garbage Collector - Automatic Memory Management (Escape Analysis and Reference Counting)
  • Exception Handling
  • Eval() to execute code during run-time
Native Object-Oriented Support
  • Encapsulation
  • Setter/Getter (optional)
  • private state (optional)
  • Instantiation
  • Polymorphism
  • Composition
  • Inheritance (Single Inheritance)
  • Operator Overloading
  • Packages
  • Reflection and Meta-programming
Standard Library
  • I/O commands
  • Math functions
  • String functions
  • List functions
  • File processing functions
  • Database support (ODBC & MySQL)
  • Security Functions (OpenSSL)
  • Internet Functions (LibCurl)

CGI Library (Written in Ring)
  • CGI LIbrary - HTTP Get
  • CGI LIbrary - HTTP Post
  • CGI LIbrary - File upload
  • CGI LIbrary - Cookies
  • CGI LIbrary - URL Encode
  • CGI LIbrary - Templates
  • CGI LIbrary - HTML Special Characters
  • CGI LIbrary - HTML Generation using Functions
  • CGI LIbrary - HTML Generation using Classes
  • CGI LIbrary - CRUD Example (using MVC)
  • CGI Library - Users Example (Register, Login and Check)
  • Extension using C/C++ (Simple API)
  • Embedding the language in C/C++ programs
  • Comes with code generator (Written in Ring) to quickly wrap C/C++ Libraries
  • Create 2D Games (Using the Allegro Library)
  • Create GUI Applications for Desktop and Mobile (Using the Qt Framework)
  • Very Stable
  • Good Performance
  • Complete Documentation
Ring in Wikibooks Ring Samples (Rosettacode)

Group Resources Team