Not just Ada...
Not just Ada...
Posted Apr 25, 2013 12:21 UTC (Thu) by phred14 (guest, #60633)In reply to: Ada should be mentioned when speaking of programming languages on safety by lonely_bear
Parent article: A taste of Rust
Which begs the question... Would it be easier to "make C safe" or to "make Modula-2 or Modula-3 usable"?
I focus on Modula-2/Modula-3 because others have mentioned that Ada has certain deficiencies which ought to be fixed. But Ada is rather rigidly standardized, and though there is a process to eventually change it, that takes time and makes experimentation difficult. Modula-2/Modula3 could make a better test-bed or starting point, recognizing that those would need work, as well. They're also less complex to begin with.
Even the usability argument against the old "safe languages" may have some issues, because while as defined they may not have been usable, most vendors back in the day had significant extensions. Back in the 1980s I used JPI Modula-2 to write a TSR (MSDOS Terminate-and-Stay-Resident, for those who are not fossils like me.) that implemented a reentrant interrupt handler for low-level communications. I also interfaced to a C module for (at the time) high-performance graphics, and both read and wrote legacy binary data files. It could be done, and it wasn't that hard.
Posted Apr 25, 2013 14:55 UTC (Thu)
by viro (subscriber, #7872)
[Link] (1 responses)
Posted Apr 25, 2013 18:44 UTC (Thu)
by phred14 (guest, #60633)
[Link]
Admittedly once you're messing with the stack frame, which I was with the interrupt handler, you've kind of unlocked the doors for the dragons, too. But I only played with the stack frame in that one example, knew it was a very risky thing, and tried to use extra care.
Posted Apr 25, 2013 17:13 UTC (Thu)
by Cyberax (✭ supporter ✭, #52523)
[Link] (4 responses)
Posted Apr 25, 2013 18:31 UTC (Thu)
by rahulsundaram (subscriber, #21946)
[Link]
Posted Apr 26, 2013 14:55 UTC (Fri)
by ibukanov (subscriber, #3942)
[Link] (2 responses)
Posted Apr 26, 2013 22:20 UTC (Fri)
by neilbrown (subscriber, #359)
[Link] (1 responses)
The thread-local heap is managed, though they currently use reference counting rather than mark/sweep garbage collection. That might change.
The thread-shared heap is not reference counted. The compiler tracks references of which there may only be on primary reference and possibly several borrowed references that can only exist within the scope of the primary reference. When the primary reference is dropped, the object is freed. No counting.
Posted Apr 26, 2013 23:18 UTC (Fri)
by ibukanov (subscriber, #3942)
[Link]
You are right, the ownership is fully tracked with the compiler.
> The thread-local heap is managed, though they currently use reference counting rather than mark/sweep garbage collection.
It is reference counting plus a cycle collector. For practical purposes it is just a form of GC with different trade-offs compared with a mark and sweep case. In Rust the reference counting allowed for simpler compiler implementation as one does not need to track the native register and stack roots. Plus for non-cyclic cases the garbage is collected faster. But when the cycle collector runs, it runs much slower than a mark-and-sweep due to significantly more complex algorithm.
Not just Ada...
Not just Ada...
Not just Ada...
Not just Ada...
Not just Ada...
Not just Ada...
Not just Ada...