Lazarus is Object Orientated. Delphi definitely offers garbage collection in newer versions, not sure about Lazarus.
Example:
IMyInterface = interface
procedure Foo;
end;
TMyClass = class(TInterfacedObject, IMyInterface)
procedure Foo;
end;
procedure TMyClass.Foo;
begin
WriteLn('Foo');
end;
procedure DoTheFoo(AObj: IMyInterface);
begin
AObj.Foo;
end;
procedure SomeMethod;
var
LObj: TMyClass;
begin
LObj := TMyClass.Create;
DoTheFoo(LObj);
LObj.Foo; // <-- Will cast nil pointer exception,
// as object was freed when AObj in DoTheFoo went
// out of scope
end;
I work with Delphi in my day job.I remember Delphi being fun back in the day and it still compiles way faster than C++, but C++ is evolving and maybe with modules even the compilation speed gap will disappear...
The 5th chapter from "The Garbage Collection Handbook", http://gchandbook.org/, one of the most renowned books in the field, there are of course other equally renowned sources I can refer to.
You will know when memory gets deleted, but not how long it will take, nor how much stack space the destructors will require to run.
Enjoy Herb Sutter's "Leak-Freedom in C++... By Default." at CppCon 2016, where he explains how those issues affect C++ and goes on to implement a tracing GC.
var
LObj: IMyInterface;
begin
LObj := TMyClass.Create;
DoTheFoo(LObj);
LObj.Foo;
end;