SlideShare a Scribd company logo
Ring Documentation, Release 1.5.2
The next screen shots for simple 2D Games that we will present in the Game Engine Chapter.
Stars Fighter Game
Flappy Bird 3000 Game
1.11. Samples in this book 15
Ring Documentation, Release 1.5.2
Super Man 2016 Game
1.11. Samples in this book 16
Ring Documentation, Release 1.5.2
1.12 Innovative
The language comes with better support for Natural Language Programming and Declarative Programming. The inno-
vation comes in supporting these paradigms with new practical techniques on the top of Object-Oriented Programming
and Functional Programming. No need to know anything about (Compilers and Parsing). You get the language con-
structs ready for use to create domain-specific languages in a fraction of time.
Articles:-
• Natural Language Programming Library :
https://www.codeproject.com/Articles/1200766/Using-the-Natural-Language-Programming-Library-NLP
• Natural Language Programming :
https://www.codeproject.com/Articles/1138605/Natural-Language-Programming-in-the-Ring-Programmi
• Syntax Flexibility :
https://www.codeproject.com/Articles/1137388/Syntax-Flexibility-in-the-Ring-Programming-Languag
• The Ring Programming Language :
https://www.codeproject.com/Articles/1089887/The-Ring-Programming-Language
1.12. Innovative 17
Ring Documentation, Release 1.5.2
1.13 Practical
Many of the Ring libraries (StdLib, WebLib, Natural Library, Games Engine, etc.) and the Ring IDE (Ring Notepad,
Form Designer, etc.) are written in the Ring language itself. Ring is ready for use in production and increase the
developers productivity.
Check the Form Designer source code : https://github.com/ring-lang/ring/tree/master/applications/formdesigner
1.13. Practical 18
CHAPTER
TWO
INTRODUCTION
Welcome to the Ring programming language!
The Ring is an Innovative and practical general-purpose multi-paradigm language that can be embedded in C/C++
projects, extended using C/C++ code and/or used as standalone language. The supported programming paradigms
are Imperative, Procedural, Object-Oriented, Functional, Meta programming, Declarative programming using nested
structures, and Natural programming. The language is portable (Windows, Linux, Mac OS X, Android, etc.) and can
be used to create Console, GUI, Web, Games and Mobile applications. The language is designed to be Simple, Small,
Flexible and Fast. Its Dynamic Language (Dynamic Typing and Weakly Typed) that compile the source code to byte
code then execute it by the Ring Virtual Machine, which is integrated with the Ring Compiler in one program.
In this chapter we are going to discuss the goals behind the language design and implementation.
2.1 Motivation
In Nov. 2011, I started to think about creating a new version of the Programming Without Coding Technology (PWCT)
software from scratch.
I was interested in creating multi-platform edition of the software beside adding support for Web & Mobile develop-
ment. Most of the PWCT source code was written in VFP and the software comes with a simple scripting language
for creating the components called (RPWI). The software contains components that support code generation in pro-
gramming languages like Harbour, C, Supernova & Python.
What I was looking for is a programming language that can be used to build the development environment, provides
multi-platform support, more productivity, better performance, can be used for components scripting & can be used
for developing different kinds of applications.
Instead of using a mix of programming languages, I decided to use one programming language for creating the devel-
opment environment, for components scripting & for creating the applications.
I looked at many programming languages like C, C++, Java, C#, Lua, PHP, Python & Ruby. I avoided using C or C++
directly because I want high-level of productivity more than the level provided by these languages, also a language
behind visual programming environment for novice programmers or professionals must be easy to use & productive.
19
Ring Documentation, Release 1.5.2
Java & C# are avoided for some reason too! I wanted to use a dynamic programming language and these languages are
static typing, Java is multi-platform, also C# through Mono, but the use of huge number of classes and forcing the use
of Object-Orientation, using a verbose language is not right for me. I need a small language, but fast and productive,
also I need better control on the Garbage Collector (GC), I need a better one that is designed for fast applications.
Lua is small and fast, but it’s avoided because I need more powerful language for large applications.
PHP is a Web programming language and it’s syntax is very similar to C, this leads to a language not general as I want
and not simple as I need to have.
Python & Ruby are more like what I need, but I need something more simple, smaller, faster & productive.
Python and Ruby are Case-Sensitive, the list index start counting from 0, you have to define the function before calling
it, Ruby usage of Object-Orientation and message passing is more than what I need and decrease performance, Python
syntax (indentation, using self, :, pass & _) is not good for my goals.
All of these languages are successful languages, and very good for their domains, but what I need is a different
language that comes with new ideas and intelligent implementation (Innovative, Ready, Simple, Small, Flexible and
Fast).
2.2 History
In Sept. 2013 I started the design and the implementation of the Ring programming language. After 21 months of
development, In May 2015 the language Compiler & Virtual Machine were ready for use!
After that I spent three months testing the language again, trying to discover any bug to fix, writing better tests, by
the end of August 2015, all know bugs were fixed, Writing many tests and testing automation helped a lot in getting a
stable product.
In September 12, 2015, most of the documentation was written. Before releasing the language I started the marketing
by writing a post in Arabic language about it to my facebook profile page asking for contributors interested in the
language idea after reading a short description, In the same day I got a lot of emails from developers and friends
interested to contribute!
Ring 1.0 is released on January 25, 2016
Ring 1.1 is released on October 6, 2016
Ring 1.2 is released on January 25, 2017
Ring 1.3 is released on May 15, 2017
Ring 1.4 is released on June 29, 2017
Ring 1.5 is released on August 21, 2017
2.3 Features
The Ring language comes with the next features
Tip: The language is ready for production!
• Free Open Source (MIT License)
• Hybrid Implementation (Compiler + Virtual Machine)
• Declarative programming on the top of Object-Oriented programming
2.2. History 20
Ring Documentation, Release 1.5.2
• Natural Language programming on the top of Object-Oriented programming
• Syntax Flexibility (You can change the language keywords and operators)
• Compact Syntax, No explicit end for statements (No ; or ENTER is required)
• Using braces { } we can access objects and use attributes/methods as variables/functions
• Transparent Implementation
• Visual Implementation - Developed using Visual Programming (PWCT)
• A small language
– The compiler + The Virtual Machine are 15,000 lines of C code
– The other 500,000 lines of code are related to libraries!
• Writen in ANSI C (The code is generated)
• Optional Printing for Tokens/Grammar/Byte-Code during execution
• Portable (Windows, Linux & Mac OS X)
• Comments (One line & Multi-lines)
• Not Case-Sensitive
• Dynamic Typing
• Weakly typed
• Lexical Scoping (Global, Local & Object State)
• Default scope for variables inside functions (Local)
• Default scope for variables outside functions (global)
• Garbage Collector - Automatic Memory Management (Escape Analysis and Reference Counting)
• Structure Programming
• Rich control structures & Operators
• For in get item by reference not value, you can read/edit the item
• Use exit to go outside from more than one loop
• Procedures/Functions
• Main Function (optional)
• Call Function before the definition
• Recursion
• Multi-line literals
• Access (read/write) string letter by index
• The list index start by 1
• No keyword to end Functions/Classes/Packages
• Range operator ex: 1:10 and “a”:”z”
• First Class Variables, Lists, Objects and Functions
• Store/Copy Lists/Objects by value (Deep Copy)
• Pass Lists/Objects by reference
2.3. Features 21
Ring Documentation, Release 1.5.2
• Native Object-Oriented Support
– Encapsulation
– Setter/Getter (optional)
– private state (optional)
– Instantiation
– Polymorphism
– Composition
– Inheritance (Single Inheritance)
– Operator Overloading
– Packages
• Reflection and Meta-programming
• Clear program structure (Statements then functions then packages & classes)
• Exception Handling
• Eval() to execute code during run-time
• 8-bit clean, work on binary data directly
• I/O commands
• Math functions
• String functions
• List functions
• File processing functions
• Database support (ODBC, SQLite & MySQL)
• Security Functions (OpenSSL)
• Internet Functions (LibCurl)
• Zip Functions
• CGI Library (Written in Ring)
– HTTP Get
– HTTP Post
– File upload
– Cookies
– URL Encode
– HTML Templates
– HTML Special Characters
– HTML Generation using Functions
– HTML Generation using Classes
– CRUD Example (using MVC)
– Users Example (Register, Login and Check)
2.3. Features 22
Ring Documentation, Release 1.5.2
• Extension using C/C++ (Simple API)
• Embedding the language in C/C++ programs
• Comes with code generator (Written in Ring) to quickly wrap C/C++ Libraries
– Used to Support Allegro by creating RingAllegro
– Used to Support LibSDL by creating RingLibSDL
– Used to Support Qt by creating RingQt
• Create 2D Games for Desktop and Mobile (Using the Allegro Library or the LibSDL Library)
• Comes with simple Game Engine for 2D Games
• Support FreeGLUT and OpenGL for 3D Graphics
• Create GUI Applications for Desktop and Mobile (Using the Qt Framework)
• Comes with IDE contains the Code Editor (Ring Notepad) and the Form Designer
2.4 License
The Ring Programming Language
http://ring-lang.net/
Version 1.5.2
The MIT License (MIT)
Copyright (c) Mahmoud Fayed
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documen-
tation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom
the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PAR-
TICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT-
WARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2.4. License 23
CHAPTER
THREE
LANGUAGE DESIGN
In this chapter we will learn about the basic concepts behind the language design.
3.1 Why Ring?
The language is simple, trying to be natural, encourage organization and comes with transparent and visual implemen-
tation. It comes with compact syntax and a group of features that enable the programmer to create natural interfaces
and declarative domain-specific languages in a fraction of time. It is very small, fast and comes with smart garbage
collector that puts the memory under the programmer control. It supports many programming paradigms, comes with
useful and practical libraries. The language is designed for productivity and developing high quality solutions that can
scale.
3.2 Designed for a Clear Goal
• Applications programming language.
• Productivity and developing high quality solutions that can scale.
• Small and fast 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.
3.3 Simple
Ring is a very simple language, and has a very straightforward syntax. It encourages programmers to program without
boilerplate code
See "Hello, World!"
The Main function is optional and will be executed after the statements, and is useful for using the local scope.
Func Main
See "Hello, World!"
24

