Capstone — Build a Real System

hello.c দিয়ে শুরু — একটি সম্পূর্ণ system-এ শেষ

2–6 সপ্তাহ Advanced Your magnum opus

1. The Goal

আপনি hello.c দিয়ে শুরু করেছিলেন। এখন এমন কিছু বানান যা আসল মানুষ ব্যবহার করতে পারবে — GitHub-এ রাখবেন, resume-এ উল্লেখ করবেন, interview-এ দেখাবেন। নিচের চারটি track থেকে একটি বেছে নিন, অথবা নিজের propose করুন।

2. Track A — Toy Language Interpreter

Lexer → Parser → AST → tree-walking interpreter তৈরি করুন একটি ছোট language-এর জন্য।

  • Lexer token stream তৈরি করে।
  • Recursive-descent parser → AST।
  • Evaluator AST walk করে।
  • REPL + file mode।
  • Bonus: closures, recursion, strings, arrays।
Feature list ছোট রাখুন: int, variable, arithmetic, if, while, function, print। "Crafting Interpreters" বই (Robert Nystrom) বিনামূল্যে online — কাঠামো পাবেন।

3. Track B — Mini Database with B-trees

  • Disk page layout (4 KB blocks)।
  • B-tree index — O(log n) lookup।
  • Insert, delete, get, range scan।
  • CLI REPL।
  • Bonus: simple transactions, WAL, crash recovery।

"Let's Build a Simple Database" (cstack) — line-by-line tutorial। SQLite-এর ছোট version-ই আপনার lab।

4. Track C — Production HTTP Server

  • Request line ও header parse।
  • Static file serving, correct MIME types।
  • Concurrent connection handling (thread pool বা epoll)।
  • Keep-alive support।
  • Logging।
  • Bonus: directory listing, range requests, gzip।

5. Track D — Unix Shell

  • Command execution via fork + exec।
  • Pipelines: a | b | c।
  • Redirection: >, <, >>, 2>।
  • Built-ins: cd, exit, export।
  • Job control: &, fg, bg।
  • Bonus: readline-like editing, history।

6. Engineering Deliverables

  1. Source modular — প্রতিটি concern আলাদা ফাইলে।
  2. Makefile বা CMake যা -Wall -Wextra -O2-এ clean build করে।
  3. অন্তত ১০টি automated test।
  4. Proper README.md — architecture, usage, example।
  5. Benchmark section — সংখ্যা, vibe না।
  6. CHANGELOG.md + semantic version tag।
  7. GitHub-এ host, peer-review, issue তৈরি + fix।
  8. 5–10 মিনিট demo video বা live session।

7. How to Succeed

  • সবচেয়ে ছোট version শেষ করে শুরু করুন — ugly is fine, working matters।
  • প্রতিটি feature আলাদা commit।
  • প্রতিবার test করার সময় -fsanitize=address,undefined চালান।
  • Test আগে লিখুন — debug সময় বাঁচবে।
  • Real project (SQLite, nginx, redis) read করুন — C-তেই লেখা।
  • আটকে গেলে rubber duck method — সমস্যা নিজেকে ব্যাখ্যা করুন।

8. Capstone Kickoff — Live Starter Code

নিচে একটি minimal REPL skeleton — যেকোনো track-এই কাজে লাগবে।

repl.c — stdin: 3 sample commands
#include <stdio.h>
#include <string.h>

int main(void) {
    char line[256];
    printf("abcl> ");
    while (fgets(line, sizeof line, stdin)) {
        size_t n = strlen(line);
        if (n && line[n-1] == '\n') line[n-1] = '\0';

        if (strcmp(line, "exit") == 0) break;

        if (strncmp(line, "print ", 6) == 0) {
            printf("%s\n", line + 6);
        } else if (strlen(line) > 0) {
            printf("unknown command: %s\n", line);
        }
        printf("abcl> ");
    }
    puts("bye");
    return 0;
}

এই ২০-লাইনের skeleton থেকেই আপনি lexer, AST, evaluator তৈরি করে একটি পূর্ণ interpreter-এ পৌঁছাতে পারবেন।

Glossary (শব্দকোষ)

TermMeaningবাংলায়
Capstone ProjectA culminating, end-of-course project applying all learned skills.সব শেখা প্রয়োগের জন্য কোর্সের শেষ প্রকল্প।
System DesignChoosing components and how they interact to meet requirements.প্রয়োজন মেটাতে কম্পোনেন্ট ও তাদের সংযোগ ঠিক করা।
ArchitectureThe high-level shape of a system.সিস্টেমের সামগ্রিক কাঠামো।
ModuleA self-contained component with a clear interface.স্পষ্ট interface-যুক্ত স্বয়ংসম্পূর্ণ component।
InterfaceThe public surface a module exposes.Module-এর প্রকাশিত surface।
LexerTurns source text into a stream of tokens.Source text-কে token-এ রূপান্তর।
ParserBuilds a syntax tree from tokens.Token থেকে syntax tree তৈরি।
ASTAbstract Syntax Tree — structured representation of code.কোডের কাঠামোগত উপস্থাপনা।
Evaluator / InterpreterWalks the AST and computes results.AST থেকে ফলাফল হিসাব করে।
Test-Driven DevelopmentWrite the test first, then make it pass.আগে test লিখে তারপর pass করানো।
RefactorRestructure code without changing behavior.আচরণ অপরিবর্তিত রেখে কোড পুনর্গঠন।
Version ControlTracking code history (e.g., Git).কোডের ইতিহাস রাখা (যেমন Git)।
Build SystemTooling that compiles and links your project (Make, CMake).Project compile/link-এর tool।
DocumentationWritten explanation of how the system works.সিস্টেম কীভাবে চলে তার লিখিত বিবরণ।
Code ReviewPeer reading and suggesting improvements before merge.Merge-এর আগে অন্যের পর্যালোচনা।
DeploymentShipping code to where users can run it.ব্যবহারকারীর কাছে কোড পৌঁছানো।

🎓 অভিনন্দন — কোর্স সম্পন্ন

আপনি ৪০টি module শেষ করেছেন। শুরু করেছিলেন কিছুই না জানা থেকে — এখন real system লেখেন সেই ভাষায় যা পৃথিবী তৈরি করেছে। Memory, correctness, complexity সম্পর্কে যুক্তি দিতে পারেন — এবং GitHub-এ তার প্রমাণ আছে।

Hello, world থেকে একটি সম্পূর্ণ system — দীর্ঘ যাত্রা আপনি শেষ করেছেন। এখন আপনি শুধু C programmer নন — একজন সিস্টেম প্রোগ্রামার। অভিনন্দন! 🎉

এরপর কী? Operating Systems, Computer Architecture, Compilers, Distributed Systems, C++, Rust — সব কিছুই সহজ হবে কারণ আপনি মেশিনকে বুঝেন।