The instance is an object and the object is an instance? Then they would be the
same thing?
Yes and no.
On the Wikipedia page itself there are 3 paragraphs that speak the same thing in different ways. It is redundant but they did so to clarify better.
Instances of a class share the same set of
attributes, although they differ in their content.
attributes. For example, the "Employee" class describes the attributes
common to all instances of the "Employee" class. The objects of this
class may be similar, but vary in attributes such as "name"
and "salary". The class description contains the items corresponding to
these attributes and defines the operations or actions relevant to the
such as "wage increase" or "change in the number of
phone. "You can then talk about an instance with the name=" Joan
Rabbit "and another with the name=" João Coelho ".
Instance is the realization of a class. In intuitive terms, a
class is like a "template" that generates instances of a certain type; one
object is something that exists physically and that has been "shaped" in the class.
Thus, in object-oriented programming, the word "instantiate"
means to create. When we talk about "instantiating an object", we create
physical representation of the class. For example:
"animal" is a class or a mold; "dog" is an instance of
"animal" and although it carries all the characteristics of the mold
"animal", is completely independent of other instances of
"animal"
link
// Aqui temos uma classe. Ela ainda não é um objeto.
Class Foo{}
// Aqui criamos um objeto da classe Foo
obj = new Foo
// Repare que não usei o termo "instância" porque esse termo significa "criar". Contudo, não é errado dizer:
// Nova instância de Foo
obj = new Foo
That is, obj
is objeto
instantiated of class Foo
.
Instance (instantiate / create) is an action. The object is a concrete representation, according to wikipedia, physically create (instantiate) a representation of the class .
The definition of what the object is is also very clear and I see no ambiguity:
In computer science, object is a reference to a location in the
memory that has a value. An object can be a variable, function,
or data structure. With the introduction of
objects, the word object refers to an instance of a class.
In object-oriented programming, an object
of a "mold" (class); the class defines the behavior of the object,
using attributes (properties) and methods (actions).
link
It is important to point out that still on the Wikipedia page there is an observation about the term instance.
In object-oriented programming, it is called an instance of a class,
an object whose behavior and state are defined by the class.
"Instance" is, in this case, Anglicism , meaning "case" or
"instance."
Anglicism: link
In order not to complicate matters, I will avoid comment on metaclass because flees rather context of the question. But anyway it's good to know.
The issue is addressed in the Japanese version of "instance" link
静 的 型 付 け の オ ブ ジ ェ ク ト 指向 言語 で は 珍 し い が, 動 的 型 付 け の オ ブ ジ ェ ク ト 指向 言語 の 多 く は, メ タ ク ラ ス を サ ポ ー ト し, ク ラ ス 自 体 も オ ブ ジ ェ ク ト と し て 扱 う こ と が で き る (ク ラ ス · オ ブ ジ ェ ク ト). ク ラ ス · オ ブ ジ ェ ク ト は,端 的 に 言 え ば 変 数 に 束縛 で き る ク ラ ス で あ る. ク ラ ス · オ ブ ジ ェ ク ト, イ ン ス タ ン ス · オ ブ ジ ェ ク ト 双方 を 変 数 に 束縛 し た 際 ど ち ら も オ ブ ジ ェ ク ト と し て 振 る 舞 い 見 か け 上 区別 は つ か な い. 例 え ば ク ラ ス · オ ブ ジ ェ ク ト, イ ン ス タ ン ス · オ ブ ジ ェ ク ト 双方 が
readFrom: と い う メ ソ ッ ド を 持 っ て い た 場合, ど ち ら も #readFrom:
メ ッ セ ー ジ を 送 っ て や る と エ ラ ー も 起 こ さ ず そ れ ぞ れ の メ ソ ッ ド を 実 行 す る.
Objective-C や Python に お い て は ク ラ ス · オ ブ ジ ェ ク ト と イ ン ス タ ン ス · オ ブ ジ ェ ク ト の 明確 な 区別 が 行 わ れ て い る. [3] [4]
メ タ ク ラ ス が サ ポ ー ト さ れ て い る シ ス テ ム で は, ク ラ ス · オ ブ ジ ェ ク ト も ま た 別 の ク ラ ス (メ タ ク ラ ス) の イ ン ス タ ン ス で あ る と い う こ と が あ り う る. こ の 場合 「ク ラ ス · オ ブ ジ ェ ク ト は イ ン ス タ ン ス で は な い」 と は 言 え な い の で, 注意 さ れ た い.
This is a brief warning in which it says not to confuse instances of metaclasses because in metaclasses instances are also classes.
As you can see, we can always complicate things further.