Mansour Ayouni

Beginning Ring Programming

From Novice to Professional

Mansour Ayouni
Kalidia Consulting, Sousse, Tunisia
ISBN 978-1-4842-5832-3e-ISBN 978-1-4842-5833-0
© Mansour Ayouni 2020
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, express or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004, U.S.A. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.

To the soul of my father, Mohsen, who gave me hisringas a message and a lifelong souvenir.

Foreword

Ring was created with a goal: to be a new language for a new programming experience.

Developing a programming language that we can rely on when we are thinking about the problems we need to solve instead of being constrained by the syntax and the rigidity of the programming paradigm is not an easy endeavor. The general mindset cultivated by the programming domain so far has proliferated the establishment of a set of technical dogmas. Obviously, this narrows the window of innovation and constitutes a serious barrier to entry for many people who could be great programmers but are demotivated by the complexity of today’s programming tools.

Facing such a cultural and technological challenge, I was aware from the beginning that I should develop a programming language for the long term. Although Ring, as you will discover in this book, is designed to deal pragmatically with any situation that a general-purpose programming language can manage, my focus was to enable new ways of thinking in code, which I believe will be required from any programmer in the foreseeable future. Writing programsvisually while leaving the tedious code generation task to the machine, designing programsdeclaratively with the semantics of the application domain, and talking with the code in anatural language written by the programmer inside that code are just three domains of innovation the new generation of programming languages should embrace.

In this regard, what makes the Ring language so important is that it naturally emerged as a solution for these strong requirements when I tried to solve them in existent programming languages and couldn’t. Every feature of the language finds its origin in a problem I faced when I was working on the PWCT project, 1 and every decision I made on its design, even if it breaks the norm and sometimes shocks the common sense, forms an answer to a practical problem that was unsolvable or hard to solve in other languages. In fact, most of them focus restrictively on conventional programming paradigms such as procedural, object-oriented, and functional programming. In Ring, our message is toconnect between those paradigms and others, such as declarative and natural language programming, in a new programming experience.

The beauty of the book in your hands is that it embraces theculture of the language while presenting its powerful features in a practical way. Mansour really shows how Ring can be an option in developing small or large programs and in enabling a programming journey based on prototyping, experimentation, iterative design, clean architecture, and code craftsmanship. Nevertheless, the author, who I consider to be a master of Ring and programming in general, has revealed the secrets of the great programmers in thinking, analyzing, modeling, and writing code. Many technical constructs famously known to be complex in programming, such as MVC architecture, data-oriented modeling, scope management, function and object composition, event-driven systems, real-time applications, and even game programming, are all introduced in an innovative visual way, with tons of examples and many engaging stories to tell.

By contemplating the strategies and real-world situations in this instructive, well-organized book and how they are solved nicely in Ring, I can say with confidence that the message behind the language has been delivered. That said, I hope that this book will help you gaining anemotional connection with Ring as a thinking tool, as a hackable learning environment, and, ultimately, as a friendly programming language built around the core values of syntax freedom, programmer’s responsibility, technological transparency, and multiparadigm programming.

Welcome to Ring, and welcome toBeginning Ring Programming .

Mahmoud Samir Fayed

Creator of Ring

Egypt, January 2020

Introduction

In Tunisia, a nation that’s more than 3,000 years old and my motherland, ancient building engineers left us the second biggest Roman theater in the world (Al-Jam), the first Islamic university (Al-Zaytoona), and the prestigious Cathedral of St. Vincent de Paul in the heart of the capital, Tunis. They are all beautiful and still functional, and they continuously inspire architects and artists alike. They are civilizational achievements that convey intellectual supremacy, design elegance, and timeless rays of spirituality.

In this book, I try to keep track of my grandparent’s footsteps, and make a modest contribution to the building of Software Civilization, by providing a new learning experience of the art of programming, for a new programming language called Ring…

Ring

