Hacker News new | ask | show | jobs
by ptx 1270 days ago
> It can be used in the style of simpler languages like Go and is almost as safe as Rust in a much faster manner.

What does this mean, exactly? Usage in the style of Go requires garbage collection and being safe like Rust (without GC) requires a borrow-checker, and as far as I know Free Pascal doesn't have either.

2 comments

A borrow-checker isn't the most practical or the only way to provide safety. For example, a string type can have an offset for creating O(1) string slices and point to a shared counter. That way when mutating the string, it creates a fresh copy iff the counter is bigger than 0.

I am working towards this in https://github.com/planetis-m/cowstrings

Object Pascal has two magic types, dynamic arrays and AnsiStrings. These are automatically reference counted. Objects and classes have to be managed by hand, yes.

In general, expect a lot more compiler magic out of Pascal, a lot of concepts were hacked into the Borland compilers over time.

So, it's closer to C++ wrt safety, not Go or Rust.
That is accurate, yes. Borland C++ and Delphi share the same component library and are interoperable.