Loading a substet of RingQt classes

58 views
Skip to first unread message

Mansour Ayouni

unread,
Jul 20, 2024, 7:53:19 AM (2 days ago) Jul 20
to The Ring Programming Language
Hello Mahmoud,

Softanza startup time takes 0.10 seconds on my machine, half of which is taken by loading the lightweight version of RingQt.

Actually I use only a small number of Qt classes in Softanza (about 10). How can I gather them from RingQt, put them in a dedicated Ring file, and load them when Softanza starts without loading all the other RingQt classes?

All the best,
Mansour

MOHANNAD ALDULAIMI

unread,
Jul 20, 2024, 8:47:11 AM (2 days ago) Jul 20
to The Ring Programming Language
Hello Mansour ,
I am pleased to help you with some ideas and information that I gained from my personal experience.

  steps are:
1-create ".pro" file.
2-link it with ringqt cpp files.
3-create build ".bat" file.
4- build it.

crsate ".pro" just copy a ring ".pro" file and edit it,
ask chatGPT to create/modify the file according to the classes that you USED…
at the "SOURCES,HEADERS"  in the. pro file load the classes and headers files of the required CLASSES…

after all this steps done finally copy the "buildvc.bat" and edit it to make
   jom.exe find your. pro file
jom.exe is in qtcreator FOLDER…
Good news the build is DONE…
the bad news, for every version of ring you need to re build IT…

after all this done, now you need to create your custom ring file that will load the dll file ,
copy/paste the ring classes code that you want from this path:
RING_PATH/libraries/guilib/classes/ring_qt.ring

know you should load this file and achieve this custom qt classes...:D

I know it looks like hard but it is easy everyone can do IT…

important notes that you have to install msvc (Visual studio) and QT 5.15 on you machine

Finally I can help you for creating files if you give me you qt classes that you are use...:D

Best wishes…
Mohannad

Mansour Ayouni

unread,
Jul 20, 2024, 9:01:23 AM (2 days ago) Jul 20
to MOHANNAD ALDULAIMI, The Ring Programming Language
Hello Mohannad,

Thank you very much for your answer and willingness to help!

I thought there should be a simpler solution by just copying the same classes generated already by RingQt and using them...

Anyway, I'll wait for Mahmoud's opinion and let you know.

All the best,
Mansour


--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/9f76d5f5-af37-42ec-ad3b-e5a208cf6bdfn%40googlegroups.com.

Mahmoud Fayed

unread,
Jul 20, 2024, 12:29:25 PM (2 days ago) Jul 20
to The Ring Programming Language
Hello Mansour, Mohannad

Mohannad already answered the question

RingQt provide the ability to build it through one of the next three options
1 - Using RingQtCore 
2 - Light GUILib (QtCore, QtGui & QtWidgets)
3 - GUILib (Supported Qt classes)

And you will find different Qt project files (*.pro) and different batch files (*.bat) to build each project

In configuration files we determine the required classes like this file

