Objects & Thinking in Models
From data to meaning
So far, we have worked with:
-
Variables (single values)
-
Arrays (lists of values)
-
Conditions and loops (logic)
But something is still missing.
In real life, we don’t think in numbers and strings.
We think in things.
-
A person
-
A student
-
A product
-
A message
-
A file
Programming becomes truly powerful when we stop thinking in data
and start thinking in models.
This is where objects come in.
1. What is an object? (in human terms)
An object is simply:
A thing that has properties and actions
For example, a person has:
-
a name
-
an email
And a person can:
-
introduce themselves
-
display their information
This idea exists everywhere — even outside programming.
GTLang supports objects in a very lightweight and friendly way
2. Creating your first class (a model)
A class is a template for creating objects.
In GTLang, classes start with the ^ symbol.
A simple class: Human
Read it like this:
A Human has a name
A Human has an email
A Human can print its information
No theory required.
3. Creating an object from a class
Now let’s create a real object.
Output:
You didn’t “instantiate a class”.
You simply created a person.
That mental shift matters.
4. Constructors – Giving life at creation
Often, we want to provide data at the moment an object is created.
GTLang automatically supports constructors based on class properties.
Create an object like this:
The ?>> means:
“The object that was just created”
Simple, practical, no ceremony.
5. Thinking in models, not code
This is the most important lesson of this part.
Instead of asking:
“How do I write this code?”
Ask:
“What thing am I modeling?”
For example:
-
A Student is a Human with a score
-
A Task has a title and a status
-
A Message has content and a sender
This mindset makes programming easier and cleaner.
6. Inheritance – Reusing ideas naturally
In real life:
-
A student is a human
-
A teacher is a human
GTLang expresses this naturally using <<.
Student inherits Human
Create a student:
Output:
You didn’t copy code.
You extended a model.
7. Public vs private (boundaries matter)
Not everything should be accessible.
GTLang supports private properties.
Now:
-
$nameis public -
$emailis protected inside the object
This mirrors real life:
You may know someone’s name,
but not their private information.
8. Objects without classes (yes, really)
Sometimes, you don’t want to design a full model.
GTLang allows converting arrays into objects.
Output:
This is perfect for:
-
Fast scripts
-
API responses
-
Temporary data models
No overengineering.
9. Real example – Modeling a task
Let’s build something practical.
Create tasks:
Output:
This is real modeling, not academic OOP.
10. Why GTLang objects feel different
Many languages teach objects like this:
-
Theory first
-
Rules first
-
Syntax first
GTLang does the opposite:
-
Meaning first
-
Models first
-
Ideas first
You are not learning “OOP”.
You are learning how to describe the world in code.
Final thoughts – Programming is modeling reality
Good programs are not about clever syntax.
They are about clear models.
If you can describe a thing:
-
what it is
-
what it has
-
what it can do
Then you already understand objects.
GTLang simply makes that understanding visible.
In the next part, you can explore:
-
Working with files
-
Small automation scripts
-
Building a complete mini project
-
Turning GTLang into a real tool
Slow down.
Think in models.
Enjoy the process — like green tea ☕🌱
