💾 Archived View for soviet.circumlunar.space › zwatotem › snapshot › solution › index.gmi captured on 2024-09-29 at 01:43:59. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Solving Expression Problem with Visual Programming

Abstract

In software engineering the problem of software expandability has been extensively studied for the last years. In the industry the Open-Closed principle, which commands code to be written “open for expansion, closed for modification” is the de-facto standard for writing code that is easy to expand upon and maintainable. Unfortunately, today’s frameworks in the form of programming languages do not allow for easy expansion of both data and behaviours in a way that is easy and follows the Open-Closed principle. This problem has been known and described in literature as Expression Problem. Several studies have presented solutions to the problem within the confines of existing programming languages, but few tried to explore creating new programming tools oriented on solving it directly. The aim of the study is to create a new framework for programming, which enables conceptually easy solution to the Expression Problem, utilizing visual programming.

Introduction

This thesis will tackle the Expression Problem. In short, Expression Problem occurs during the process of writing a program with some number of types of data, and some number of operations on all these types. When new types and new operations are added consecutively in arbitrary order, one must revisit existing definitions upon these additions. In object-oriented programming one must revisit all existing classes when adding a new method. In functional programming one must revisit all existing function when adding a data case.

In the first chapter we will review the history of the problem research and approaches to its solutions. The we will define Expression Problem in more formally, considering all the interpretations of the informal definition. We will separate a common understanding of the definition agreed upon by all previous papers and follow it by extensions – aspects considered by some works.

In the second chapter we will compare few notable solutions to the Expression Problem present in existing literature. For all of them we will follow a common example, compiled by the author of this work. For each solution a discussion will assess, how it solves the extensions of the Expression Problem defined in the first chapter.

Finally, third chapter will present Visual Solution – a proposal of novel approach to the Expression Problem utilizing techniques of visual (non-textual) programming to solve the organizational aspects of the Expression Problem. The Visual Solution will be discussed in the same categories as previous solutions to provide fair comparison and enlist known limitations.

The main contributions of this work are:

Basic terminology in this work

Function: an abstraction for a unit of code separated under a name, parametric with accordance to an arbitrary number of unknowns and reusable via a construct of function call. The Type of function parameter constrains a set of values that this parameter can take based on compile-time check.

Algorithm: a function that at the top level of indirection has a single implementation; generic in regard of its argument type but can in reality differ in implementation on the further levels of indirection via non-generic functions that it uses.

Method: a function, which has an arbitrary number of alternative implementations, of which one is selected at runtime based on the data type of one or more of its arguments.

Object Oriented Programming: a style of programming, where a definition of a data type is inseparable from definitions of functions on this data type and from declarations of partaking in an abstraction. Such a unit of data description, abstraction membership declarations and function definitions we call a Class.

Interface: an abstraction in Object Oriented Programming defined by a set of externally available methods.

Functional Programming: a style of programming, where a data type is defined separately from functions operating on that data type. While in general functional programming is defined by more distinct qualities, they are not a concern of this work.

Compilation unit: a unit of executable code or a runtime linkable library that is a result of a single compilation operation, of code provided directly, and code linked statically by a reference to another available module of source code.

Extension of existing code: a change that regardless of compilation unit it is defined in, could be transferred to an external compilation unit with preservation of all semantics.

Modification of existing code: code change that is made in the compilation unit of the base version and cannot be transferred to an external compilation unit due to specifics of a language it is defined in. Remark: in equivalent code in two different programming languages the same change can be an extension in one and modification in the other.

Chapter 1: Introduction to Expression Problem

History of Expression Problem research

History of Expression Problem research

Definition of Expression Problem

Definition of Expression Problem

Expression problem in this paper

As this chapter shown, there are different aspects of the Expression Problem, which can be respected or omitted in different situations. Having this in mind, the next chapter will assess solutions proposed in literature separately for each criterion, instead of choosing a specific subset of them. Similarly, following chapter will assess my own solution according to all aspects of Expression Problem in separation.

Chapter 2: Overview of proposed solutions

Dynamic Visitor

Static Visitor

Object Algebra

Traits & Mix-ins

Final Tagless

Protocols

Multimethods

Chapter 3: Visual Solution

Visual Solution

Conclusions

This thesis has explored the Expression Problem, a fundamental challenge in software engineering that revolves around the tension between extending data types and adding new operations in a modular and type-safe manner. The initial chapters outlined existing solutions, each contributing unique strengths in addressing this challenge. However, these solutions often require trade-offs, particularly in how they organize and structure code, which can lead to inefficiencies and difficulties in maintenance as software evolves.