Like a beautiful star, Ring shines in the sky of the new generation of programming languages because of its outstanding learnability, expressiveness, and extreme flexibility. The language is remarkably dogma-free and embraces declarative and natural programming in an effective new way. Yet it is a serious tool, with powerful features and extended portability. It is ranked in the top 100 most popular programming languages ( https://www.tiobe.com/tiobe-index/ ) and has been used to develop the PWCT open source visual programming project, which more than 21 million downloads from SourceForge.

The Book

The main goal ofBeginning Ring Programming is to help you gain a gentle yet rigorous introduction to the world of Ring programming with clarity as the first concern, rich visualizations, and a lot of practical code examples.

In this book, Ring is used more as a computational thinking medium than a programming language. Its simple pseudocode-like footprint will help you focus on the underlining logic and ideas instead of the code itself. Its flexible syntax allows anyone, whatever language programming language they use, to feel at home when reading and writing computer code. Several programming paradigms (structured, object-oriented, functional, declarative, natural language, and metaprogramming), all allowed by Ring, are used in combination to compose specific designs to address specific problems in different situations.

Part I shows you how to install Ring and gives you a bird’s-eye view of the language by exploring its features. I explain how Ring rigorously structures programs, and then you’ll learn about the type system of the language by exposing its four native data types (number, string, list, and object) and how you can augment them by crafting your own user-defined types.

Part II is where you will learn how Ring manages inputs, outputs, and what is in between. The basic constructs of computer logic (sequence, selection, and iteration) are used in isolation and then combined to show more complex logic flows. I will discuss real-world scenarios and common mistakes leading to code complexity and present several strategies of refactoring, code cleansing, data modeling, and variable naming. Then, I will explain how Ring deals with the scopes of variables, at the local, object, and global levels.

In Part III, you will master the two conceptual constructs every programmer truly needs: functions and objects. You’ll discover how they can be composed to solve a problem and how more advanced programming paradigms, such as declarative and natural, are beautifully implemented on top of them. Then I will introduce game programming as one of the domain applications of Ring. You’ll learn how you can design a game declaratively, in Ring code, like you were designing it in visual software. Finally, I’ll deliver 30 years of experience in writing code in the form of a gamified Ring-oriented fantasy world called Ringorialand. You’ll learn how much of programming is complex, both technically and socially, and how gaming can be a good metaphor to reign over it.

The book was written over a period of nine months, with a lot of patience, consideration, and love of sharing. It is not intended to be a clinical user manual of Ring, though, but rather a passionate alchemy of technical knowledge, real-world programming experience, and critical personal reflections. So, use it to build your technical programming skills in Ring while developing acultural consciousness of programming from the intellectual conversation it contains between you, the reader, and me, a seasoned programmer questioning today’s code complexity via an emergent programming language that provides elegant and unprecedented answers to those questions.

Beginning Ring Programming is for those who are passionate about the craftsmanship culture in writing code, thinking in code, and solving algorithmic problems in a beautiful, expressive, and learnable programming language. You’ll gain beginner-friendly knowledge about Ring and benefit, at the same time, from a one-stop container of lessons learned and valuable returns on experience, all distilled into real-world, customer-facing programming projects.

What You Will Learn

Specifically, in this book, you will do the following:
  • Get started with the Ring programming language

  • Master data types, I/O, GUI widgets, events, functions, and classes, including how they can be composed

  • Carry out structural, object-oriented, functional, declarative, natural, and metaprogramming with Ring

  • Quickly design professional-grade video games on top of the Ring Game Engine and enjoy a new declarative gaming programming experience with Ring

  • Use the full power of Ring to refactor program code and develop clean and flexible program architectures

  • Deploy visual thinking techniques in pragmatically solving complex algorithmic problems in Ring

  • Embrace the Ring language culture founded on syntax freedom, programmer responsibility, hackable transparency, and dogma-free multiparadigm programming.

Acknowledgments

To Cherihen, Teeba, and Haneen for their love, encouragement, and unbounded sacrifice.

To Mahmoud Fayed, Bert Mariani, and the Apress team (Mark, Matt, and Steve) for their support, patience, and dedication.

To those who inspired and taught me something during my programming career.

Table of Contents
Index 653
About the Author
Mansour Ayouni
../images/485799_1_En_BookFrontmatter_Figb_HTML.jpg

is one of the leading contributors to the Ring programming language. He wrote his first BASIC computer statement in the mid-80s, using only pen and paper, when he was 10 years old. It wasn’t in a California garage, though, or under the lights of the prestigious Eiffel Tower of Paris; it was in the rural village of Regueb in the center of Tunisia (North Africa) where there was no electricity or computers at all. Over the years, programming took him on an otherwise impossible international journey. From Tunisia to Niger to Canada, he contributed to the development of dozens of software applications ranging from lawyer office management solutions to banking to nuclear waste management systems. During his career, he has overseen programmers from three cultures and led software teams in various companies such as Whitecape, Keyrus, and Webgenetics. Now, he is a member of the Ring core team and runs Kalidia Consulting, helping businesses to make effective software.

 
About the Technical Reviewer
Bert Mariani
../images/485799_1_En_BookFrontmatter_Figc_HTML.jpg
has worked on mainframe hardware as a field engineer for Univac and Amdahl, where machine language coding was used to debug and fix hardware problems when the OS would not boot. He supplements his coding skills with Assembler and C Code.

Bert currently resides in Montreal, Canada, where he works for Bell Mobility, helping to migrate 4G technology to 5G. Along with his team, he tests and implements many different types of network equipment from various hardware vendors to support mobile communications and cell phones.

 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.147.215