But before investing time in this task, my suggestion (DON'T DO IT)
This is over optimization (Not Necessary) and could lead to conflict with projects that uses RingQt if it's not done correctly

For web projects that need to avoid startup time (per request), use a web server written in Ring or write a web server extension to avoid CGI.

What you really need to do is separating very large classes (like the String class that have over 14,000 methods) to different classes.
Each time Ring compiler found a Ring method definition, it will search in previously defined methods to provide (method redefinition error) when this happens, so a class with 14,000 methods trigger 14,000 search operation in a list of (previously defined methods) 

To see how this has an impact on compile-time performance  (And startup time) 
Try
ring stzlib.ring -clock -norun
This operation consumes five and half seconds (5.5s) on my machine!
This is huge time!

using ring stzlib.ring -go -norun
then ring stzlib.ringo -norun -clock

Will reduce this to 1 second

I have PWCT2 which is a large project (like SoftanzaLib) and it compiles ring files in 1 second because it doesn't have these huge classes (over 90,000 lines of code in one class)

Of course, we can solve the problem at Ring Compiler level and provide custom options to disable some compile feature and have the same compiler speed at SoftanzaLib, but the right thing to do is revising  SoftanzaLib architecture itself.

Another way to solve the problem of huge classes (without changing your design and keeping all of the methods in the same class)
Is to separate the class to different files (where each class have some related methods)
Then use MergeMethods to merge methods from different classes in one class
And you could provide customization to the users to pick which methods they want in their string class


SoftanzaLib is GREAT WORK (Piece of Art) - but separating very huge classes to smaller classes will lead to better results. 

Greetings,
Mahmoud

Mansour Ayouni

unread,
Jul 20, 2024, 12:41:53 PM (2 days ago) Jul 20
to Mahmoud Fayed, The Ring Programming Language
Hello Mahmoud,

Thank you very much for this instructive answer. I better understand now your remarks about the size of Softanza classes.
As I told you before, it is in my plan to refactor them and make them smaller and more adaptable to programmers' needs.
This will be the first thing I'll do right after closing this release!

Regarding AddAttribute, is this reasonably efficient from a performance point of view?

Best,
Mansour


--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.

Mahmoud Fayed

unread,
Jul 20, 2024, 1:11:17 PM (2 days ago) Jul 20
to The Ring Programming Language
Hello Mansour

>> "Regarding AddAttribute, is this reasonably efficient from a performance point of view?"

It works at the object level and works at performance level similar to adding items to a list where the added item is a list representing the attribute and contains the attribute name, type & value.

In most cases, You shouldn't worry about performance until it becomes a problem, at this time we measure to find the bottleneck then optimize it.

Also, the AddAttribute() function support adding many attributes at the same time which is faster than adding each attribute one by one

Greetings,
Mahmoud

Mahmoud Fayed

unread,
Jul 20, 2024, 2:28:22 PM (2 days ago) Jul 20
to The Ring Programming Language
Hello Mansour

I have already updated Ring Compiler to reduce the startup time for projects similar to SoftanzaLib (That have huge classes)
Where we use (HashTable) to check function redefinition - Instead of the slow linear search.


Now using
ring stzlib.ring -clock -norun
will consume ( 1.3 second ) instead of ( 5.5 seconds) on my machine

Greetings,
Mahmoud

Mansour Ayouni

unread,
Jul 20, 2024, 11:01:11 PM (2 days ago) Jul 20
to msfcl...@gmail.com, ring...@googlegroups.com

Hello Mahmoud,

This is a very nice news I start my day with!

Thank you and keep letting Ring be the langage that care about us.

The user-centered culture you embrace in this project is one of its main strengths.

During this SoftanzaLib project, I feel that Ring works hand in hand with me, and not against me, like it was the case in other languages I tried before.

All the best.
Mansour


Mahmoud Fayed

unread,
Jul 21, 2024, 2:25:07 AM (yesterday) Jul 21
to The Ring Programming Language
Hello Mansour

>> "This is a very nice news I start my day with!"

Happy new day to you :D

>> "Thank you and keep letting Ring be the language that care about us."

You are welcome :D

>> "The user-centred culture you embrace in this project is one of its main strengths."

We will do our best to push the project forward for everyone looking for a beautiful programming language 

>> "During this SoftanzaLib project, I feel that Ring works hand in hand with me, and not against me, like it was the case in other languages I tried before."

I see the real art at the heart of SoftanzaLib, and I am happy that the project is going forward
Keep up the GREAT WORK :D

Greetings,
Mahmoud

Bert Mariani

unread,
Jul 21, 2024, 10:21:26 AM (23 hours ago) Jul 21
to The Ring Programming Language
Hello Mansour



RE: <<< Softanza ... very large classes (like String class that have over 14,000 methods) to different classes >>>

Just to put things into perspective.
I speak some Chinese and can read some rudimentary text from my friends.
Learning to read more than 200 characters was a struggle

常用字(cháng yòng zì) Basic Chinese characters total number is around 2500, and 
最常用字(zuì cháng yòng zì) the most common Chinese characters total number is around 500
There are only about 400 Chinese phonetic syllables, and these 400 cover thousands of characters.

NOTE:  Pin-Yin uses the Latin alphabet to express the Mandarin characters to it's easily readable.
It is how they teach young students in school to learn the thousands of Mandarin characters.
There is no clue to the sound of the word in Chinese characters.

My point being that the Number of Methods in Softanza is  5-6 X  more than Basic Chinese characters !!
Who is going to remember all these methods ?
I think you should have a very small basic set that covers what is necessary.

Look at Ring documentation, chapter on Strings,  there are only 18 basic commands.
Enough to accomplish what is necessary.

Best Regards
Bert Mariani



Mansour Ayouni

unread,
Jul 21, 2024, 2:17:00 PM (19 hours ago) Jul 21
to Bert Mariani, The Ring Programming Language
Hello Bert,

Let's break the problem down into its basic components.

There are over 14,000 methods in stzString, not 17,000. Of these, more than 3,000 are actually functions, not methods. These functions are designed to accelerate the use of some methods. For instance, @Len(str) serves as an enhancement to the Ring len() function for non-Latin strings and calls StzStringQ(str).NumberOfChars() in the background.

This leaves over 11,000 methods. Softanza is designed to meet different needs, requiring a unique mindset. One notable aspect is the readability of Softanza code by language models (LLMs) and their ability to quickly learn its syntax and semantics. This led me to provide multiple alternative names for each function. In machine learning workflows, this is called "labeling," a crucial step in designing intelligent models.

On average, there are 10 alternative names for each Softanza method. Dividing the 11,000 methods by 10 gives us about 1,100 unique methods. If we feed all the stzString class code to ChatGPT and ask it to identify the categories of features covered, we get around 20 distinct domains within the text processing field (refer to the attached document). This results in approximately 50 methods per domain, which is a very logical number.

On another scale, if we consider the file size of over 90,000 lines of code (LOC) and divide it by the number of classes, approximately 11,000, we get an average of less than 10 lines of code per function. This is the true metric for qualifying the codebase. You can verify this by reading the code on GitHub; the vast majority of functions are indeed that concise.

Regarding memorability, I have previously mentioned that these functions are designed to be forgotten. The programmer thinks in natural terms, and because Softanza is so intuitive and can handle most of the terminology used, what the programmer writes is often what Softanza understands and executes.

Finally, at the most basic level, if one needs to learn some functions, there is a simple model I developed in the design of the library. It consists of just a dozen functions that can perform any feature provided by Softanza. Refer to the attached diagram for this model, and I will elaborate on it in another post.

I hope this clarifies everything.


All the best,
Mansour

stz-functional-coverage.png
stz-model.bmp

Mahmoud Fayed

unread,
Jul 21, 2024, 2:55:18 PM (19 hours ago) Jul 21
to The Ring Programming Language
Hello Mansour

Bert message is about (Size, Learning-Curve and Documentation) which is an important factor for other to learn any new library

Add to this another important thing related to the library development itself which is (TESTING)
Testing huge software is not easy, requires long time and big effort
Imagine how many automated tests that you need to continue updating/developing the library without breaking other code.

Greetings,
Mahmoud

Mansour Ayouni

unread,
Jul 21, 2024, 4:10:36 PM (17 hours ago) Jul 21
to Mahmoud Fayed, The Ring Programming Language
Hello Mahmoud,

I did my best to address the concerns about the size and learnability of the library, which I am very aware of. The five-step mental model for using Softanza was motivated by your feedback, especially from Bert, when you first discovered the library. I created this model to provide a strong response to the learnability requirements that I knew would be raised by any user. It took a lot of thought and numerous refactorings to reorganize the library around this model.

Regarding documentation, there are extensive narrations and hundreds of thousands of examples (over 30,000 lines of code for stzString alone) explaining every aspect of the library. Some of these are detailed tutorials. However, all this information needs to be consolidated into a comprehensive online help system, which I plan to work on after the V1 release.

Lastly, testability has been a major focus from the very beginning. I usually write tests before writing the functions that implement them. This process should be automated, and it will be relatively easy to do since I use a specific syntax (/* to start the test region, #--> to indicate input, #!--> to indicate an error, etc.) in all the test files.

Softanza has been a grand challenge for me on many levels, but your help as a community and your constructive feedback have been invaluable.

Sincerely,
Mansour

Mahmoud Fayed

unread,
Jul 21, 2024, 7:04:18 PM (15 hours ago) Jul 21
to The Ring Programming Language
Hello Mansour

Thank you very much 
Keep up the GREAT WORK :D

Greetings,
Mahmoud

Reply all
Reply to author
Forward
0 new messages