News for hackers. Stuff that matters.
Re:Lazarus – A Delphi-compatible cross-platform IDE by tigershark on Wednesday August 09, 2017 @11:27PM (#14976079)
No GC is actually an advantage? The world really changed, there are people rejoicing for procedural languages, while we have so many excellent OO and FP alternatives, and they are actually happy to shoot their own foot with manual memory management. I'm not really sure that the change has been for the better.
Re:Lazarus – A Delphi-compatible cross-platform IDE by klipt on Thursday August 10, 2017 @12:47AM (#14976477)
Lazarus is Object Orientated. Delphi definitely offers garbage collection in newer versions, not sure about Lazarus.
Re:Lazarus – A Delphi-compatible cross-platform IDE by undreren on Thursday August 10, 2017 @01:43AM (#14976790)
No. Delphi offers reference counting, but only on interface variables. It's a huge difference really, because if your last interface variable that points to an object goes out of scope, the object is freed from memory. Even if you have raw class pointers to it.

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.
Re:Lazarus – A Delphi-compatible cross-platform IDE by pjmlp on Thursday August 10, 2017 @05:30AM (#14977977)
For those lacking CS background, reference counting is an GC algorithm.

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.

Re:Lazarus – A Delphi-compatible cross-platform IDE by zerr on Thursday August 10, 2017 @07:03AM (#14978449)
Formality aside, it's about deterministic GC vs nondeterministic GC.
Re:Lazarus – A Delphi-compatible cross-platform IDE by pjmlp on Thursday August 10, 2017 @07:25AM (#14978560)
Reference counting isn't deterministic in the presence of large complex data structures.

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.

https://www.youtube.com/watch?v=JfmTagWcqoE

Re:Lazarus – A Delphi-compatible cross-platform IDE by TimJYoung on Friday August 11, 2017 @02:51PM (#14992998)
You would never code the SomeMethod like that, you would use this instead:

    var
        LObj: IMyInterface;
    begin
        LObj := TMyClass.Create;
        DoTheFoo(LObj);
        LObj.Foo;
    end;
Re:Lazarus – A Delphi-compatible cross-platform IDE by klipt on Thursday August 10, 2017 @02:05AM (#14976894)
Oh, in that case that's no better than C++'s shared_ptr.

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...

Re:Lazarus – A Delphi-compatible cross-platform IDE by undreren on Thursday August 10, 2017 @02:54AM (#14977105)
I actually feel that shared_ptr is a better fix, because that makes the memory handling consistently opt-in, instead of inconsistent.
Re:Lazarus – A Delphi-compatible cross-platform IDE by MageSlayer on Thursday August 10, 2017 @05:19AM (#14977920)
I highly doubt it's production code. Nobody uses both objects(pointers) and interfaces simultaneously. It's a quick way to disaster. In practice Delphi/FPC interfaces serve their purpose.
Re:Lazarus – A Delphi-compatible cross-platform IDE by Jack4E4B on Thursday August 10, 2017 @05:52PM (#14984670)
Swift also does Reference counting, the difference is huge. Speed of code is in another level. I am new to Lazarus, but I am guessing they do the same as Delphi.