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.
Performance vs Programming Effort between Rust and C on Multicore Architectures: Case Study in N-Body
历史上,Fortran和C一直是高性能计算(HPC)中的默认程序设计语言。在这两种情况下,程序员都可以使用原语和函数来操纵系统内存并直接与底层硬件交互,从而在响应时间和资源使用方面实现高效的代码。另一方面,在这些类型的语言中生成可维护和可扩展的代码是一个真正的挑战。2010年,Rust作为一种为并发和安全应用程序设计的新程序设计语言出现,它采用了过程式,面向对象和函数式语言的特性。在其设计原则中,Rust的目标是在效率方面与C相匹配,但同时提高代码安全性和生产力。本文介绍了C和Rust在性能和编程工作方面的比较研究,选择作为案例研究的N个计算体(N-Body),在HPC社区的一个流行的问题的模拟。基于实验工作,可以确定Rust是一种减少编程工作量的语言,同时保持可接受的性能水平,这意味着它是C for HPC的可能替代品。