HackerPapers

arXiv:1803.02796cs.PL

Resource Polymorphism

Guillaume Munch-Maccagnoni

Abstract

We present a resource-management model for ML-style programming languages, designed to be compatible with the OCaml philosophy and runtime model. This is a proposal to extend the OCaml language with destructors, move semantics, and resource polymorphism, to improve its safety, efficiency, interoperability, and expressiveness. It builds on the ownership-and-borrowing models of systems programming languages (Cyclone, C++11, Rust) and on linear types in functional programming (Linear Lisp, Clean, Alms). It continues a synthesis of resources from systems programming and resources in linear logic initiated by Baker. It is a combination of many known and some new ideas. On the novel side, it highlights the good mathematical structure of Stroustrup's "Resource acquisition is initialisation" (RAII) idiom for resource management based on destructors, a notion sometimes confused with finalizers, and builds on it a notion of resource polymorphism, inspired by polarisation in proof theory, that mixes C++'s RAII and a tracing garbage collector (GC). The proposal targets a new spot in the design space, with an automatic and predictable resource-management model, at the same time based on lightweight and expressive language abstractions. It is backwards-compatible: current code is expected to run with the same performance, the new abstractions fully combine with the current ones, and it supports a resource-polymorphic extension of libraries. It does so with only a few additions to the runtime, and it integrates with the current GC implementation. It is also compatible with the upcoming multicore extension, and suggests that the Rust model for eliminating data-races applies. Interesting questions arise for a safe and practical type system, many of which have already been thoroughly investigated in the languages and prototypes Cyclone, Rust, and Alms.

arXiv comments
62 pages
Journal reference
DOI
Subjects
cs.PLProgramming Languages cs.LOLogic in Computer Science

On Hacker News

Linked by 3 identifiable commenters in 4 comments across 4 threads, from Dec 2018 to Dec 2021. Found in 1 HN submission from Mar 2018 to Mar 2018. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments4 threads

    • Garbage collection and controlled object lifetimes are important and orthogonal concerns. You can have both at the same time. C# for instance lets you add a Dispose() method for the times when you want to free the resources now. There are even ways to ensure statically that…

      rwmjView on HNParent context

  1. Linear types are merged in GHC 1 comment
    • Yes to almost all of that. The proposal process has exhausted me, but I suppose I will write it again, since your questions there serve as excellent section headings :). > Do you think the feature is not going to be very useful in a practical setting? Yes. For one example, you…

      Ericson2314View on HNParent context

    • https://arxiv.org/abs/1803.02796 has a good intro referencing other work. The paper doesn't go into much detail on the borrow checking side of things, but that author is both thoroughly steeped in the linear types research tradition and knows Rust and mentions it a bunch. The…

      Ericson2314View on HNParent context

    • > and all GC enabled system programming languages do offer multiple ways to manage memory. Since "GC-enabled system programming languages" is an oxymoron, a claim about what such languages may or may not include is just not very useful. But it's definitely the case that properly…

      zozbot123View on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.