Hacker News new | ask | show | jobs
by slt2021 1270 days ago
I learned programming at school in Pascal and didn't have troubles with memory safety. FreePascal/Delphi has good standard library to work with strings and dynamic arrays and objects, and as long as you follow very simple convention with TObject.Create() and TObject.Free; you won't have memory safety problems.

I didn't really have a need to work with pointers and do pointer math in Pascal, because language itself provided facilities to work with heap objects safely.

Also standard Pascal compiler added array bounds safety and many other checks, and you would easily find these errors during program execution (there wont be a silent exception).

Also because Pascal compiler is LL(1) single pass compiler, you could easily do a cycle of: edit code, compile (<1 second on 333Mhz Pentium-II), and run.

That compiler enabled developer experience of like modern Python/Javascript

Unlike C++ which spent enormous time evaluating macros, compiling, linking, etc

1 comments

> as long as you follow very simple convention with TObject.Create() and TObject.Free; you won't have memory safety problems

Is this the same as how in C, as long as you follow very simple convention with malloc() and free() you won't have memory safety problems?

not only that, Object pascal has very nice way of separating code and avoiding globals, and variables were constrained within certain scope. Each module is compiled independently and no macro hell.

if you were to pass reference around, then compiler would warn about potentially dangerous Free.

I don't remember ever seeing Pascal code where you received raw pointer and then directly casted it to your object type for example. Pascal has very powerful and expressive type system