Table of Contents
Fetching ...

Completing the Functional Approach in Object-Oriented Languages

Martin Pluemicke

TL;DR

Java-TX extends Java with global type inference and real function types to complete the functional approach in object-oriented languages, while preserving static typing and bytecode fidelity. It interleaves constraint generation, unification, and a novel generic-generation step to produce a robust, Java-conform typing of classes and methods. The work also introduces function types with variance, a strawman-based target typing strategy, and heterogeneous translation to avoid JVM descriptor collisions. Collectively, the approach delivers extended overloading, generics generation, and function-type support, aiming to bring functional programming expressiveness into Java without sacrificing runtime semantics.

Abstract

Over the last two decades practically all object-oriented programming languages have introduced features that are well-known from functional programming languages. But many features that were introduced were fragmentary. In Java-TX we address the latter features and propose a completion. Java-TX (i.e. Type eXtended) is a language based on Java. The predominant new features are global type inference and real function types for lambda expressions. Global type inference means that all type annotations can be omitted, and the compiler infers them without losing the static type property. We introduce the function types in a similar fashion as in Scala but additionally integrated them into the Java target-typing as proposed in the so-called strawman approach. In this paper, we provide an integrated presentation of all Java-TX features. The focus is therby on the automatic inference of type parameters for classes and their methods, and on the heterogeneous translation of function types, which permits the preservation of the argument and return types in bytecode.

Completing the Functional Approach in Object-Oriented Languages

TL;DR

Java-TX extends Java with global type inference and real function types to complete the functional approach in object-oriented languages, while preserving static typing and bytecode fidelity. It interleaves constraint generation, unification, and a novel generic-generation step to produce a robust, Java-conform typing of classes and methods. The work also introduces function types with variance, a strawman-based target typing strategy, and heterogeneous translation to avoid JVM descriptor collisions. Collectively, the approach delivers extended overloading, generics generation, and function-type support, aiming to bring functional programming expressiveness into Java without sacrificing runtime semantics.

Abstract

Over the last two decades practically all object-oriented programming languages have introduced features that are well-known from functional programming languages. But many features that were introduced were fragmentary. In Java-TX we address the latter features and propose a completion. Java-TX (i.e. Type eXtended) is a language based on Java. The predominant new features are global type inference and real function types for lambda expressions. Global type inference means that all type annotations can be omitted, and the compiler infers them without losing the static type property. We introduce the function types in a similar fashion as in Scala but additionally integrated them into the Java target-typing as proposed in the so-called strawman approach. In this paper, we provide an integrated presentation of all Java-TX features. The focus is therby on the automatic inference of type parameters for classes and their methods, and on the heterogeneous translation of function types, which permits the preservation of the argument and return types in bytecode.

Paper Structure

This paper contains 12 sections, 2 theorems, 2 equations, 8 figures.

Key Result

Theorem 9

The completed family of generated generics of any class fulfills the typing rules of a Java class.

Figures (8)

  • Figure 1: Result of the constraint generation
  • Figure 2: Result of the type unification
  • Figure 3: Class TPHsToGenerics before and after tree traversing
  • Figure 4: Generated generics of the class TPHsTo-Ge-ner-ics
  • Figure 5: Further example for the completed family of generated generics
  • ...and 3 more figures

Theorems & Definitions (13)

  • Example 1
  • Example 2
  • Example 3
  • Example 4
  • Definition 5: Family of generated generics
  • Example 6
  • Definition 7: Completed family of generated generics
  • Example 8
  • Theorem 9
  • Example 10
  • ...and 3 more