3 ms·
You might be interested in this thread from a year ago, where we discussed memory management in Ada. [0] The Ada folks sometimes seem a bit quiet on memory-man
by MaxBarraclough 5y ago
You might be interested in this thread from a year ago, where we discussed memory management in Ada. [0]
The Ada folks sometimes seem a bit quiet on memory-management questions, a bit like the way Forth folks rarely talk about the real-world performance of Forth interpreters. On the plus side, borrower-checking is coming to SPARK. [1][2]
[0] https://news.ycombinator.com/item?id=24361992 https://news.ycombinator.com/item?id=24361992
[1] https://www.adacore.com/papers/safe-dynamic-memory-management-in-ada-and-spark https://www.adacore.com/papers/safe-dynamic-memory-managemen...
[2] https://arxiv.org/abs/1805.05576 https://arxiv.org/abs/1805.05576
- InfiniteRand 5y agoOne thing to keep in mind in Ada is the "typical" Ada programmer lives in embedded world, where memory needs to be deterministic. It's a very different perspective from say "desktop-application" world where dynamically allocating memory is just a natural part of programming.
- mcculley 5y agoI get that. I just keep seeing Ada recommended for projects other than embedded systems and I don’t see how it can work.
- MaxBarraclough 5y agoI'm not especially knowledgeable about Ada, but looking at the docs for GtkAda, it seems they're able to do reference-counting with good ergonomics. https://docs.adacore.com/live/wave/gtkada/html/gtkada_ug/memory.html https://docs.adacore.com/live/wave/gtkada/html/gtkada_ug/mem...
- pyjarrett 5y agoI found it a lot easier than I thought it would be. Ada has RAII (controlled types) which you can use for reference counting and resource management like in C++. Septum uses a lot of dynamically allocated memory, but it's all hidden by smart pointers or Unbounded_String (built-in reference-counted COW strings). I use it routinely to search codebases in the tens of millions of lines and it's fast enough right now (single second search times) due to task parallelism I did in Ada that I haven't even bothering to tune it or do any fancy indexing yet.
- MaxBarraclough 5y agoPresumably that means you're vulnerable to issues with reference cycles?
- pyjarrett 5y agoIn theory, yes, I'm vulnerable to reference cycles, but I haven't run into this in practice. The GNAT smart pointer types supports weak pointers if I need it.
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]