More Related Content

PDF
The Ring programming language version 1.5.4 book - Part 5 of 185
PDF
The Ring programming language version 1.5.3 book - Part 5 of 184
PDF
The Ring programming language version 1.4.1 book - Part 2 of 31
PDF
The Ring programming language version 1.4 book - Part 2 of 30
PDF
The Ring programming language version 1.5.1 book - Part 4 of 180
PDF
The Ring programming language version 1.3 book - Part 4 of 88
PDF
The Ring programming language version 1.10 book - Part 6 of 212
PDF
The Ring programming language version 1.7 book - Part 6 of 196
The Ring programming language version 1.5.4 book - Part 5 of 185
The Ring programming language version 1.5.3 book - Part 5 of 184
The Ring programming language version 1.4.1 book - Part 2 of 31
The Ring programming language version 1.4 book - Part 2 of 30
The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.3 book - Part 4 of 88
The Ring programming language version 1.10 book - Part 6 of 212
The Ring programming language version 1.7 book - Part 6 of 196

What's hot (20)

PDF
The Ring programming language version 1.9 book - Part 6 of 210
PDF
The Ring programming language version 1.6 book - Part 6 of 189
PDF
The Ring programming language version 1.2 book - Part 4 of 84
PDF
The Ring programming language version 1.8 book - Part 6 of 202
PPT
COMPUTER LANGUAGES AND THERE DIFFERENCE
PDF
Programming Language Selection
PDF
Functional conf 2014_schedule
PDF
Programing fundamentals with C++
PPTX
Programming languages
PPTX
Entrepreneur’s guide to programming
PPT
Comparative Study of programming Languages
PPTX
computer languages
PDF
Lets Go - An introduction to Google's Go Programming Language
PDF
Ruby vs Java: Comparing Two Popular Programming Languages For Developing Ente...
PDF
JPT : A SIMPLE JAVA-PYTHON TRANSLATOR
PPTX
Evolution of Computer Languages
PDF
Build your own Language - Why and How?
PDF
Bridge to r
PDF
Programming Languages Categories / Programming Paradigm By: Prof. Lili Saghafi
PDF
Computer programming programming_langugages
The Ring programming language version 1.9 book - Part 6 of 210
The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.2 book - Part 4 of 84
The Ring programming language version 1.8 book - Part 6 of 202
COMPUTER LANGUAGES AND THERE DIFFERENCE
Programming Language Selection
Functional conf 2014_schedule
Programing fundamentals with C++
Programming languages
Entrepreneur’s guide to programming
Comparative Study of programming Languages
computer languages
Lets Go - An introduction to Google's Go Programming Language
Ruby vs Java: Comparing Two Popular Programming Languages For Developing Ente...
JPT : A SIMPLE JAVA-PYTHON TRANSLATOR
Evolution of Computer Languages
Build your own Language - Why and How?
Bridge to r
Programming Languages Categories / Programming Paradigm By: Prof. Lili Saghafi
Computer programming programming_langugages
Ad

