r/learnprogramming • • 7d ago

Tutorial Building a shell in C from scratch made me realize how similar it is to modern AI Agents

Hey folks,

I'm currently halfway through Stephen Brennan's classic "Write a Shell in C" (lsh) tutorial. It's a fun read so far, though it feels a bit too hand-wavy—it shows how to glue fork(), exec(), and wait() together, and leaves me itching for the actual official specs and deeper design docs.

It got me thinking about two things:

First, how did the OG legends like Ken Thompson or Stephen Bourne actually architect the early UNIX shells from a blank slate? I want to read the real foundational papers, POSIX docs, or historical design breakdowns instead of just toy tutorials.

Second—linking the classic Read -> Parse -> Execute loop to modern AI Agents—it feels remarkably similar to how agents parse context and dispatch tools.

Looking for recommendations on historical specs, papers, or minimal shell source repos. Drop them below. Thanks! And hopefully I'll stick with documenting my learning journey here ;)

0 Upvotes

5 comments sorted by

9

u/[deleted] 7d ago

People used to use their brains, back in the day. I mean, before people started to delegate thinking to AI.

Take a paper and pencil, and think about what you want your program to do. Refine. And when it looks good, code. Pretty simple.

-4

u/Consistent-Play-8932 7d ago

Oh yes. Sometimes AI steal my thoughts. I feel that I should return to a simpler state of mind and calm down to think. I started university in 2023. I witnessed the period when AI evolved from a baby to a fierce beast. However, this also made my thinking become more impulsive.

9

u/Eisenfuss19 7d ago

Ah yes, a deterministic command execution tool that has clear documentation is similar to a statistical nondeterministic tool that has no documentation.

Sounds about right to me.

2

u/mredding 7d ago

Their development process was very informal and unmanaged. They were building on the foundations of prior lessons and ideas - everything is a file, don't make the mistakes of MULTICS, modular components out in userspace rather than all-in-one monoliths. You NEED that prior context, those lessons hard learned to make sense of how they could have built their vision. Shells were not a new concept, they weren't inexperienced, and there was more domain knowledge and familiarity with parsing and batching than is usual today. Ken Thompson wrote his first shell for him, deployed directly to a shared system, and got immediate feedback from his peers, who restarted their shells and started using it.