Same problem. Different language.
A small recursive text-search CLI implemented in Python, Rust, and C++.
The goal of this project is simple: solve the same practical problem three times and compare how different languages approach file traversal, text processing, command-line interfaces, error handling, and project structure.
- 🔎 Recursive directory search
- 🔤 Case-insensitive search
- 📍 Line-number output
- 📁 File extension filtering
- 👻 Hidden-file support
- 📊 Match statistics
⚠️ Basic error handling- 🧪 Shared test dataset
- 🛠️ C++ implementation with CMake
python3 python/textgrep.py "TODO" tests/dataCase-insensitive search:
python3 python/textgrep.py "todo" tests/data --ignore-caseFilter by extension:
python3 python/textgrep.py "TODO" tests/data --ext cppcargo run --manifest-path rust/Cargo.toml -- "TODO" tests/dataCase-insensitive search:
cargo run --manifest-path rust/Cargo.toml -- "todo" tests/data --ignore-caseBuild:
cmake -S cpp -B cpp/build
cmake --build cpp/buildRun:
./cpp/build/textgrep "TODO" tests/dataWith line numbers and case-insensitive search:
./cpp/build/textgrep "todo" tests/data --ignore-case --line-numbertextgrep/
├── python/
│ └── textgrep.py
│
├── rust/
│ ├── Cargo.toml
│ └── src/
│ └── main.rs
│
├── cpp/
│ ├── CMakeLists.txt
│ ├── include/
│ │ ├── config.hpp
│ │ ├── search.hpp
│ │ └── utils.hpp
│ └── src/
│ ├── config.cpp
│ ├── main.cpp
│ ├── search.cpp
│ └── utils.cpp
│
├── tests/
│ ├── data/
│ └── test.sh
│
├── README.md
├── LICENSE
└── .gitignore
| Language | Focus |
|---|---|
| 🐍 Python | Rapid implementation and readable scripting |
| 🦀 Rust | Safety, ownership, and explicit error handling |
| ⚙️ C++ | Low-level control, filesystem APIs, and structured architecture |
All three implementations solve the same core problem while using the tools and conventions of their respective languages.
The project includes a shared dataset under tests/data.
Run the test script:
bash tests/test.shThe same test data can be used to compare the behavior of all three implementations.
textgrep started as a small programming challenge:
Can the same problem be solved cleanly in different languages?
Instead of building three unrelated projects, the same requirements are implemented in Python, Rust, and C++.
This makes it possible to compare:
- syntax and language design
- filesystem APIs
- string processing
- CLI argument parsing
- error handling
- project organization
- development workflow
The C++ version is intentionally structured as a multi-file project to practice a more production-oriented layout with headers, source files, and CMake.
This project is licensed under the MIT License.
textgrep
Same problem. Different language.