Practical Projects in Nex

Contracts at Work

Nine complete, runnable programs — CLI tools, libraries, concurrent code, networked services, and a desktop GUI — with contracts holding each one together.

By Vijay Mathew

Front Matter

  1. Preface
    PrefaceWhy a projects book, how it differs from the other three, who it is for.
  2. Front Matter
    How This Book WorksThe anatomy every project follows, the file layout convention, and how to build and run each one.

Part I — Command-Line Tools: The Baseline Discipline

  1. Chapter 1
    A Text-Analysis CLIA word-frequency counter. The CLI's contract before its code: flags, exit codes, and boundary-located errors.
  2. Chapter 2
    A Persistent Task TrackerModeling task state with refinement types, round-tripping it through JSON, and evolving a file format without breaking old data.

Part II — Libraries, Not Apps

  1. Chapter 3
    A Generic LRU CacheDesigning the interface before the implementation; an invariant as the real specification.
  2. Chapter 4
    An Expression InterpreterGrammar to AST by hand; a union and an exhaustive match as the evaluator's safety net.

Part III — Concurrency in One Process

  1. Chapter 5
    A Concurrent Duplicate FinderFan-out, fan-in with Task and Channel; testing code whose scheduler is not deterministic.

Part IV — Talking Over the Wire

  1. Chapter 6
    A TCP Chat ServerA protocol designed before any code; one task per connection, a shared broadcast channel.
  2. Chapter 7
    An HTTP JSON APIA service and its CLI client either side of net/Http_Server; Project 4's interpreter embedded as an endpoint.

Part V — Crossing Into the Host Platform

  1. Chapter 8
    A Live Desktop DashboardReal Swing listeners in Nex, and the isolation pattern a feasibility spike found and this project follows.

Part VI — Capstone: Composing What You've Built

  1. Chapter 9
    Capstone: Nex RadarFive earlier projects wired together through intern, without any of them knowing about each other.

Appendices

  1. Appendix A
    Practice IndexPractice → project → chapter lookup table.
  2. Appendix B
    Building and Packaging Each Projectnex compile jvm, standalone jars, and the interpreter/JVM-backend split.
  3. Appendix C
    The Project Layout ConventionWhy every project separates its library from its entry point, and what checks.nex is for.
  4. Appendix D
    Reading GuideFor a reader who has not done Programming with Nex first.
  5. Back Matter
    What to Build NextFurther project ideas, left out of this book on purpose.