Click here to Skip to main content
15,940,550 members
Articles / Web Development / HTML

The Ring Programming Language

Rate me:
Please Sign up or sign in to vote.
4.72/5 (29 votes)
6 Sep 2016CPOL13 min read 89.3K   985   29   35
Free Open Source Innovative and practical general-purpose multi-paradigm Scripting language developed using C/C++


I'm interested in programming languages design and implementation and the Ring programming language (general-purpose multi-paradigm language released on January 25th, 2016) is my third project in this domain after Programming Without Coding Technology (2005-2015) and Supernova programming language (2009-2010).

In this article, I will try to introduce the language, why it's designed! and what you can do using it.

From the beginning, remember that this is an open source project that you can get, use and modify for free (MIT License). If you want to contribute or get the source code, just check the project source code (GitHub) and the language website for more resources like (documentation and support group).

Also, you can download Ring 1.0 for Windows (Binary Release) or Ring 1.0 for Ubuntu Linux (Binary Release).

Also we have Ring 1.0 for Mac OS X (Binary Release) and Ring 1.0 for Mobile App Development using Qt


In November, 2011, I started to think about creating a new version of the Programming Without Coding Technology (PWCT) software from scratch. I was interested in creating multi-platform edition of the software beside adding support for Web & Mobile development. Most of the PWCT source code was written in VFP (Microsoft Visual FoxPro 9.0 SP2) and the software comes with a simple scripting language for creating the components called (RPWI). The software contains components that support code generation in programming languages like Harbour, C, Supernova & Python.

What I was looking for is a programming language that can be used to build the development environment, provides multi-platform support, more productivity, better performance, can be used for components scripting & can be used for developing different kinds of applications. Instead of using a mix of programming languages, I decided to use one programming language for creating the development environment, for components scripting & for creating the applications.

I looked at many programming languages like C, C++, Java, C#, Lua, PHP, Python & Ruby. I avoided using C or C++ directly because I want high-level of productivity more than the level provided by these languages, also a language behind visual programming environment for novice programmers or professionals must be easy to use & productive. Java & C# are avoided for some reason too! I wanted to use a dynamic programming language and these languages are static typing, Java is multi-platform, also C# through Mono, but the use of huge number of classes and forcing the use of Object-Orientation, using a verbose language is not right for me. I need a small language, but fast and productive, also I need better control on the Garbage Collector (GC), I need a better one that is designed for fast applications.

Lua is small and fast, but it’s avoided because I need more powerful language for large applications. PHP is a Web programming language and it’s syntax is very similar to C, this leads to a language not general as I want and not simple as I need to have. Python & Ruby are more like what I need, but I need something more simple, smaller, faster & productive. Python and Ruby are Case-Sensitive, the list index start counting from 0, you have to define the function before calling it, Ruby usage of Object-Orientation and message passing is more than what I need and decrease performance, Python syntax (indentation, using self, :, pass & _) is not good for my goals.

All of these languages are successful languages, and very good for their domains, but what I need is a different language that comes with new ideas and intelligent implementation (Innovative, Ready, Simple, Small, Flexible and Fast).

The Ring is an Innovative and practical general-purpose multi-paradigm scripting language that can be embedded in C/C++ projects, extended using C/C++ code and/or used as standalone language. The supported programming paradigms are Imperative, Procedural, Object-Oriented, Functional, Meta programming, Declarative programming using nested structures, 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. Its Dynamic Language (Dynamic Typing and Weakly Typed) that compile the source code to byte code then execute it by the Ring Virtual Machine, which is integrated with the Ring Compiler in one program. The first version of the language (around 100,000 lines of C/C++/Ring code) is released on January 25th, 2016

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.

The language is designed for a clear goal:

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

Using the Code

I have 10 samples to introduce, you can run all of these samples using the online version provided by the Ring website.

Sure I will start with the hello world program!

See "Hello, World!"

The Ring uses (See) and (Give) for printing output and getting input from the user.

The language uses special keywords (different from other languages). These special words selected to be (small and fast to write and still with clear meaning). Anyway, if you are going to add the language to your project, you can hack the source code and modify anything!

