3 ms·
I'm not sure what point you're trying to make. Do you think Object Pascal is as good as Rust?
by IshKebab 2y ago
I'm not sure what point you're trying to make. Do you think Object Pascal is as good as Rust?
- pjmlp 2y agoNope, but definitly better than C in regards to safety in systems programming.
- bawolff 2y agoThat's a pretty low bar. What would be less safe than c?
- pjmlp 2y agoAnd yet here we stand, still not having it replaced at scale. To quote Hoare in 1980, "A consequence of this principle is that every occurrence of every subscript of every subscripted variable was on every occasion checked at run time against both the upper and the lower declared bounds of the array. Many years later we asked our customers whether they wished us to provide an option to switch off these checks in the interests of efficiency on production runs. Unanimously, they urged us not to--they already knew how frequently subscript errors occur on production runs where failure to detect them could be disastrous. I note with fear and horror that even in 1980 language designers and users have not learned this lesson. In any respectable branch of engineering, failure to observe such elementary precautions would have long been against the law." ===> I note with fear and horror that even in 1980 language designers and users have not learned this lesson. Referring naturally to C, by the way 1988 is the birth year of the Morris Worm, taking advantage of C's buffer management capabilities. Yes, a pretty low bar that 40 years after those events is still largely used across the industry. And the copy paste compatibility of Objective-C and C++ with C doesn't help, because even though those languages provide better capabilities and safer alternatives than writing raw C, there are always those folks that will write C style code no matter what.
- pdimitar 2y ago> And yet here we stand, still not having it replaced at scale. Network effects and business' risk aversion. Nothing to do with technical superiority / inferiority really. The MBAs only hear "we must replace everything from scratch" and immediately shout "NO!". Offensively simple I am afraid. That's all there is to it. Believe me, I'd jump with joy if we scrap like 75% of all UNIX crap, especially "untyped text rulz" in the terminal -- and introduce one good terminal protocol in the process. But it ain't happening in yours and my lifetime.
- pjmlp 2y agoMost likely so, and that also applies to most Rewrite in Rust attempts, sadly.
- pdimitar 2y agoObviously. Anything that's being done without some analysis is downright dumb, RIIR included. Though to me it seems that a good percentage of those efforts will improve a general area. Still your point stands.
- timbit42 2y agoAssembly.
- chadcmulligan 2y agoFun Fact - The NSA / White House regards Delphi (object Pascal) as a memory safe language - https://blogs.embarcadero.com/is-delphi-a-memory-safe-language https://blogs.embarcadero.com/is-delphi-a-memory-safe-langua... in preference to C/C++. Not sure I agree, but I bow to their authority.
- pjmlp 2y agoBecause 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;