Click here to Skip to main content
13,801,049 members
Click here to Skip to main content
Add your own
alternative version

Stats

17.8K views
254 downloads
16 bookmarked
Posted 30 Dec 2017
Licenced CPOL

The Evolution of the Ring Programming Language

, 7 Oct 2018
Rate this:
Please Sign up or sign in to vote.
The evolution of the Ring programming language since version 1.0 to 1.9

Introduction

Since the first release of the Ring programming language on January 25, 2016, a lot of new features are added from release to release. In this article, I will focus on major features in each new release, to save others time when they need to know about what is new?, where the development direction is going?, is it worth the time to update or check new release or not?

Background

Ring is a dynamic and 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 language is portable (Windows, Linux, Mac OS X, Android, etc.) and can be used to create console, GUI, web, game and mobile applications. Some of the supported programming paradigms are procedural, object-oriented, declarative using nested structures, and natural programming.

On March 9, 2017, in TIOBE Index, the Ring programming language enters the top 100 for the first time. The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index is updated once a month. It is important to note that the TIOBE index is not about the best programming language or the language in which most lines of code have been written.

In February 2018, the Ring programming language broke into the top 50 for the first time, just 2 years after the first public release in January 2016.

 

 

The language is free open source (download, source code)

Ring 1.1

Top new features in this release:

  • Better Natural Language Programming Support
  • Syntax Flexibility and different styles for I/O and Control Structures
  • Generate/Execute Ring Object Files (*.ringo)
  • StdLib functions and classes written in Ring
  • Demo project - Game Engine for 2D Games
  • RingLibSDL Extension
  • RingSQLite Extensions

With syntax flexibility, we have the freedom to select our favorite style when writing code, based on our preivous experience in using other programming languages.

Having Ring Object Files (*.ringo), we can create closed source applications, distribute applications without distributing the source code!

The new library (StdLib - written in Ring) comes with new functions and classes that we can use to develop real object-oriented applications (everything is an object) or real functional programming software (immutable data, pure functions, map, filter, etc.).

Extensions like RingSQLite, RingLibSDL, and Game Engine for 2D Games, just add more power to the default package of the language!

This release comes with better natural language programming support as we can see in this example.

# Natural Code
new program {
        Accept 2 numbers then print the sum
}

# Natural Code Implementation
class program
        # Keywords
                Accept=0 numbers=0 then=0 print=0 the=0 sum=0

        # Execution
        func braceexpreval x
                value = x
        func getnumbers
                for x=1 to value
                        see "Enter Number ("+x+") :" give nNumber
                        aNumbers + nNumber
                next
        func getsum
                nSUm = 0
                for x in aNumbers nSum+= x next
                see "The Sum : " + nSum
        private
                value=0 aNumbers=[]

After the support of BraceExprEval() method in classes, we can define new natural statements that accept expressions beside keywords!

Ring 1.2

Top new features in this release are:

  • Better Ring Notepad (The Language Editor|IDE)
  • Better RingQt (The GUI Library for Desktop|Mobile)
  • Objects Library for RingQt
  • RingLibCurl Extension
  • Display Warnings Option

Ring notepad is an editor for Ring written in Ring itself. It started as an example, then become more usable by the community, but when comparing it to other code editors, a lot of features are missing. With each new release of Ring, it's common to find an updated version of Ring Notepad, but we have other options and support for other code editors like (Notepad++, Atom, Sublime, Emac, Visual Studio, etc.)

The Objects Library manage the GUI objects and provide a more natural API to quickly create one or many windows from the same class. The library provides a way to quickly set methods to be executed when an event is fired. The Library is designed to be used with the MVC Design Pattern.

load "guilib.ring"

new qApp {
        open_window( :MainWindowController )
        exec()
}

class MainWindowController from WindowsControllerParent
        oView = new MainWindowView
        func SubWindowAction
                Open_window( :SubWindowController )
                Last_Window().SetParentObject(self)

class MainWindowView from WindowsViewParent
        win = new qWidget() {
                SetWindowTitle("Main Window")
                btnSub = new qPushButton(win) {
                        setText("Sub Window")
                        setClickEvent( Method( :SubWindowAction ) )
                }
                resize(400,400)
        }

class SubWindowController from WindowsControllerParent
        oView = new SubWindowView
        func SetMainWindowTitleAction
                Parent().oView.win.SetWindowTitle("Message from the Sub Window")
                oView.win.SetWindowTitle("Click Event Done!")

class SubWindowView from WindowsViewParent
        win = new qWidget() {
                SetWindowTitle("Sub Window")
                btnMsg = new qPushButton(win) {
                        setText("Set Main Window Title")
                        setClickEvent( Method( :SetMainWindowTitleAction ) )
                }
                btnClose = new qPushButton(win) {
                        Move(200,0)
                        setText("Close")
                        setClickEvent( Method( :CloseAction ) )
                }
                resize(400,400)
        }

