Separating Use and Reuse to Improve Both

02/01/2019
by   Marco Servetto, et al.
0

Context: Trait composition has inspired new research in the area of code reuse for object oriented (OO) languages. One of the main advantages of this kind of composition is that it makes possible to separate subtyping from subclassing; which is good for code-reuse, design and reasoning. However, handling of state within traits is difficult, verbose or inelegant. Inquiry: We identify the this-leaking problem as the fundamental limitation that prevents the separation of subtyping from subclassing in conventional OO languages. We explain that the concept of trait composition addresses this problem, by distinguishing code designed for use (as a type) from code designed for reuse (i.e. inherited). We are aware of at least 3 concrete independently designed research languages following this methodology: TraitRecordJ, Package Templates and DeepFJig. Approach: In this paper, we design 42_μ a new language, where we improve use and reuse and support the This type and family polymorphism by distinguishing code designed for use from code designed for reuse. In this way 42_μ synthesise the 3 approaches above, and improves them with abstract state operations: a new elegant way to handle state composition in trait based languages. Knowledge and Grounding: Using case studies, we show that 42_μ's model of traits with abstract state operations is more usable and compact than prior work. We formalise our work and prove that type errors cannot arise from composing well typed code. Importance: This work is the logical core of the programming language 42. This shows that the ideas presented in this paper can be applicable to a full general purpose language. This form of composition is very flexible and could be used in many new languages.

READ FULL TEXT
research
03/27/2018

Live Multi-language Development and Runtime Environments

Context: Software development tools should work and behave consistently ...
research
06/21/2023

A Chain of AI-based Solutions for Resolving FQNs and Fixing Syntax Errors in Partial Code

API documentation, technical blogs and programming Q A sites contain n...
research
02/01/2019

Shallow EDSLs and Object-Oriented Programming: Beyond Simple Compositionality

Context: Embedded Domain-Specific Languages (EDSLs) are a common and wid...
research
03/21/2018

Generic Zero-Cost Reuse for Dependent Types

Dependently typed languages are well known for having a problem with cod...
research
01/31/2022

Advantages and Disadvantages of (Dedicated) Model Transformation Languages A Qualitative Interview Study

In a recent study we have shown, that a large number of claims about mod...
research
02/26/2019

Iteratively Composing Statically Verified Traits

Metaprogramming is often used to programmatically generate faster specia...
research
11/29/2021

Enabling Reusable Physical Design Flows with Modular Flow Generators

Achieving high code reuse in physical design flows is challenging but in...

Please sign up or login with your details

Forgot password? Click here to reset