Legacy

Why Grep Isn't Enough: The Case for Structured Code Search

Every developer knows the reflex: something breaks in production, and you reach for grep. You type a function name, a table name, or an error code, and wait for the results. On a small codebase, this works. On a 2-million-line COBOL system with 3,000 JCL jobs, 8,000 copybooks, and 40 years of accumulated changes — it fails.

This post explains why text search breaks down at scale, and what structured search brings to the table.

The grep ceiling

Text search has three fundamental limitations when applied to source code:

  1. No awareness of structure. grep doesn't know that CALL 'PGM001' and EXEC PGM=PGM001 refer to the same program. It sees strings, not relationships.
  2. No cross-file context. Finding every program that touches a dataset means grepping every JCL and every COBOL file. On a mainframe with 48,000 source files, that's not a search — it's a research project.
  3. No transitive understanding. PGM-A calls PGM-B which calls PGM-C which executes SQL on TABLE-X. Grep sees four disconnected results. A knowledge graph sees a chain.

What structured search unlocks

When you index source code into a graph rather than an inverted text index, you can answer questions that grep simply cannot:

  • "What breaks if I change this copybook field from PIC X(10) to PIC X(20)?"
  • "Which batch jobs eventually read the output of JOB001?"
  • "Show me all programs that call PGM-XYZ, directly or indirectly."
  • "Are there any programs that reference TABLE-A but aren't documented?"

These are not hypothetical questions. They are the daily reality of maintaining and modernizing enterprise systems. And they require more than text matching — they require relationship awareness.

From text to graph

Codegraphs takes a fundamentally different approach. Instead of building a text index, we parse each file into its structural elements — programs, paragraphs, SQL statements, CALLs, COPYs, DD statements — and store them as nodes and edges in a knowledge graph.

A search for "PGM001" doesn't just return files containing that string. It returns:

  • The program definition itself
  • Every program that calls it
  • Every JCL job that executes it
  • Every dataset it reads or writes
  • Every copybook it includes
  • Every SQL table it touches

All in a single query. All connected. All navigable.

The real cost of grep

The cost of grep isn't the tool — it's the time spent running dozens of searches, manually connecting the dots, and still missing critical relationships. When a single missed dependency can cause a production outage during a migration, "good enough" search stops being good enough.

Structured search isn't a luxury for enterprise systems. It's a necessity.


Codegraphs indexes and connects software assets across 43 file extensions and counting, from COBOL on mainframes to TypeScript in the cloud. Request early access to try it on your codebase.