The objects library solve a problem in the language design that avoid creating references when using the assignment operator (copy by value instead of copy by reference). The language encourages the programmer to avoid using reference as much as possible.

Ring 1.3

Top new features in this release:

  • Embedding Ring in Ring without sharing the State
  • RingZip Library
  • Form Designer

In this release, we have functions for embedding Ring in Ring programs without sharing the state.

Advantages:

  1. Quick integration for Ring programs and applications together without conflicts
  2. Execute and run Ring code in safe environments that we can trace
pState = ring_state_init()
ring_state_runcode(pState,"See 'Hello, World!'+nl")
ring_state_runcode(pState,"x = 10")

pState2 = ring_state_init()
ring_state_runcode(pState2,"See 'Hello, World!'+nl")
ring_state_runcode(pState2,"x = 20")

ring_state_runcode(pState,"see x +nl")
ring_state_runcode(pState2,"see x +nl")

v1 = ring_state_findvar(pState,"x")
v2 = ring_state_findvar(pState2,"x")

see v1[3] + nl
see V2[3] + nl

ring_state_delete(pState)
ring_state_delete(pState2)

Ring 1.3 comes with the Form Designer to quickly design the GUI application windows/forms and generate the Ring source code. The designer is written in Ring (Around 8000 Lines of code) using Object-Oriented Programming and Meta-Programming.

Ring 1.4

Top new features in this release:

  • The Natural Library
  • RingREPL

Using the Natural Library, we can quickly create new natural languages and define new statements!

Using RingREPL (Read-Eval-Print-Loop), we can quickly run commands and test some scripts.

The next example from the natural library, define a language contains two commands!

load "stdlib.ring"
load "naturallib.ring"

New NaturalLanguage {
        SetLanguageName(:MyLanguage)
        SetCommandsPath(CurrentDir()+"/../command")
        SetPackageName("MyLanguage.Natural")
        UseCommand(:Hello)
        UseCommand(:Count)
        RunFile("program.txt")
}

The next code for the Hello command:

DefineNaturalCommand.SyntaxIsKeyword([
        :Package = "MyLanguage.Natural",
        :Keyword = :hello,
        :Function = func {
                See  "Hello, Sir!" + nl + nl
        }
])

Ring 1.5

Top new features in this release:

  • Trace Library and Interactive Debugger
  • Type Hints Library
  • RingFreeGLUT Extension
  • RingOpenGL Extension

Using the Trace library and the Interactive debugger, we can detect and solve the bugs in Ring programs.

Also using the Type hints library, we can add type annotactions to our functions.

The next example uses a Breakpoint to open the Interactive Debugger!

load "tracelib.ring"

test1()

func test1
        x = 10
        see :test1 + nl
        t = 12
        BreakPoint()
        see "After breakpoint!" +nl
        see "t = " + t + nl
        see "End of program!" + nl

The next example uses the typehints library:

load "typehints.ring"

see sayHello("Rubin");

string func sayHello(string name) {
        return "Hello " + name ;
}

Ring 1.6

Top new features in this release:

  • Ring2EXE
  • RingConsoleColors Extension
  • RingMurmurHash Extension

Using Ring2EXE, we can distribute our applications as binary package without including the source code or using the Ring object files (*.ringo) that requires having the RingVM.

Ring2EXE can prepare the application to be distributed for Windows, Linux and macOS.

Also Ring2EXE supports distribution for Mobile devices (using Qt):

ring2exe formdesigner.ring -dist -mobileqt

Ring 1.7

Top new features in this release:

  • Load package command
  • Changing the behavior of the input and output commands
  • RingLibuv Extension

Using the "Load package" command, we can load libraries in a different global scope. This is important to avoid conflicts in global variables between libraries that use them.

Also, Ring 1.7 comes with new functions like ringvm_see() and ringvm_give() that can be used to change the behavior of the input and output commands.

Using the RingLibuv extension, we can access all of the Libuv library features.

The next example uses Libuv threads, which is very simple and nice.

Remember that Ring doesn't have Global Interpreter Lock (No GIL), So we can have real threads executing Ring instructions in parallel at the same time which is more faster than other scripting languages that use GIL.

load "libuv.ring"
load "objectslib.ring"

? "Testing RingLibuv - Threads - Using Classes"

open_object(:MyThreads)

class MyThreads from ObjectControllerParent

        func Start
                one_id = new_uv_thread_t()
                two_id = new_uv_thread_t()
                uv_thread_create(one_id, Method(:One))
                uv_thread_create(two_id, Method(:Two))
                uv_thread_join(one_id)
                uv_thread_join(two_id)
                destroy_uv_thread_t(one_id)
                destroy_uv_thread_t(two_id)

        func one
                ? "Message from the First Thread!"

        func Two
                ? "Message from the Second Thread!"

Ring 1.8

