Article Preview
Top1. Introduction
One can distinguish four main programming paradigms: imperative, object-oriented, functional and logic. In this research, the focus is on imperative and especially functional programming, and more precisely between the two (see below). While imperative programming with languages such as the C and Pascal language remains mainstream, functional programming, whose importance has been acknowledged for decades (Hughes, 1989), has seen an increased interest in recent years (Bossard and Kaneko, 2019): the new versions of programming languages of the imperative and object-oriented paradigms feature mechanisms that are derived from functional programming. For example, JavaScript now provides the Array.prototype.map method (Terlson, 2018) and C++17 the std::apply function (ISO/IEC JTC 1/SC 22, 2017). As mentioned above, functional programming is at the centre of this work. With this programming paradigm, the program logic takes precedence over the control of the program execution: we say that functional programming is declarative. As a result, tracking the state of the program and tracing its execution is challenging for the programmer. And especially with functional languages that feature lazy evaluation.
In this paper, we take on this issue by proposing a programming paradigm – and an implementing programming language – that features “instructions” executed in a sequence in an imperative programming style manner (thus comparable to a program in the assembly language), but, importantly, with these instructions being pure functions in order to retain the referential transparency advantages of pure functional programming. This proposal is named “sequence of functions” (SOF).
In addition, thanks to this approach based on a sequence of instructions, we project to facilitate the parallel execution of functional programs, for example when data are to be disseminated across the interconnection network of a massively parallel system such as the torus network binding RIKEN’s Supercomputer Fugaku (Bossard and Kaneko, 2020). This issue is indeed notorious (Ahn and Han, 2000).
The proposed programming paradigm and language stay purposefully simple, in a way that may remind the reader of a Reduced Instruction Set Computer (RISC) approach (Patterson and Ditzel, 1980), a technology which is used for example by the aforementioned Supercomputer Fugaku – it is equipped with ARM computing nodes (RIKEN, 2020) – and which may be deemed the future given its ecological friendliness (green computing) (Aroca and Gonçalves, 2012).
SOF designates at the same time a programming paradigm and a sample implementation of this paradigm, that is a programming language. The SOF approach positions itself between the imperative and functional paradigms, as shown in Figure 1. Note that this paper is an extended version of Bossard (2020): it significantly clarifies the SOF proposal, for instance by situating this new paradigm in the context of the existing ones, concretely describes the realisation of a SOF compiler and conducts thorough experimental evaluation whose results are subsequently discussed. These are the main, and major, differences with Bossard (2020).
Figure 1.
Position of the SOF approach with respect to other programming paradigms and related languages
The rest of this paper is organised as follows. Related works and preliminaries are reviewed in Section 2. The proposed paradigm and language are detailed in Section 3. Additional examples are given in Section 4. A compiler for the proposed paradigm is described in Section 5. Evaluation is conducted in Section 6 and the paper is concluded in Section 7.