Capstone — Build a Real System
hello.c দিয়ে শুরু — একটি সম্পূর্ণ system-এ শেষ
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।
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
- Source modular — প্রতিটি concern আলাদা ফাইলে।
- Makefile বা CMake যা
-Wall -Wextra -O2-এ clean build করে। - অন্তত ১০টি automated test।
- Proper
README.md— architecture, usage, example। - Benchmark section — সংখ্যা, vibe না।
CHANGELOG.md+ semantic version tag।- GitHub-এ host, peer-review, issue তৈরি + fix।
- 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-এই কাজে লাগবে।
#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 (শব্দকোষ)
| Term | Meaning | বাংলায় |
|---|---|---|
| Capstone Project | A culminating, end-of-course project applying all learned skills. | সব শেখা প্রয়োগের জন্য কোর্সের শেষ প্রকল্প। |
| System Design | Choosing components and how they interact to meet requirements. | প্রয়োজন মেটাতে কম্পোনেন্ট ও তাদের সংযোগ ঠিক করা। |
| Architecture | The high-level shape of a system. | সিস্টেমের সামগ্রিক কাঠামো। |
| Module | A self-contained component with a clear interface. | স্পষ্ট interface-যুক্ত স্বয়ংসম্পূর্ণ component। |
| Interface | The public surface a module exposes. | Module-এর প্রকাশিত surface। |
| Lexer | Turns source text into a stream of tokens. | Source text-কে token-এ রূপান্তর। |
| Parser | Builds a syntax tree from tokens. | Token থেকে syntax tree তৈরি। |
| AST | Abstract Syntax Tree — structured representation of code. | কোডের কাঠামোগত উপস্থাপনা। |
| Evaluator / Interpreter | Walks the AST and computes results. | AST থেকে ফলাফল হিসাব করে। |
| Test-Driven Development | Write the test first, then make it pass. | আগে test লিখে তারপর pass করানো। |
| Refactor | Restructure code without changing behavior. | আচরণ অপরিবর্তিত রেখে কোড পুনর্গঠন। |
| Version Control | Tracking code history (e.g., Git). | কোডের ইতিহাস রাখা (যেমন Git)। |
| Build System | Tooling that compiles and links your project (Make, CMake). | Project compile/link-এর tool। |
| Documentation | Written explanation of how the system works. | সিস্টেম কীভাবে চলে তার লিখিত বিবরণ। |
| Code Review | Peer reading and suggesting improvements before merge. | Merge-এর আগে অন্যের পর্যালোচনা। |
| Deployment | Shipping code to where users can run it. | ব্যবহারকারীর কাছে কোড পৌঁছানো। |
🎓 অভিনন্দন — কোর্স সম্পন্ন
আপনি ৪০টি module শেষ করেছেন। শুরু করেছিলেন কিছুই না জানা থেকে — এখন real system লেখেন সেই ভাষায় যা পৃথিবী তৈরি করেছে। Memory, correctness, complexity সম্পর্কে যুক্তি দিতে পারেন — এবং GitHub-এ তার প্রমাণ আছে।