[1] - As usual, there are many ways of doing OO, not just C++/Java style.
[1] - As usual, there are many ways of doing OO, not just C++/Java style.
Not at all, objects need to be explicitly allocated on heap, otherwise they are value based.
I took care not to list any language that only allows objects as references.
Object Pascal was created by Apple for Lisa and Mac OS, with collaboration from Niklaus Wirth.
Borland then adopted it to Turbo Pascal 5.5 for MS-DOS.
Turbo Pascal 6.0 and 7.0 for MS-DOS, followed by Turbo Pascal 1.0 and 1.5 for Windows 3.x took up ideas from C++.
Borland then rebooted Turbo Pascal with Delphi, but to avoid creating too much confusion among Pascal developers, they kept calling their dialect Object Pascal, even though they completly rebooted the object model.
This is how you declare objects in Object Pascal.
type
PTPoint = ^TPoint;
TPoint = object
x: Integer;
y: Integer;
end;
var
valuePointOnGlobalMemory: TPoint;
valuePointOnTheHeap: PTPoint;
begin
{Can use it right away}
valuePointOnGlobalMemory.x := 10;
valuePointOnGlobalMemory.y := 20;
{Need to heap allocate first}
New(valuePointOnTheHeap);
valuePointOnTheHeap^.x := 10;
valuePointOnTheHeap^.y := 20;
Dispose(valuePointOnTheHeap);
{....}
end.
Easy to test with Free Pascal using Turbo Pascal compatibility mode.Delphi 1.0 was about the time I started focusing on C++, so I am not that knowledgeable about its features. Just remembered that was one of the key changes.
There isn't "The ONE true OOP way", just like there isn't "The ONE true FP way" or "The ONE true LP way".
Each paradigm has a set of concepts of what they might mean, and many languages cherry pick from there.
Rust and Go implement polymorphism via traits and interfaces respectively.
Rust and Go implement encapsulation via struct methods and modules.
Rust and Go implement containment.
Rust and Go allow for delegation.
Rust allows for type extensions via a mix of generics and traits.
Go allows for struct embedding as a kind of type extension.
Class based inheritance is not a requirement for a language to be OO.
CS literature is full of languages that explored other kinds of OO.