The Visual Solution proposed in this work introduces a novel approach inspired by spreadsheet pivot tables, aiming to overcome the limitations of traditional code organization methods. By separating program semantics from its representation, this solution allows developers to view and manipulate code through different organizational lenses, depending on the task at hand. This flexibility enables programmers to optimize code organization dynamically, aligning it with current development needs without being locked into a single structure.

Through the use of a visual environment that supports multiple views — class view, method view, concept view — this solution provides a more intuitive and adaptable way to manage the complexities of the Expression Problem. It ensures that code can be organized according to various concerns, minimizing scattering and tangling, which are common in traditional approaches. The Visual Solution also maintains static type safety and reduces code overhead by introducing roles and concepts, which streamline polymorphism and method implementation.

While the theoretical framework for the Visual Solution is well-defined, it remains unimplemented in practice. Implementing this solution is necessary to validate its practical utility, assess its effectiveness in real-world scenarios, and evaluate the runtime complexity of the underlying algorithms. Only through such an implementation can the solution's true potential and any unforeseen limitations be fully understood.

While the solution shows promise in enhancing code organization and addressing the Expression Problem within self-contained programs, there are areas that require further exploration, particularly concerning external extensibility and composability. These aspects are crucial for evaluating the solution's applicability in larger, modular systems where interaction across module boundaries is necessary.

In conclusion, the Visual Solution represents a significant step forward in the ongoing quest to solve the Expression Problem. It provides a more flexible and user-friendly approach to code organization, potentially improving the maintainability and evolution of software. Future work should focus on implementing this solution to verify its practical application and to refine the approach, as well as exploring open extensions.

References

Borne, I. (1993). A visual programming environment for Smalltalk. Proceedings - 1993 IEEE Symposium on Visual Languages, VL 1993.

Carette, J., Kiselyov, O., & Shan, C. C. (2009). Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. Journal of Functional Programming, 19(5).

Chambers, C., & Leavens, G. T. (1995). Typechecking and Modules for Multimethods. ACM Transactions on Programming Languages and Systems (TOPLAS), 17(6).

Clifton, C., Millstein, T., Leavens, G. T., & Chambers, C. (2006). MultiJava: Design rationale, compiler implementation, and applications. ACM Transactions on Programming Languages and Systems, 28(3).

Clojure - Protocols. (2024).

Cook, W. R. (1991). Object-oriented programming versus abstract data types. Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), 489 LNCS.

Gamma, E., Helm, R., Johnson, R., & Vlissides, J. (1994). Design Patterns: Elements of Reusable Object-Oriented Software (Addison Wesley professional computing series). In Applied Object-Oriented Patterns.

Giffen, R., & Tomek, I. (1997). Visual programming interface for Smalltalk. Proceedings of the Conference on Technology of Object-Oriented Languages and Systems, TOOLS.

Haeri, S. H., & Keir, P. (2019). Solving the Expression Problem in C++, á la LMS. Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), 11884 LNCS.

Jean-Louis Leroy. (2018). Introduction | yomm2.

Kiselyov, O. (2012). Typed tagless final interpreters. Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), 7470 LNCS.

Krishnamurthi, S., Felleisen, M., & Friedman, D. P. (1998). Synthesizing object-oriented and functional design to promote re-use. Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), 1445.

Oliveira, B. C. D. S. (2009). Modular visitor components a practical solution to the expression families problem. Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), 5653 LNCS.

Oliveira, B. C. D. S., & Cook, W. R. (2012). Extensibility for the masses practical extensibility with object Algebras. Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), 7313 LNCS.

Oliveira, B. C. D. S., Van Der Storm, T., Loh, A., & Cook, W. R. (2013). Feature-oriented programming with object algebras. Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), 7920 LNCS.

Pirkelbauer, P., Solodkyy, Y., & Stroustrup, B. (2007). Open multi-methods for c++. GPCE’07 - Proceedings of the Sixth International Conference on Generative Programming and Component Engineering.

Reynolds, J. C. (1972). Definitional interpreters for higher-order programming languages. Proceedings of the ACM Annual Conference, ACM 1972.

Reynolds, J. C. (1978). User-Defined Types and Procedural Data Structures as Complementary Approaches to Data Abstraction. In Programming Methodology.

Reynolds, J. C. (1998). Definitional Interpreters Revisited. Higher-Order and Symbolic Computation, 11(4).

Structure and interpretation of computer programs, (second edition). (1997). Computers & Mathematics with Applications, 33(4).

Szyperski, C. (1996). Independently Extensible Systems - Software Engineering Potential and Challenges. Australian Computer Science Communications, 18(August).

Tarr, P., Ossher, H., Harrison, W., & Sutton, S. M. (1999). N degrees of separation: Multi-dimensional separation of concerns. Proceedings - International Conference on Software Engineering.

Torgersen, M. (2004). The Expression Problem Revisited Four New Solutions Using Generics. Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), 3086.

Walder, P. (1998, November 12). The Expression Problem.