Top new features in this release:

  • Better Performance (The performance gain from 10% to 100% based on the application)
  • More 3D Samples
  • FoxRing Library (library with some functions similar to FoxPro)
  • General improvements to the Compiler, VM, Libraries & Tools

This release comes with better performance and more 3D samples to get an idea about the performance in this release.

In this release the Ring compiler ignore new lines between keywords and the parameters in the same command

see
"
        Hello, World!
"
test()

func
#======================#
        Test
#======================#

        ?
        "

        Hello from the Test function

        "

Ring 1.9

Top new features in this release are:

  • More Games are added to the applications folder (Gold Magic 800, 2048, Tessera, Othello, etc)
  • Better Ring Notepad (The Language Editor|IDE) - New style & Tabs for opened files
  • Better RingQt (The GUI Library) - More classes are added
  • Big Number Library
  • PostgreSQL Extension
  • Deploying web applications in the Cloud
  • Better Memory Management

Ring Notepad is more better in this release, we have tabs for the opened files and better organization for the dock-able windows.

Also more games are added to the applications folder

Gold Magic 800 is a puzzle game developed using Ring, RingAllegro and RingOpenGL

Also, The new games include an implementation for the famous 2048 game using Ring and RingQt

Ring 1.9 comes with better memory management, The Ring API is updated to include RING_API_RETMANAGEDCPOINTER() function, Using this function, the Ring extensions written in C/C++ languages can return a managed pointer to Ring. This pointer can be controlled by the Ring VM using reference counting.

In Ring, The Garbage Collector used Escape Analysis and Reference Counting, According to Ring website, In most cases (90%) The GC uses Escape Analysis (Faster)

This release comes with more functions in the StdLib like List2Code(), This function convert a Ring list during the runtime to Ring source code that we can save to source files.

load "stdlibcore.ring"
aList = 1:10
? list2Code(aList)

Output:

[
        1,2,3,4,5,6,7,8,9,10
]

Points of Interest

With each new release, the language comes with a lot of new features based on the community requirements. Having a small community around the language since it's still a new language leads to quick progress in this stage.

Each new release is compatible (99.99%) with the previous releases, keeping compatibility helps a lot to upgrade from old releases to new releases.

It looks like most of Ring developers come from the Python and Ruby community. To use Ring for Desktop and Mobile development, unlike PyQt, RingQt is free-open source and comes with the language package. Also, the Ring Form Designer is written in Ring itself which adds more user experience similar to Visual Basic to a Dynamic programming language.

The language looks good for games prototyping, It comes with direct support for many popular libraries like (Allegro, LibSDL, OpenGL, etc).

The problem with this language is having a lot of features and many ways to do things which add an extra time during development to decide what are the best features to use for solving a specific problem. For experts, this could be more flexibility and power! But for others, this may increase the learning curve for a language designed to be simple!

History

The time between two releases is not big!

In 2016, the Ring team released two versions of the language (Ring 1.0 and Ring 1.1)

In 2017, they provided new five releases! (Ring 1.2, Ring 1.3, Ring 1.4, Ring 1.5 and Ring 1.6)

In 2018, they provided three releases (Ring 1.7, Ring 1.8 and Ring 1.9)

  • In January 2016, Ring 1.0 was released.
  • In October 2016, Ring 1.1 was released.
  • In January 25, 2017, Ring 1.2 was released.
  • In May 15, 2017, Ring 1.3 was released.
  • In June 29, 2017, Ring 1.4 was released.
  • In August 21, 2017, Ring 1.5 was released.
  • In November 30, 2017, Ring 1.6 was released.
  • In January 25, 2018, Ring 1.7 was released.
  • In June 25, 2018, Ring 1.8 was released.
  • In October 6, 2018, Ring 1.9 was released.

License

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

Share

About the Author

Rubin Liu
Software Developer (Senior)
China China
No Biography provided

You may also be interested in...

Comments and Discussions

 
QuestionC# Pin
David Radcliffe28-Jun-18 3:31
memberDavid Radcliffe28-Jun-18 3:31 
AnswerRe: C# Pin
Rubin Liu28-Jun-18 7:42
memberRubin Liu28-Jun-18 7:42 
SuggestionRing and C# Pin
martin.nedopil3-May-18 0:55
membermartin.nedopil3-May-18 0:55 
GeneralRe: Ring and C# Pin
Rubin Liu27-Jun-18 11:53
memberRubin Liu27-Jun-18 11:53 
GeneralMy vote of 5 Pin
Member 1070234812-Feb-18 19:25
memberMember 1070234812-Feb-18 19:25 
GeneralMy vote of 5 Pin
Member 1070234812-Feb-18 19:25
memberMember 1070234812-Feb-18 19:25 
PraiseMy vote of 5! Pin
jediYL12-Feb-18 14:49
professionaljediYL12-Feb-18 14:49 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.181215.1 | Last Updated 8 Oct 2018
Article Copyright 2017 by Rubin Liu
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid