The SOF Programming Paradigm: A Sequence of Pure Functions

The SOF Programming Paradigm: A Sequence of Pure Functions

Antoine Bossard
Copyright: © 2022 |Pages: 14
DOI: 10.4018/IJSI.309965
Article PDF Download
Open access articles are freely available for download

Abstract

Out of the four main programming paradigms, it is widely considered that functional programming is the most promising. The programming languages that implement the functional paradigm generally do so either in a pure manner, such as Haskell, or by providing a multi-paradigm programming solution, such as most Lisp dialects, in order to allow side effects, which are proscribed under the former (pure) model. Nevertheless, tracking the execution steps of such a functional program remains challenging for the programmer. In this paper, the author addresses this issue by proposing a novel programming paradigm that combines the imperative programming approach based on a sequence of instructions with the pure function approach of functional programming, the objective being to retain the advantages of both strategies. This proposal is named “sequence of functions” (SOF), and its applicability and novelty are shown hereinafter throughout various examples and experiments.
Article Preview
Top

1. 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

IJSI.309965.f01

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.

Complete Article List

Search this Journal:
Reset
Volume 12: 1 Issue (2024)
Volume 11: 1 Issue (2023)
Volume 10: 4 Issues (2022): 2 Released, 2 Forthcoming
Volume 9: 4 Issues (2021)
Volume 8: 4 Issues (2020)
Volume 7: 4 Issues (2019)
Volume 6: 4 Issues (2018)
Volume 5: 4 Issues (2017)
Volume 4: 4 Issues (2016)
Volume 3: 4 Issues (2015)
Volume 2: 4 Issues (2014)
Volume 1: 4 Issues (2013)
View Complete Journal Contents Listing