Similar to The Ring programming language version 1.5.2 book - Part 5 of 181 (20)

PDF
The Ring programming language version 1.5.1 book - Part 173 of 180
PDF
The Ring programming language version 1.7 book - Part 89 of 196
PDF
The Ring programming language version 1.10 book - Part 99 of 212
PDF
The Ring programming language version 1.9 book - Part 97 of 210
PDF
The Ring programming language version 1.2 book - Part 77 of 84
PDF
The Ring programming language version 1.6 book - Part 5 of 189
PDF
The Ring programming language version 1.5.1 book - Part 5 of 180
PDF
The Ring programming language version 1.5.3 book - Part 186 of 194
PDF
The Ring programming language version 1.10 book - Part 7 of 212
PDF
The Ring programming language version 1.3 book - Part 81 of 88
PDF
The Ring programming language version 1.5.4 book - Part 6 of 185
PDF
The Ring programming language version 1.5.1 book - Part 13 of 180
PDF
The Ring programming language version 1.5.3 book - Part 6 of 184
PDF
The Ring programming language version 1.8 book - Part 4 of 202
PDF
The Ring programming language version 1.6 book - Part 181 of 189
PDF
The Ring programming language version 1.5 book - Part 3 of 31
PDF
The Ring programming language version 1.2 book - Part 84 of 84
PDF
The Ring programming language version 1.5.2 book - Part 14 of 181
PDF
The Ring programming language version 1.6 book - Part 16 of 189
PDF
The Ring programming language version 1.3 book - Part 8 of 88
The Ring programming language version 1.5.1 book - Part 173 of 180
The Ring programming language version 1.7 book - Part 89 of 196
The Ring programming language version 1.10 book - Part 99 of 212
The Ring programming language version 1.9 book - Part 97 of 210
The Ring programming language version 1.2 book - Part 77 of 84
The Ring programming language version 1.6 book - Part 5 of 189
The Ring programming language version 1.5.1 book - Part 5 of 180
The Ring programming language version 1.5.3 book - Part 186 of 194
The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.3 book - Part 81 of 88
The Ring programming language version 1.5.4 book - Part 6 of 185
The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.3 book - Part 6 of 184
The Ring programming language version 1.8 book - Part 4 of 202
The Ring programming language version 1.6 book - Part 181 of 189
The Ring programming language version 1.5 book - Part 3 of 31
The Ring programming language version 1.2 book - Part 84 of 84
The Ring programming language version 1.5.2 book - Part 14 of 181
The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.3 book - Part 8 of 88
Ad

More from Mahmoud Samir Fayed (20)

PDF
The Ring programming language version 1.10 book - Part 212 of 212
PDF
The Ring programming language version 1.10 book - Part 211 of 212
PDF
The Ring programming language version 1.10 book - Part 210 of 212
PDF
The Ring programming language version 1.10 book - Part 208 of 212
PDF
The Ring programming language version 1.10 book - Part 207 of 212
PDF
The Ring programming language version 1.10 book - Part 205 of 212
PDF
The Ring programming language version 1.10 book - Part 206 of 212
PDF
The Ring programming language version 1.10 book - Part 204 of 212
PDF
The Ring programming language version 1.10 book - Part 203 of 212
PDF
The Ring programming language version 1.10 book - Part 202 of 212
PDF
The Ring programming language version 1.10 book - Part 201 of 212
PDF
The Ring programming language version 1.10 book - Part 200 of 212
PDF
The Ring programming language version 1.10 book - Part 199 of 212
PDF
The Ring programming language version 1.10 book - Part 198 of 212
PDF
The Ring programming language version 1.10 book - Part 197 of 212
PDF
The Ring programming language version 1.10 book - Part 196 of 212
PDF
The Ring programming language version 1.10 book - Part 195 of 212
PDF
The Ring programming language version 1.10 book - Part 194 of 212
PDF
The Ring programming language version 1.10 book - Part 193 of 212
PDF
The Ring programming language version 1.10 book - Part 192 of 212
The Ring programming language version 1.10 book - Part 212 of 212
The Ring programming language version 1.10 book - Part 211 of 212
The Ring programming language version 1.10 book - Part 210 of 212
The Ring programming language version 1.10 book - Part 208 of 212
The Ring programming language version 1.10 book - Part 207 of 212
The Ring programming language version 1.10 book - Part 205 of 212
The Ring programming language version 1.10 book - Part 206 of 212
The Ring programming language version 1.10 book - Part 204 of 212
The Ring programming language version 1.10 book - Part 203 of 212
The Ring programming language version 1.10 book - Part 202 of 212
The Ring programming language version 1.10 book - Part 201 of 212
The Ring programming language version 1.10 book - Part 200 of 212
The Ring programming language version 1.10 book - Part 199 of 212
The Ring programming language version 1.10 book - Part 198 of 212
The Ring programming language version 1.10 book - Part 197 of 212
The Ring programming language version 1.10 book - Part 196 of 212
The Ring programming language version 1.10 book - Part 195 of 212
The Ring programming language version 1.10 book - Part 194 of 212
The Ring programming language version 1.10 book - Part 193 of 212
The Ring programming language version 1.10 book - Part 192 of 212

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Cloud computing and distributed systems.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Empathic Computing: Creating Shared Understanding
PDF
cuic standard and advanced reporting.pdf
PPT
Teaching material agriculture food technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
MIND Revenue Release Quarter 2 2025 Press Release
Network Security Unit 5.pdf for BCA BBA.
The Rise and Fall of 3GPP – Time for a Sabbatical?
NewMind AI Weekly Chronicles - August'25 Week I
Mobile App Security Testing_ A Comprehensive Guide.pdf
Cloud computing and distributed systems.
Per capita expenditure prediction using model stacking based on satellite ima...
Empathic Computing: Creating Shared Understanding
cuic standard and advanced reporting.pdf
Teaching material agriculture food technology
Chapter 3 Spatial Domain Image Processing.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
The AUB Centre for AI in Media Proposal.docx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Digital-Transformation-Roadmap-for-Companies.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
MIND Revenue Release Quarter 2 2025 Press Release

