2 ms·
Because it is, even if not perfect. Sure, you still get use-after-free and manually memory management, which does not hold folks to now race into rewriting stu
by pjmlp 2y ago
Because it is, even if not perfect.
Sure, you still get use-after-free and manually memory management, which does not hold folks to now race into rewriting stuff in Zig.
However it gets you covered on:
- proper strings with bounds checking
- proper arrays with bounds checking
- no pointer decays, you need to be explicit about getting pointers to arrays
- less use cases of implicit conversions, requires more typecasts
- reference parameters reduce the need of pointers
- variant records directly support tags
- enumerations are stronger typed without implicit conversions
- modules with better control what gets exposed
- range types
- set types
- when using COM like interfaces, reference counting
- arenas
Sure C++ also covers some of that, that is why I went C++ after Turbo Pascal, but too many folks still use C like idioms instead of improved C++ ones, it is like adopting TypeScript, but still write JavaScript instead.
EDIT: typo, missing not
- chadcmulligan 2y agoVery true. If you include FastMM in your project use-after-free is trapped along with other memory errors. I find the allocate / try / finally / free paradigm in Delphi makes things easier, it just becomes a habit. eg var obj := TMyObject.Create try ...do stuff finally obj.free //(or for bonus points freeandnil(obj)) end;