Ring (programming language)

From HandWiki
Short description: Dynamically typed, general-purpose programming language
Ring
Ringlogo transparent.png
ParadigmMulti-paradigm: object-oriented, imperative, functional, procedural, reflective, declarative, natural language programming
DeveloperThe Ring Development Team
First appearedJanuary 25, 2016; 8 years ago (2016-01-25)
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,[1] DragonLang [2]

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

History

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.[13][14][15][16]

Goals

PWCT 2.0 (Android) - Under development using Ring

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

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

Examples

Different styles for writing the source code
Declarative Programming (Web Development)
Natural Language Programming
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:

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

[20][21]

Loop command

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

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 orogramming

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

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

? "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 VM implementation using PWCT - Virtual Machine Instructions
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

Online Form Designer (WebAssembly) - Using RingQt
Sokoban Implementation using Ring Game Engine for 2D Games
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.

[25]

Libraries

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.

[26][27]

Applications

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

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

Some of these applications are

[28][29]

Tools

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

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

Criticism

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

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

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

  1. Azeez Adewale. "The Simple programming language". https://simple-lang.sourceforge.io. 
  2. Aavesh Jilani. "The Dragon programming language". https://www.dragon-lang.org/. 
  3. Dr. Rangarajan Krishnamoorthy (7 August 2021). "First Encounter with the Ring Programming Language". rangakrish.com. https://www.rangakrish.com/index.php/2021/08/07/first-encounter-with-the-ring-programming-language/. 
  4. Omar Selim (January 2018). "The Ring programming language Review". BIMArabia Magazine. http://bimarabia.com/download/BIMarabia_Arabic/BIMarabia27.pdf#page=8. 
  5. Ahmed Tartour (January 2020). "Your way to programming (Arabic Book, Pages 56-57) talk about Ring". Kotobna. https://ring-lang.sourceforge.io/ref/ArabicBook_YourWayToProgramming_TalkAboutRing.pdf. 
  6. Bernhard Lauer (14 August 2018). "Ring: flexible, simple, fast". Dotnetpro. https://www.dotnetpro.de/diverses/sprachen/ring-flexibel-einfach-schnell-1571947.html. 
  7. Paul Krill (24 August 2020). "Ring language upgrade focuses on WebAssembly". InfoWorld. https://www.infoworld.com/article/3572395/ring-language-upgrade-focuses-on-webassembly.html. 
  8. Ghanem, Mohamed (2021). Developing Poet Software using Ring language. MetaBook (Egypt - Mansoura). ISBN 978-977-6928-38-1. https://ring-lang.sourceforge.io/ref/GhanemBookAboutRing.pdf. 
  9. (in en) Beginning Ring Programming - From Novice to Professional | Mansour Ayouni | Apress. https://www.apress.com/gp/book/9781484258323. 
  10. Hany Salah (11 January 2016). "Ring: A New programming language". youm7.com. youm7. https://www.youm7.com/story/2016/1/11/%D9%81%D9%89-25-%D9%8A%D9%86%D8%A7%D9%8A%D8%B1-%D8%A7%D9%84%D9%85%D9%82%D8%A8%D9%84-%D9%84%D8%BA%D8%A9-%D8%A8%D8%B1%D9%85%D8%AC%D8%A9-%D8%AC%D8%AF%D9%8A%D8%AF%D8%A9-%D8%A8%D9%85%D9%88%D8%A7%D8%B5%D9%81%D8%A7%D8%AA-%D8%B9%D8%A7%D9%84%D9%85%D9%8A%D8%A9-%D9%85%D9%86/2532713. 
  11. Ahmed Mohammed Hassan. "Ring: A programming language developed by Arab". https://muslims-res.com/%D9%84%D8%BA%D8%A9-%D8%A8%D8%B1%D9%85%D8%AC%D9%8A%D8%A9-%D8%AC%D8%AF%D9%8A%D8%AF%D8%A9-%D8%A8%D8%A3%D9%8A%D8%AF%D9%8D-%D8%B9%D8%B1%D8%A8%D9%8A%D8%A9-%D9%88%D9%84%D9%82%D8%A7%D8%A1-%D8%AD%D8%B5%D8%B1/. 
  12. Abedallah Salehani. "A book about the Ring programming language". https://muslims-res.com/%D9%84%D8%BA%D8%A9-%D8%B1%D9%8A%D9%86%D8%AC-%D8%A7%D9%84%D8%A8%D8%B1%D9%85%D8%AC%D9%8A%D8%A9-ring-programming/. 
  13. Ring Team (September 2021). "Ring Language - Frequently Asked Questions (FAQ)". Ring Team. https://ring-lang.github.io/doc1.16/faq.html. 
  14. Fayed (April 2010). "Supernova programming language". Code Project. https://www.codeproject.com/Articles/66996/Supernova-Programming-Language. 
  15. Omnia (December 2011). "Supernova language by Egyptian programmer". Youm7. https://www.youm7.com/story/2011/12/24/%D8%B4%D8%A7%D8%A8-%D9%85%D8%B5%D8%B1%D9%89-%D9%8A%D8%A8%D8%AA%D9%83%D8%B1-%D8%B3%D9%88%D8%A8%D8%B1-%D9%86%D9%88%D9%81%D8%A7-%D9%88%D8%AA%D9%82%D9%86%D9%8A%D8%A9-%D8%A8%D8%B1%D9%85%D8%AC%D8%A9-%D8%A8%D8%AF%D9%88%D9%86-%D9%83%D9%88%D8%AF/562415. 
  16. Softpedia Team (23 October 2021). "Ring 1.16 review". Softpedia. https://www.softpedia.com/get/Programming/Coding-languages-Compilers/Fayed-Ring.shtml. 
  17. Naveen Verma (14 Aug 2018). "Ring Programming Language: What Do You Need To Know?". Medium. https://medium.com/sitesonic/ring-programming-language-what-do-you-need-to-know-23c51b315e4d. 
  18. Mones Hawas (29 May 2018). "Progress in developing PWCT 2.0 using Ring". youm7.com. youm7. https://www.youm7.com/story/2018/5/29/%D9%85%D8%B5%D8%B1%D9%89-%D9%8A%D9%81%D9%88%D8%B2-%D9%81%D9%89-%D9%85%D8%B3%D8%A7%D8%A8%D9%82%D8%A9-%D8%A7%D9%84%D8%B3%D9%88%D8%B1%D8%B3-%D9%81%D9%88%D8%B1%D8%AC-%D9%84%D9%84%D9%85%D8%B4%D8%A7%D8%B1%D9%8A%D8%B9-%D9%85%D9%81%D8%AA%D9%88%D8%AD%D8%A9-%D8%A7%D9%84%D9%85%D8%B5%D8%AF%D8%B1/3812107. 
  19. Fayed, Mahmoud S.; Al-Qurishi, Muhammad; Alamri, Atif; Hossain, M. Anwar; Al-Daraiseh, Ahmad A. (October 2020). "PWCT: a novel general-purpose visual programming language in support of pervasive application development". CCF Transactions on Pervasive Computing and Interaction 2 (3): 164–177. doi:10.1007/s42486-020-00038-y. 
  20. Rubin Liu (28 December 2017). "Different styles for writing Hello World program in the Ring programming language". codeproject.com. Code Project. https://www.codeproject.com/Tips/1222859/Different-styles-for-writing-Hello-World-program-i. 
  21. Roshan Ali (4 June 2018). "Ring programming tutorial". YouTube. https://www.youtube.com/watch?v=7BqoQldx0Pk&list=PL8SruvH85P0uA8ggijCQUR9tXAXF4bmtu&index=2. 
  22. Dr. Rangarajan Krishnamoorthy (21 August 2021). ""Loop" Command in Ring Programming Language". rangakrish.com. https://www.rangakrish.com/index.php/2021/08/21/loop-command-in-ring-programming-language/. 
  23. "Object Oriented Programming (OOP) — Ring 1.16 documentation". https://ring-lang.github.io/doc1.16/oop.html. 
  24. Dr. Rangarajan Krishnamoorthy (4 September 2021). "Ring Language: Dynamic Behavior of Classes and Objects". rangakrish.com. https://www.rangakrish.com/index.php/2021/09/04/ring-language-dynamic-behavior-of-classes-and-objects/. 
  25. Majdi Sobain (2 May 2017). "Squares Puzzle using RingAllegro". codeproject.com. Code Project. https://www.codeproject.com/Articles/1096942/Squares-Puzzle-using-RingAllegro. 
  26. Fayed (11 August 2017). "Using the Natural Language Programming Library (NLPL) in the Ring Programming Language". codeproject.com. Code Project. https://www.codeproject.com/Articles/1200766/Using-the-Natural-Language-Programming-Library-NLP. 
  27. Fayed (12 October 2016). "Natural Language Programming in the Ring Programming Language". codeproject.com. Code Project. https://www.codeproject.com/Articles/1138605/Natural-Language-Programming-in-the-Ring-Programmi. 
  28. Open Source Developers (15 June 2019). "Applications written in Ring". Ring Team. https://ring-lang.github.io/resources.html. 
  29. Etqan Company (25 September 2018). "Gold Magic 800 Game by Etqan Company". Steam. https://store.steampowered.com/app/939200/Gold_Magic_800/. 
  30. "ようこそ Ring 取扱説明書へ! — プログラミング言語 Ring 1.16 取扱説明書". http://ring-lang-081.osdn.jp/docs-1.16/index.html. 
  31. "TIOBE Index | TIOBE - the Software Quality Company". https://www.tiobe.com/tiobe-index/. 
  32. Emma White (6 October 2020). "Top 100 Programming Languages". https://www.bairesdev.com/blog/top-100-programming-languages/. 
  33. "Build software better, together". https://github.com/collections/programming-languages. 
  34. Ciklum (12 December 2017). "New Programming Languages – A Hype Or Reality?". ciklum.com. Ciklum. https://www.ciklum.com/blog/new-programming-languages-a-hype-or-reality/. 
  35. "Variables — Ring 1.16 documentation". https://ring-lang.github.io/doc1.16/variables.html#implicit-conversion. 

Further reading

External links