The Ring programming language version 1.5.2 book - Part 5 of 181

  • 1. Ring Documentation, Release 1.5.2 The next screen shots for simple 2D Games that we will present in the Game Engine Chapter. Stars Fighter Game Flappy Bird 3000 Game 1.11. Samples in this book 15
  • 2. Ring Documentation, Release 1.5.2 Super Man 2016 Game 1.11. Samples in this book 16
  • 3. Ring Documentation, Release 1.5.2 1.12 Innovative The language comes with better support for Natural Language Programming and Declarative Programming. The inno- vation comes in supporting these paradigms with new practical techniques on the top of Object-Oriented Programming and Functional Programming. No need to know anything about (Compilers and Parsing). You get the language con- structs ready for use to create domain-specific languages in a fraction of time. Articles:- • Natural Language Programming Library : https://www.codeproject.com/Articles/1200766/Using-the-Natural-Language-Programming-Library-NLP • Natural Language Programming : https://www.codeproject.com/Articles/1138605/Natural-Language-Programming-in-the-Ring-Programmi • Syntax Flexibility : https://www.codeproject.com/Articles/1137388/Syntax-Flexibility-in-the-Ring-Programming-Languag • The Ring Programming Language : https://www.codeproject.com/Articles/1089887/The-Ring-Programming-Language 1.12. Innovative 17
  • 4. Ring Documentation, Release 1.5.2 1.13 Practical Many of the Ring libraries (StdLib, WebLib, Natural Library, Games Engine, etc.) and the Ring IDE (Ring Notepad, Form Designer, etc.) are written in the Ring language itself. Ring is ready for use in production and increase the developers productivity. Check the Form Designer source code : https://github.com/ring-lang/ring/tree/master/applications/formdesigner 1.13. Practical 18
  • 5. CHAPTER TWO INTRODUCTION Welcome to the Ring programming language! The Ring is an Innovative and practical general-purpose multi-paradigm language that can be embedded in C/C++ projects, extended using C/C++ code and/or used as standalone language. The supported programming paradigms are Imperative, Procedural, Object-Oriented, Functional, Meta programming, Declarative programming using nested structures, and Natural programming. The language is portable (Windows, Linux, Mac OS X, Android, etc.) and can be used to create Console, GUI, Web, Games and Mobile applications. The language is designed to be Simple, Small, Flexible and Fast. Its Dynamic Language (Dynamic Typing and Weakly Typed) that compile the source code to byte code then execute it by the Ring Virtual Machine, which is integrated with the Ring Compiler in one program. In this chapter we are going to discuss the goals behind the language design and implementation. 2.1 Motivation In Nov. 2011, I started to think about creating a new version of the Programming Without Coding Technology (PWCT) software from scratch. I was interested in creating multi-platform edition of the software beside adding support for Web & Mobile develop- ment. Most of the PWCT source code was written in VFP and the software comes with a simple scripting language for creating the components called (RPWI). The software contains components that support code generation in pro- gramming languages like Harbour, C, Supernova & Python. What I was looking for is a programming language that can be used to build the development environment, provides multi-platform support, more productivity, better performance, can be used for components scripting & can be used for developing different kinds of applications. Instead of using a mix of programming languages, I decided to use one programming language for creating the devel- opment environment, for components scripting & for creating the applications. I looked at many programming languages like C, C++, Java, C#, Lua, PHP, Python & Ruby. I avoided using C or C++ directly because I want high-level of productivity more than the level provided by these languages, also a language behind visual programming environment for novice programmers or professionals must be easy to use & productive. 19
  • 6. Ring Documentation, Release 1.5.2 Java & C# are avoided for some reason too! I wanted to use a dynamic programming language and these languages are static typing, Java is multi-platform, also C# through Mono, but the use of huge number of classes and forcing the use of Object-Orientation, using a verbose language is not right for me. I need a small language, but fast and productive, also I need better control on the Garbage Collector (GC), I need a better one that is designed for fast applications. Lua is small and fast, but it’s avoided because I need more powerful language for large applications. PHP is a Web programming language and it’s syntax is very similar to C, this leads to a language not general as I want and not simple as I need to have. Python & Ruby are more like what I need, but I need something more simple, smaller, faster & productive. Python and Ruby are Case-Sensitive, the list index start counting from 0, you have to define the function before calling it, Ruby usage of Object-Orientation and message passing is more than what I need and decrease performance, Python syntax (indentation, using self, :, pass & _) is not good for my goals. All of these languages are successful languages, and very good for their domains, but what I need is a different language that comes with new ideas and intelligent implementation (Innovative, Ready, Simple, Small, Flexible and Fast). 2.2 History In Sept. 2013 I started the design and the implementation of the Ring programming language. After 21 months of development, In May 2015 the language Compiler & Virtual Machine were ready for use! After that I spent three months testing the language again, trying to discover any bug to fix, writing better tests, by the end of August 2015, all know bugs were fixed, Writing many tests and testing automation helped a lot in getting a stable product. In September 12, 2015, most of the documentation was written. Before releasing the language I started the marketing by writing a post in Arabic language about it to my facebook profile page asking for contributors interested in the language idea after reading a short description, In the same day I got a lot of emails from developers and friends interested to contribute! Ring 1.0 is released on January 25, 2016 Ring 1.1 is released on October 6, 2016 Ring 1.2 is released on January 25, 2017 Ring 1.3 is released on May 15, 2017 Ring 1.4 is released on June 29, 2017 Ring 1.5 is released on August 21, 2017 2.3 Features The Ring language comes with the next features Tip: The language is ready for production! • Free Open Source (MIT License) • Hybrid Implementation (Compiler + Virtual Machine) • Declarative programming on the top of Object-Oriented programming 2.2. History 20
  • 7. Ring Documentation, Release 1.5.2 • Natural Language programming on the top of Object-Oriented programming • Syntax Flexibility (You can change the language keywords and operators) • Compact Syntax, No explicit end for statements (No ; or ENTER is required) • Using braces { } we can access objects and use attributes/methods as variables/functions • Transparent Implementation • Visual Implementation - Developed using Visual Programming (PWCT) • A small language – The compiler + The Virtual Machine are 15,000 lines of C code – The other 500,000 lines of code are related to libraries! • Writen in ANSI C (The code is generated) • Optional Printing for Tokens/Grammar/Byte-Code during execution • Portable (Windows, Linux & Mac OS X) • Comments (One line & Multi-lines) • Not Case-Sensitive • Dynamic Typing • Weakly typed • Lexical Scoping (Global, Local & Object State) • Default scope for variables inside functions (Local) • Default scope for variables outside functions (global) • Garbage Collector - Automatic Memory Management (Escape Analysis and Reference Counting) • Structure Programming • Rich control structures & Operators • For in get item by reference not value, you can read/edit the item • Use exit to go outside from more than one loop • Procedures/Functions • Main Function (optional) • Call Function before the definition • Recursion • Multi-line literals • Access (read/write) string letter by index • The list index start by 1 • No keyword to end Functions/Classes/Packages • Range operator ex: 1:10 and “a”:”z” • First Class Variables, Lists, Objects and Functions • Store/Copy Lists/Objects by value (Deep Copy) • Pass Lists/Objects by reference 2.3. Features 21
  • 8. Ring Documentation, Release 1.5.2 • Native Object-Oriented Support – Encapsulation – Setter/Getter (optional) – private state (optional) – Instantiation – Polymorphism – Composition – Inheritance (Single Inheritance) – Operator Overloading – Packages • Reflection and Meta-programming • Clear program structure (Statements then functions then packages & classes) • Exception Handling • Eval() to execute code during run-time • 8-bit clean, work on binary data directly • I/O commands • Math functions • String functions • List functions • File processing functions • Database support (ODBC, SQLite & MySQL) • Security Functions (OpenSSL) • Internet Functions (LibCurl) • Zip Functions • CGI Library (Written in Ring) – HTTP Get – HTTP Post – File upload – Cookies – URL Encode – HTML Templates – HTML Special Characters – HTML Generation using Functions – HTML Generation using Classes – CRUD Example (using MVC) – Users Example (Register, Login and Check) 2.3. Features 22
  • 9. Ring Documentation, Release 1.5.2 • Extension using C/C++ (Simple API) • Embedding the language in C/C++ programs • Comes with code generator (Written in Ring) to quickly wrap C/C++ Libraries – Used to Support Allegro by creating RingAllegro – Used to Support LibSDL by creating RingLibSDL – Used to Support Qt by creating RingQt • Create 2D Games for Desktop and Mobile (Using the Allegro Library or the LibSDL Library) • Comes with simple Game Engine for 2D Games • Support FreeGLUT and OpenGL for 3D Graphics • Create GUI Applications for Desktop and Mobile (Using the Qt Framework) • Comes with IDE contains the Code Editor (Ring Notepad) and the Form Designer 2.4 License The Ring Programming Language http://ring-lang.net/ Version 1.5.2 The MIT License (MIT) Copyright (c) Mahmoud Fayed Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documen- tation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PAR- TICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT- WARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2.4. License 23
  • 10. CHAPTER THREE LANGUAGE DESIGN In this chapter we will learn about the basic concepts behind the language design. 3.1 Why Ring? The language is simple, trying to be natural, encourage organization and comes with transparent and visual implemen- tation. It comes with compact syntax and a group of features that enable the programmer to create natural interfaces and declarative domain-specific languages in a fraction of time. It is very small, fast and comes with smart garbage collector that puts the memory under the programmer control. It supports many programming paradigms, comes with useful and practical libraries. The language is designed for productivity and developing high quality solutions that can scale. 3.2 Designed for a Clear Goal • Applications programming language. • Productivity and developing high quality solutions that can scale. • Small and fast 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. 3.3 Simple Ring is a very simple language, and has a very straightforward syntax. It encourages programmers to program without boilerplate code See "Hello, World!" The Main function is optional and will be executed after the statements, and is useful for using the local scope. Func Main See "Hello, World!" 24