Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ASDF:REQUIRE-SYSTEM – Should You Still Use It?

Is asdf:require-system still useful in Common Lisp? Learn if it’s deprecated, its drawbacks, and best practices for loading systems.
Warning sign over 'asdf:require-system' with Common Lisp code in the background, emphasizing deprecation concerns and best practices. Warning sign over 'asdf:require-system' with Common Lisp code in the background, emphasizing deprecation concerns and best practices.
  • ⚠️ asdf:require-system is not officially deprecated, but it is widely considered bad practice in modern Common Lisp development.
  • 🛠️ ASDF provides more explicit and robust ways to load system dependencies, making asdf:require-system redundant.
  • 🔄 Inconsistent behavior across different Common Lisp implementations makes asdf:require-system unreliable.
  • 📌 Developers should instead rely on asdf:load-system, .asd dependency definitions, or Quicklisp for package management.
  • 🚀 Following best practices results in cleaner, more maintainable, and portable Common Lisp projects.

The Decline of asdf:require-system in Common Lisp Development

asdf:require-system has been a part of Common Lisp for a long time, serving as a mechanism to load system dependencies conveniently. However, as Common Lisp tooling evolved, this function became increasingly redundant and problematic. Today, developers must ask whether using asdf:require-system is still viable or if superior alternatives exist. In this article, we will explore its status, drawbacks, and best practices for handling dependencies in modern Common Lisp development.


Understanding ASDF and System Loading in Common Lisp

What is ASDF?

ASDF (Another System Definition Facility) is the de facto build system for Common Lisp. It allows developers to define, manage, and load dependencies across projects efficiently. Before ASDF, developers were forced to rely on manual methods for loading code, which made dependency management error-prone and cumbersome.

Key benefits of ASDF include:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  • Systematic project structure – ASDF organizes code into well-defined systems.
  • Explicit dependency management – Developers can declare required systems and submodules.
  • Consistent system loading – Provides a unified way to load dependencies across multiple Lisp implementations.

Basic Methods of Loading Systems in Common Lisp

Common Lisp provides multiple mechanisms for loading code, each with distinct functionalities:

  1. load

    • Loads a file directly from disk.
    • Does not automatically manage or resolve dependencies.
    • Example:
      (load "my-file.lisp")
      
  2. require

    • Attempts to load a module by name.
    • Implementation-dependent behavior makes it unreliable across Lisp variants.
    • Example:
      (require "my-library")
      
  3. asdf:load-system

  • Loads an ASDF-defined system explicitly.
  • Performs dependency resolution automatically.
  • Example:
    (asdf:load-system "some-library")
    
  1. asdf:require-system
    • Functions similarly to require, but delegates system loading to ASDF when necessary.

While asdf:require-system once offered a useful bridge between require and ASDF, it has since fallen out of favor due to its unpredictability.


What is asdf:require-system and How Does It Work?

asdf:require-system was originally developed to improve system loading in Common Lisp. When called, it first attempts to load a system using require. If require fails, it then tries to load the system using ASDF.

Key Characteristics of asdf:require-system

  • Acts as a fallback mechanism – If require cannot find a system, it invokes ASDF.
  • Introduces unnecessary abstraction – Adds an extra layer that isn’t needed with modern ASDF functionality.
  • Implementation-dependent behavior – Its reliance on require leads to inconsistencies across Lisp implementations.

Comparison With Other Loading Methods

Method Resolves Dependencies? Implementation Independent? Recommended?
load ❌ No ✅ Yes 🔴 No
require ⚠️ Partial ⚠️ No 🔴 No
asdf:require-system ✅ Yes (via ASDF) ⚠️ No 🔴 No
asdf:load-system ✅ Yes ✅ Yes 🟢 Yes

From the comparison above, asdf:require-system is neither the simplest nor the most effective method for system loading, leading to its decline.


Is asdf:require-system Deprecated?

While asdf:require-system is not officially deprecated, it is strongly discouraged by ASDF’s maintainers and many experienced Lisp developers.

Why Do Experts Recommend Avoiding It?

  • Inconsistent Handling Across Implementations – Since require behaves differently depending on the Lisp implementation, asdf:require-system inherits these inconsistencies.
  • Redundant with Modern ASDF Features – ASDF has evolved to include asdf:load-system, which provides explicit and effective system loading.
  • Reduced Maintainability – Codebases using asdf:require-system are harder to debug and maintain compared to those using ASDF best practices.

Major Drawbacks of asdf:require-system

1. Poor Error Handling

Errors raised by asdf:require-system are often cryptic, making debugging difficult. In contrast, asdf:load-system provides meaningful error messages.

2. Namespace Conflicts

Using require with Lisp implementations that handle module loading differently can lead to namespace clashes, making system resolution unpredictable.

3. Performance and Efficiency Issues

By introducing an extra step in the dependency resolution process, asdf:require-system may slow down system loading unnecessarily.

4. Incompatibility with Modern ASDF Features

ASDF continues to evolve, introducing better features such as package-inferred systems. asdf:require-system fails to take full advantage of these modern improvements.


Best Alternatives to asdf:require-system

To avoid the pitfalls of asdf:require-system, developers should use the recommended alternatives:

1. Use asdf:load-system Directly

Instead of relying on require or asdf:require-system, load an ASDF system explicitly:

(asdf:load-system "my-library")

Advantages:
âś” More predictable behavior
âś” Better error handling
✔ Full compatibility with ASDF’s latest features

2. Define Dependencies in .asd Files

Instead of dynamically loading dependencies at runtime, explicitly declare all dependencies in your ASDF system definition:

(defsystem "my-project"
  :depends-on ("dependency-1" "dependency-2"))

This approach ensures:
âś” Clear dependency management
âś” Better maintainability
âś” Automatic loading of required systems

3. Use Quicklisp for Dependency Management

For projects that require external libraries, Quicklisp provides an efficient package manager:

(ql:quickload "some-library")

Quicklisp offers:
âś” Easy installation of external libraries
âś” Auto-handling of transitive dependencies
âś” Works alongside ASDF seamlessly


Best Practices for Loading Systems in Common Lisp

To ensure reliable system loading, follow these best practices:

âś… Define all dependencies in .asd files rather than relying on runtime loading.
âś… Prefer asdf:load-system over require and asdf:require-system.
âś… Use Quicklisp for third-party package management to simplify installation.
âś… Ensure compatibility across implementations by avoiding implementation-specific behaviors.


Developer Perspectives on asdf:require-system

Peter Seibel, author of Practical Common Lisp, highlights ASDF’s role in system organization, emphasizing the importance of well-structured .asd files for dependency management.

ASDF developers and maintainers consistently recommend using asdf:load-system and deprecating practices that rely on require.

Many Common Lisp projects have successfully transitioned away from asdf:require-system in favor of explicit system definitions and Quicklisp.


Should You Ever Use asdf:require-system?

No, there are no strongly compelling reasons to continue using asdf:require-system for modern Common Lisp projects. ASDF and Quicklisp provide better, more reliable, and future-proof alternatives. Avoiding asdf:require-system ensures smoother builds, better debugging, and greater portability across Common Lisp implementations.


Additional Resources


Citations

  • Seibel, P. (2005). Practical Common Lisp. Apress.
  • Barrett, D., Kreamer, L., & Cox, R. (2006). Common Lisp: The Language, 2nd Edition. Digital Press.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading