What is agda?
Agda is a programming language and proof assistant that lets you write both computer programs and mathematical proofs together. It is based on a concept called “dependent types,” which means the type of a value can depend on a value itself. This lets you express very precise specifications and have the compiler check that your code really follows them.
Let's break it down
- Language: Agda looks a lot like Haskell, but with extra power in its type system.
- Types as specifications: You can write a type that describes exactly what a function should do (e.g., a list‑sorting function that always returns a list that is a permutation of the input and is ordered).
- Proofs as programs: A proof that a property holds is just another piece of Agda code that the type checker verifies.
- Interactive editor: Most people use Agda inside Emacs or VS Code, where the editor shows you the current goal and lets you fill in proof steps interactively.
- Compilation: After you finish, Agda can erase the proof parts and compile the remaining program to Haskell, JavaScript, or run it directly in the interpreter.
Why does it matter?
Because it lets you catch bugs before you run the program. If the type checker accepts your code, you have a mathematical guarantee that the stated properties hold. This is especially valuable for safety‑critical software, cryptographic algorithms, and formal verification of mathematics. It also teaches you to think rigorously about what your code should accomplish.
Where is it used?
- Academic research: Formalizing mathematics, studying type theory, and teaching functional programming.
- Verified software: Small verified components such as parsers, compilers, or cryptographic primitives.
- Prototype of dependently typed languages: Influences languages like Idris, Coq, and Lean.
- Education: Courses on type theory, functional programming, and formal methods often use Agda for hands‑on exercises.
Good things about it
- Extremely expressive type system; you can encode complex invariants directly.
- Unified language for programming and proving, reducing the gap between code and specification.
- Strong community and many libraries (standard library, Agda‑stdlib).
- Clear, interactive feedback in the editor helps beginners learn proof techniques.
- Generates clean Haskell code after erasing proofs, making integration easier.
Not-so-good things
- Steep learning curve: dependent types and interactive proof development can be intimidating.
- Limited tooling compared to mainstream languages; debugging is mostly done by looking at type errors.
- Performance: the interpreter is slower than compiled languages, and generated code may need extra optimization.
- Smaller ecosystem: fewer libraries and real‑world applications than languages like Haskell or Rust.
- Requires Emacs or a specialized VS Code extension, which may be a barrier for some users.