Skip to main content
QUICK REVIEW

[Paper Review] Fusing Industry and Academia at GitHub (Experience Report)

Patrick Thomson|arXiv (Cornell University)|Jun 18, 2022
Scientific Computing and Data ManagementDecision Sciences1 citations
TL;DR

This paper presents Semantic, a production-scale program analysis system built in Haskell that leverages functional programming techniques—such as algebraic effects, data types à la carte, and recursion schemes—to enable semantic diffing, code navigation, and abstract interpretation across hundreds of millions of code repositories. The key contribution is demonstrating the successful industrial application of advanced academic FP research, resulting in a performant, extensible, and open-source toolset that enhanced GitHub’s code analysis capabilities and fostered community-driven language support.

ABSTRACT

GitHub hosts hundreds of millions of code repositories written in hundreds of different programming languages. In addition to its hosting services, GitHub provides data and insights into code, such as vulnerability analysis and code navigation, with which users can improve and understand their software development process. GitHub has built Semantic, a program analysis tool capable of parsing and extracting detailed information from source code. The development of Semantic has relied extensively on the functional programming literature; this paper describes how connections to academic research inspired and informed the development of an industrial-scale program analysis toolkit.

Motivation & Objective

  • To address the challenge of analyzing vast, diverse codebases at industrial scale with high performance and correctness.
  • To evaluate the applicability of advanced functional programming techniques—such as algebraic effects and recursion schemes—in real-world, high-throughput production systems.
  • To reduce barriers to contribution by enabling external language communities to maintain code navigation rules without requiring expertise in low-level systems programming.
  • To demonstrate the bidirectional value of collaboration between industry and academia by applying academic research to solve real engineering problems.

Proposed method

  • Implementing a program analysis framework in Haskell to leverage strong type safety and referential transparency for correctness and maintainability.
  • Using algebraic effects and scoped effects to model side effects in a pure functional way, enabling modular and composable effect handling.
  • Applying data types à la carte to build extensible, well-typed data structures for syntax trees across multiple programming languages.
  • Employing recursion schemes and generalized LR parsing to enable efficient and extensible traversal and transformation of abstract syntax trees.
  • Designing a domain-specific query language (integrated into Tree-sitter) to replace Haskell-based code navigation, lowering the barrier to contribution from external language communities.
  • Refining the type system to parameterize error handling and comment tracking via functors, improving flexibility without sacrificing type safety.

Experimental results

Research questions

  • RQ1Can advanced functional programming techniques from academia be effectively applied to solve large-scale industrial software engineering problems?
  • RQ2How do techniques like algebraic effects and data types à la carte scale in production systems handling tens of thousands of concurrent code analysis requests?
  • RQ3What are the practical trade-offs between expressive power and maintainability when using recursion schemes and generalized parsing in real-world codebases?
  • RQ4How can academic research be adapted to reduce barriers to contribution in industrial tools without sacrificing performance or correctness?
  • RQ5To what extent can domain-specific languages replace low-level functional implementations in production systems while preserving performance and extensibility?

Key findings

  • The Semantic system successfully scaled to handle tens of thousands of code analysis requests per minute with low latency, demonstrating the viability of functional programming in high-throughput industrial systems.
  • The use of algebraic effects and scoped effects enabled modular, composable, and testable effect handling, significantly improving code clarity and maintainability.
  • Data types à la carte allowed for the construction of extensible, well-typed syntax trees across multiple programming languages, supporting a diverse codebase with strong type safety.
  • The transition from a Haskell-based code navigation system to a domain-specific query language built on Tree-sitter drastically reduced the barrier to contribution, enabling external communities like Elixir to maintain their own rules.
  • Parameterizing syntax node types with functors (e.g., for comments or diff states) allowed for flexible, type-safe extension of ASTs without sacrificing performance or expressivity.
  • Despite initial challenges with recursion schemes on large, mutually-recursive syntax trees, the development of Fastsum and higher-order type classes restored sufficient expressivity for production use.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.