Ring (programming language)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Ring
File:Ringlogo transparent.png
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; 10 years ago (2016-01-25)
Typing disciplineDynamic
Implementation languageC
OSWindows, Linux and macOS
LicenseMIT License
Filename extensions.ring, .rh, .rform
Websitering-lang.net
Influenced by
Lua, Python, Ruby, C, C#, BASIC, QML, xBase, Supernova
Influenced
SimpleLang,[2] DragonLang [3]
  • File:Wikibooks-logo-en-noslogan.svg Ring at Wikibooks

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

History

[edit | edit source]
File:Ringlang shot1.png
Ring IDE (Ring Notepad - Form Designer)

In 2009, Mahmoud Samir Fayed created a minor domain-specific language called Supernova that focuses on user interface 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.[14][15][16][17]

Goals

[edit | edit source]
File:Ringlang shot6.png
PWCT 2.0 (Android) - Under development using Ring

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

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

Examples

[edit | edit source]
File:Ringlang shot14.png
Different styles for writing the source code
File:Ringlang shot5.png
Declarative Programming (Web Development)
File:Ringlang shot12.png
Natural Language Programming
File:Ringlang shot13.png
Testing TreeView Control Performance using RingQt

Hello World program

[edit | edit source]

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

[edit | edit source]

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

[21][22][23]

Loop command

[edit | edit source]

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

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

[edit | edit source]

Ring supports object-oriented programming (classes, objects, composition, inheritance, encapsulation, etc.)[25]

new point {                # Create new object then access it 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[26]

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

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

Implementation

[edit | edit source]

Compiler and virtual machine

[edit | edit source]
File:Ringlang shot10.jpg
Ring VM implementation using PWCT - Virtual Machine Instructions
File:Ringlang shot11.jpg
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

[edit | edit source]
File:Ringlang shot3.png
Online Form Designer (WebAssembly) - Using RingQt
File:Ringlang shot8.png
Sokoban Implementation using Ring Game Engine for 2D Games
File:Ringlang shot9.png
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.

[27]

Libraries

[edit | edit source]

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

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.

[28][29]

Applications

[edit | edit source]
File:Ringlang shot2.png
Gold Magic 800 Game - Using RingAllegro and RingOpenGL
File:Ringlang shot4.png
Online Othello Game (WebAssembly) - Using RingQt

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

Some of these applications are

[30][31]

Tools

[edit | edit source]
File:Ringlang shot7.png
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

[edit | edit source]

Ring is distributed with documentation written using Sphinx. A Japanese translation of the documentation is also available.[32]

Reception

[edit | edit source]

Popularity

[edit | edit source]

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

Criticism

[edit | edit source]

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

The list index starts from 1 instead of 0

[edit | edit source]

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

[edit | edit source]

The language can automatically convert between numbers and strings.[37]

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

[edit | edit source]

Lua error in mw.title.lua at line 392: bad argument #2 to 'title.new' (unrecognized namespace name 'Portal').

References

[edit | edit source]
  1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  2. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  3. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  4. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  5. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  6. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  7. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  8. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  9. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  10. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  11. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  12. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  13. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  14. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  15. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  16. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  17. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  18. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  19. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  20. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  21. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  22. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  23. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  24. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  25. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  26. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  27. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  28. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  29. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  30. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  31. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  32. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  33. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  34. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  35. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  36. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  37. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).

Further reading

[edit | edit source]
[edit | edit source]