This from the beginning demonstrates that Ring is not a clone from any other language but sure the language borrows some ideas from other languages like C,C++, C#, Java, PHP, Python, Ruby, Lua, Basic, Supernova and Harbour. Also the language coms with new ideas specially for abstraction and creating natural and declarative interfaces to be used as domain-specific languages. Also, the language implementation (transparent and visual) helps in using it in Compiler courses. Being a multiparadigm language that is fast and written in ANSI C also provides a good chance for embedding the language in C/C++ projects.

The language is not case sensitive, you can write "SEE", "see" or "See".

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

The Ring Uses Dynamic Typing and Lexical scoping. No $ is required before the variable name!
You can use the '+' operator for string concatenation and the language is weakly typed and will convert automatically between numbers and strings based on the context.

The list index starts from 1. You can call functions before definition. The assignment operator uses Deep copy (no references in this operation). You can pass numbers and strings by value, but pass lists and objects by reference.
The for in loop can update the list items. We can use Lists during definition as in the next example.

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

We can easily exit from more than one loop.

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

The language encourages organization, forget bad days using languages where the programmer starts with function then class then function and a strange mix between things! Each source file follows the next structure:

  • Load Files
  • Statements and Global Variables
  • Functions
  • Packages and Classes

This enables 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 */.

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

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!

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. Fork me on GitHub.

The next screen shot demonstrates what I mean by visual implementation:

Image 1

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

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

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.

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.

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

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

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, generates 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)

Embedding the Ring Programming Language in C/C++ Projects

We can use the Ring language from C/C++ programs using the next functions:

RingState *ring_state_init();
ring_state_runcode(RingState *pState,const char *cCode);
ring_state_delete(RingState *pState);

The idea is to use the ring_state_init() to create new state for the Ring Interpreter, then call the ring_state_runcode() function to execute Ring code using the same state. When we are done, we call the ring_state_delete() to free the memory.

#include "ring.h"
#include "stdlib.h"
int main(int argc, char *argv[])
  RingState *pState = ring_state_init();
  ring_state_runcode(pState,"see 'hello world from the ring programming language'+nl");

Sure the previous sample can't be tested using the online version of the language where you will need a C compiler + the Ring language header files and library (that you can build from the source code)

The Ring API comes with the next functions to create and delete the state. Also we have functions to create new variables and get variables values.

RingState * ring_state_init ( void ) ;
RingState * ring_state_delete ( RingState *pRingState ) ;
void ring_state_runcode ( RingState *pRingState,const char *cStr ) ;
List * ring_state_findvar ( RingState *pRingState,const char *cStr ) ;
List * ring_state_newvar ( RingState *pRingState,const char *cStr ) ;
void ring_state_main ( int argc, char *argv[] ) ;
void ring_state_runfile ( RingState *pRingState,const char *cFileName ) ;

We can create more than one ring state in the same program and we can create and modify variable values.

To get the variable list, we can use the ring_state_findvar() function.

To create new variable, we can use the ring_state_newvar() function.


#include "ring.h"
#include "stdlib.h"

