Ring (programming language)

Ring (programming language)
Ring is a dynamically typed, general-purpose programming language. It can be embedded in C/C++ projects, extended using C/C++ code and/or used as a standalone language. The supported programming paradigms are imperative, procedural, object-oriented, functional, meta, declarative using nested structures, and natural programming. The language is portable (Windows, Linux, macOS, Android, WebAssembly, etc.) and can be used to create console, GUI, web, game and mobile applications.
History
In 2009, Mahmoud Samir Fayed created a minor domain-specific language called Supernova that focuses on User interface (UI) creation and uses some ideas related to Natural Language Programming, then he realized the need for a new language that is general-purpose and can increase the productivity of natural language creation. Ring aims to offer a language focused on helping the developer with building natural interfaces and declarative DSLs.
Goals
The general goals behind Ring:
Applications programming language.
Productivity and developing high quality solutions that can scale.
Small and flexible 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.
Examples
Hello World program
The same program can be written using different styles. Here is an example of the standard "Hello, World!" program using four different styles.
The first style:
see "Hello, World!"
The second style:
put "Hello, World!"
The third style:
load "stdlib.ring"
print("Hello, World!")
Another style: similar to xBase languages like Clipper and Visual FoxPro
? "Hello, World!"
Change the Keywords and Operators
Ring supports changing the language keywords and operators.
This could be done many times in the same source file, and is useful for
Translating the keywords from English to other human languages (Non-English-based programming languages)
Customizing the language for use of a favorite style
Porting Legacy code written in other languages
Translate Ring keywords to Japanese
ChangeRingKeyword See 手紙を出す
ChangeRingOperator + そして
改行 = nl
します。 = :します。
手紙を出す "こんにちは、世界" そして 改行 します。
ChangeRingKeyword 手紙を出す See // キーワードの復旧
ChangeRingOperator そして + // 演算子の復旧
Translate Ring keywords to Arabic
ChangeRingKeyword See إطبع
إطبع "Hello, World!"
ChangeRingKeyword إطبع See
Use style similar to the Pascal programming language
ChangeRingKeyword func function
ChangeRingKeyword see write
begin = :begin
function main
begin
write("Hello, World!");
return 0;
end
ChangeRingKeyword function func
ChangeRingKeyword write see
Loop Command
The Loop command can take an integer to apply the continue semantics to enclosing outer loops
changeRingKeyword loop continue
count = 2
for x in 1:5
for y = 1 to 2
if x = 3
? "About to execute 'loop', count = " + count
continue count
ok
? "x: " + x + ", y: " + y
next
next
Object Oriented Programming
Ring supports Object Oriented Programming (Classes, Objects, Composition, Inheritance, Encapsulation, etc.)
new point { # Create new object from the Point class the access the object using braces
x=10 y=20 z=30 # Set the object attributes
print() # Call the print() method
} # end of object access using braces
class point # Define the class
x y z # Define the attributes (x,y,z)
func print # Define the print() method
? x + nl + y + nl + z # Print the attributes values (nl means printing a new line)
In Ring classes can be defined at runtime using the Eval() function
? "Creating a new class dynamically..."
eval("class DynamicClass a b")
? "Printing the instance..."
? new DynamicClass {a=1 b=2}
Implementation
Compiler and Virtual Machine
Ring programs are not interpreted directly from the textual Ring file, but are compiled into bytecode, which is then run on the Ring virtual machine. The compilation process is typically invisible to the user and is performed at run-time, but it can be done offline in order to increase loading performance or reduce the memory footprint of the host environment by leaving out the compiler.
The Compiler and the Virtual Machine are designed using Visual Programming through the Programming Without Coding Technology software then the C code is generated.
Extensions
The following are extensions that can be used immediately after the installation of the full installation version (with a file size of about 280 MB for Ring 1.12). Since these are officially provided and maintained on the Ring side, the users are not bothered by library dependencies that may cause problems in other languages, and there is a concern that they can not be used suddenly even if there are destructive language specification changes.
The extensions are implemented in approximately 500,000 lines of C and C++ code.
RingAllegro (Allegro Game Library)
RingConsoleColor (Text coloring library for command prompt or the terminal)
RingCurl (CURL Library)
RingFreeGLUT (FreeGLUT)
RingInternet (Internet related library)
RingLibUV (LibUV-asynchronous I / O library)
RingMurMurHash (Hash Function Library)
RingMySQL (MySQL)
RingODBC (Open Database Connectivity)
RingOpenGL (OpenGL 1.1-4.6)
RingOpenSSL (OpenSSL)
RingPostgreSQL (PostgreSQL)
RingQt (Qt framework)
RingRayLib (raylib)
RingSDL (SDL-Simple DirectMedia Layer Library)
RingSQLite (SQLite)
RingWinAPI (Windows API)
RingWinCREG (Windows Registry)
RingZIP (zip file processing library)
Libraries
Ring comes with libraries written in Ring itself, such as libraries related to web and game development.
Applications
Ring is distributed with over 60 applications written in the language.
Some of these applications are
Analog Clock application
Calculator application
The Checkers Game
The Chess Game
Fifteen Puzzle 3D Game
Game 2048
Knight Tour Game
Minesweeper Game
Othello Game
Sokoban Game
Sudoku Game
Tic-tac-toe 3D Game
Video Music Player application
Windows Startup Manager application
Tools
Ring is distributed with a Standard IDE that includes the following tools:
Ring REPL (Read–eval–print loop)
Ring2EXE (Distributing executable applications)
RingPM (The Ring Package manager)
Ring Notepad (Source-code editor)
Form Designer (WYSIWYG GUI designer)
Ring is also distributed with extensions for many code editors such as Emacs, Notepad++, Geany, Atom, Sublime Text 2, and Visual Studio Code.
Documentation
Ring is distributed with documentation written using Sphinx. A Japanese translation of the documentation is also available.
Reception
Popularity
Ring had a rapid rise and fall in popularity as measured by the TIOBE Programming Community Index. In February 2018, Ring broke into the top 50 for the first time (position 45). As of October 2020, Ring holds position 93 on the TIOBE index. Ring is listed by GitHub in the list of programming languages that are actively developed.
Criticism
Ring critics pointed to some features in Ring that are not common in widely used programming languages.
The list index starts from 1 instead of 0 (See: Zero-based numbering)
Implicit type conversions (See: Implicit type conversions and "type punning")
The list index starts from 1 instead of 0
In Ring, the index of the first item in lists and the first character in strings is 1.
cName = "Ring"
? cName[1] # print R
aList = ["One","Two","Three"]
? aList[1] # print One
Implicit type conversions
The language can automatically convert between numbers and strings.
/*
** Rules:
** <NUMBER> + <STRING> --> <NUMBER>
** <STRING> + <NUMBER> --> <STRING>
*/
x = 10 # x is a number
y = "20" # y is a string
nSum = x + y # nSum is a number (y will be converted to a number)
cMsg = "Sum = " + nSum # cMsg is a string (nSum will be converted to a string)
See also
Tcl
Lua
Python
Ruby
Squirrel
Gambas
References
Further reading
Ghanem (2021) Developing Poet Software using Ring language (Arabic Book), MetaBook (Egypt - Mansoura)
Ayouni (2020) Beginning Ring Programming, Apress (part of Springer Nature)
Hassouna (2019) Ring Basics (Arabic Book), Hassouna Academy
Sobain (2017) RingWinCReg Extension Documentation, SourceForge
Fayed (2016) The Ring Programming Language, CodeProject
External links
Ring home page
RosettaCode samples
Ring Documentation (Japanese)
Online Form Designer (WebAssembly)
Programming languages
Cross-platform free software
Programming languages created in 2016
High-level programming languages
2016 software
Dynamically typed programming languages
Egyptian inventions
Free software projects
Software using the MIT license
Free software programmed in C
Multi-paradigm programming languages
Extensible syntax programming languages