Ring (programming language)

Dynamically typed, general-purpose programming language From Wikipedia, the free encyclopedia

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 or used as a standalone language.[5] The supported programming paradigms are imperative, procedural, object-oriented, functional, meta, declarative using nested structures, and natural programming.[6][7] The language is portable (Windows, Linux, macOS, Android,[8] WebAssembly,[9] etc.)[10] and can be used to create console, GUI, web, game and mobile applications.[11][12][13][14]

Quick Facts Paradigm, Designed by ...
Ring
Thumb
ParadigmMulti-paradigm: object-oriented, imperative, functional, procedural, reflective, declarative, natural language programming
Designed byMahmoud Samir Fayed[1]
DeveloperThe Ring Development Team
First appearedJanuary 25, 2016; 9 years ago (2016-01-25)
Stable release
1.22[2]  / 1 December 2024; 4 months ago (1 December 2024)
Typing disciplineDynamic
Implementation languageC
OSWindows, Linux and macOS
LicenseMIT License
Filename extensions.ring, .rh, .rform
Websitehttp://ring-lang.net
Influenced by
Lua, Python, Ruby, C, C#, BASIC, QML, xBase, Supernova
Influenced
SimpleLang,[3] DragonLang [4]
Close

History

Thumb
Ring IDE (Ring Notepad - Form Designer)

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.[15][16][17][18]

Goals

Thumb
PWCT 2.0 (Android) - Under development using Ring

The general goals behind Ring:[19] [20]

  • 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.[21]

Examples

Summarize
Perspective
Thumb
Different styles for writing the source code
Thumb
Declarative Programming (Web Development)
Thumb
Natural Language Programming
Thumb
Testing TreeView Control Performance using RingQt

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:

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

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

[22][23][24]

Loop command

The Loop command can take an integer to apply the continue semantics to enclosing outer loops[25]

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.)[26]

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[27]

? "Creating a new class dynamically..."
eval("class DynamicClass a b")

? "Printing the instance..."
? new DynamicClass {a=1 b=2}

Implementation

Summarize
Perspective

Compiler and virtual machine

Thumb
Ring VM implementation using PWCT - Virtual Machine Instructions
Thumb
Ring VM implementation using PWCT - List Structure

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

Thumb
Online Form Designer (WebAssembly) - Using RingQt
Thumb
Sokoban Implementation using Ring Game Engine for 2D Games
Thumb
Using Qt3D through RingQt

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.

[28]

Libraries

Ring comes with libraries written in Ring itself, such as libraries related to web and game development.

More information Library Name, Description ...
Library Name Description
Standard Library General Classes and functions.
GUI Library Classes and functions for creating GUI applications
Objects Library Classes and functions for creating GUI applications using the MVC design pattern
Web Library Simple framework for developing web applications using the MVC design pattern
Game Engine Support developing 2D Games for Desktop and Mobile using Declarative Programming based on Allegro and LibSDL
Natural Library General-Purpose Natural Language Programming Library.
Trace Library A library for debugging applications.
Type Hints A library for adding type hints to functions.
Big Number Library Support arithmetic operations on huge numbers.
Fox Ring Library Contains functions similar to Visual FoxPro.
ZeroLib Library Contains classes where the Index starts from 0 instead of 1.
Close

[29][30]

Applications

Thumb
Gold Magic 800 Game - Using RingAllegro and RingOpenGL
Thumb
Online Othello Game (WebAssembly) - Using RingQt

Ring is distributed with over 60 applications written in the language.

Some of these applications are

[31][32]

Tools

Thumb
Running the Tetris game using the Ring Package Manager

Ring is distributed with a Standard IDE that includes the following tools:

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.[33]

Reception

Summarize
Perspective

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).[34] As of October 2020, Ring holds position 93 on the TIOBE index.[35] Ring is listed by GitHub in the list of programming languages that are actively developed.[36]

Criticism

Ring critics pointed to some features in Ring that are not common in widely used programming languages.[37]

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.[38]

/*
** 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

References

Further reading

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.