int main(int argc, char *argv[])
  List *pList;

  RingState *pState = ring_state_init();
  RingState *pState2 = ring_state_init();

  (pState,"see 'hello world from the ring programming language'+nl");

  printf("Again from C we will call ring code\n");
  ring_state_runcode(pState,"for x = 1 to 10 see x + nl next");

  ring_state_runcode(pState2,"for x = 1 to 5 see x + nl next");

  printf("Now we will display the x variable value from ring code\n");
  ring_state_runcode(pState,"see 'x value : ' + x + nl ");
  ring_state_runcode(pState2,"see 'x value : ' + x + nl ");

  pList = ring_state_findvar(pState,"x");

  printf("Printing Ring variable value from C , %.0f\n",

  printf("now we will set the ring variable value from C\n");

  ring_state_runcode(pState,"see 'x value after update : ' + x + nl ");

  pList = ring_state_newvar(pState,"v1");

  pList = ring_state_newvar(pState,"v2");

  ring_state_runcode(pState,"see 'v1 + v2 = ' see v1+v2 see nl");

  ring_state_runcode(pState,"see 'end of test' + nl");



hello world from the ring programming language
Again from C we will call ring code
Now we will display the x variable value from ring code
x value : 11
x value : 6
Printing Ring variable value from C , 11
now we will set the ring variable value from C
x value after update : 20
v1 + v2 = 30
end of test

Ring VM Extension using C/C++ Code

We can extend the Ring Virtual Machine (RingVM) by adding new functions written in the C programming language or C++. The RingVM comes with many functions written in C that we can call like any Ring function.

We can extend the language by writing new functions then rebuilding the RingVM again, or we can create shared library (DLL/So) file to extend the RingVM without the need to rebuild it.

Each module function may contain the next steps:

  1. Check Parameters Count
  2. Check Parameters Type
  3. Get Parameters Values
  4. Code/Call Functions
  5. Return Value

The structure is very similar to any function (Input - Process - Output). But here, we will use the Ring API for the steps 1, 2, 3 and 5.

The next code represents the sin() function implementation using the Ring API and the sin() C function.

void ring_vm_math_sin ( void *pPointer )
        if ( RING_API_PARACOUNT != 1 ) {
                return ;
        if ( RING_API_ISNUMBER(1) ) {
        } else {

You can read more about extension from this tutorial.

Also, you can use a code generator that comes with Ring to quickly generate wrappers for C/C++ functions/classes.

Editors Support

You can use the language with any editor, also the Ring team provides extensions for Notepad++, SubLime Text 2, Geany Editor, Visual Studio and Atom editor.

The next screen shot demonstrates using Ring in SubLime Text 2.

Image 2

The next screen shot demonstrates using Ring in Atom (my favorite code editor).

Image 3

Graphics and 2D Games Programming using RingAllegro

You can learn about using the Allegro game programming library from the Ring language through this tutorial.

The next example displays and rotates an image:

Load "gamelib.ring"


display = al_create_display(640,480)

image = al_load_bitmap("man2.jpg")



The next screen shot demonstrates the application during the runtime:

Image 4

Web Development

For now, the Ring programming language comes with a simple CGI Library for creating web applications.

Hello World program:

#!b:\ring\ring.exe -cgi

Load "weblib.ring"

Import System.Web

        Text("Hello World!")

The library is written in Ring (around 5K lines of code).

The next screen shot demonstrates the power of the library that uses Object-Oriented Programming and the MVC design pattern.

Image 5

You can read more about the library from this tutorial.

Desktop and Mobile Applications (Using RingQt)

The next example asks the user about his/her name, then says Hello!

Load "guilib.ring"

MyApp = New qApp {

        win1 = new qWidget() {

                setwindowtitle("Hello World")
                label1 = new qLabel(win1) {
                        settext("What is your name ?")
                btn1 = new qpushbutton(win1) {
                        settext("Say Hello")
                btn2 = new qpushbutton(win1) {
                lineedit1 = new qlineedit(win1) {
                layout1 = new qVBoxLayout() {


Func pHello
        lineedit1.settext( "Hello " + lineedit1.text())

Func pClose

The next screen shot demonstrates the application during the runtime.

Image 6

You can read more about GUI development using Ring from this tutorial.

The tutorial comes with many samples including a simple Cards game developed using RingQt where each player get 5 cards, the cards are unknown to any one. Each time one player clicks on one card to see it, if the card is identical to another card, the play gets points for each card. If the card value is “5”, the player get points for all visible cards.

Image 7

The next screen shot while running the game using a Mobile (Android):

Image 8

Points of Interest

The Ring is a multi-paradigm language that will give you the choice to select the right paradigm for your problem.

Try the language (It's FREE OPEN SOURCE), then think about creating new projects (frameworks) based on the language power (declarative programming and natural programming) and I'm sure that you will get success.

We need contributors so feel free to join and help us (improve our code, add features, report bugs, fix some bugs!, write libraries, provide extensions, write documentation, etc.)


  • January 25, 2016: Ring 1.0 released!
  • September, 2015: Most of the documentation was written!
  • August, 2015: Most of the testing was done!
  • May, 2015: Most of the work in the compiler and The Virtual Machine was done!
  • April, 2015: The language name: Ring
  • September, 2013: The design and the implementation of the language started!
  • November, 2011: The ideas and the general goals behind the new programming language


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Egypt Egypt
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

Questionexample from book do not work Pin
john blackfield20-Jul-21 14:18
john blackfield20-Jul-21 14:18 
AnswerRe: example from book do not work Pin
Mahmoud Samir Fayed22-Jul-21 5:11
Mahmoud Samir Fayed22-Jul-21 5:11 
SuggestionRing and C# Pin
martin.nedopil2-May-18 23:57
martin.nedopil2-May-18 23:57 
GeneralRe: Ring and C# Pin
Mahmoud Samir Fayed18-May-18 7:25
Mahmoud Samir Fayed18-May-18 7:25 
GeneralMy vote of 5 Pin
Rubin Liu12-Mar-18 11:45
Rubin Liu12-Mar-18 11:45 
GeneralRe: My vote of 5 Pin
Mahmoud Samir Fayed18-May-18 7:26
Mahmoud Samir Fayed18-May-18 7:26 
QuestionOne Suggestion Pin
Rick York4-May-17 6:12
mveRick York4-May-17 6:12 
AnswerRe: One Suggestion Pin
Mahmoud Samir Fayed4-May-17 15:39
Mahmoud Samir Fayed4-May-17 15:39 
QuestionLoop exiting Pin
leon de boer2-Mar-17 21:05
leon de boer2-Mar-17 21:05 
AnswerRe: Loop exiting Pin
Mahmoud Samir Fayed2-Mar-17 22:29
Mahmoud Samir Fayed2-Mar-17 22:29 
GeneralRe: Loop exiting Pin
leon de boer2-Mar-17 23:37
leon de boer2-Mar-17 23:37 
GeneralRe: Loop exiting Pin
Mahmoud Samir Fayed2-Mar-17 23:44
Mahmoud Samir Fayed2-Mar-17 23:44 
Generalmy vote of 5 Pin
Southmountain25-Feb-17 5:22
Southmountain25-Feb-17 5:22 
GeneralRe: my vote of 5 Pin
Mahmoud Samir Fayed25-Feb-17 9:01
Mahmoud Samir Fayed25-Feb-17 9:01 
QuestionMentioned relation between VFP (sp2) and Ring Pin
Frank Kropp26-Nov-16 1:12
Frank Kropp26-Nov-16 1:12 
AnswerRe: Mentioned relation between VFP (sp2) and Ring Pin
Mahmoud Samir Fayed29-Nov-16 5:09
Mahmoud Samir Fayed29-Nov-16 5:09 
GeneralRe: Mentioned relation between VFP (sp2) and Ring Pin
RugbyLeague17-Jan-18 4:14
RugbyLeague17-Jan-18 4:14 
GeneralRe: Mentioned relation between VFP (sp2) and Ring Pin
Mahmoud Samir Fayed26-Feb-18 16:00
Mahmoud Samir Fayed26-Feb-18 16:00 
GeneralMy vote of 5 Pin
Mr. Tamer Radwan 15-Oct-16 22:16
Mr. Tamer Radwan 15-Oct-16 22:16 
GeneralRe: My vote of 5 Pin
Mahmoud Samir Fayed16-Oct-16 21:57
Mahmoud Samir Fayed16-Oct-16 21:57 
QuestionBad verbs Pin
David O'Neil8-Sep-16 6:31
professionalDavid O'Neil8-Sep-16 6:31 
AnswerRe: Bad verbs Pin
Mahmoud Samir Fayed8-Sep-16 14:57
Mahmoud Samir Fayed8-Sep-16 14:57 
GeneralRe: Bad verbs Pin
Bhudda8-Sep-16 19:38
Bhudda8-Sep-16 19:38 
GeneralRe: Bad verbs Pin
Mahmoud Samir Fayed8-Sep-16 21:20
Mahmoud Samir Fayed8-Sep-16 21:20 
GeneralRe: Bad verbs Pin
David O'Neil8-Sep-16 18:21
professionalDavid O'Neil8-Sep-16 18:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.