
Smart Calculator – All in One
Building a fast, feature-packed calculator that outperforms stock apps — with a custom math parser and zero third-party math libraries.
1. The Problem
Stock calculator apps are too basic — they handle arithmetic but nothing else. Third-party calculators on the Play Store are either bloated with ads, confusingly complex, or surprisingly slow to open. I wanted to build something that loads instantly, handles everything from tip calculations to scientific equations, and feels native to Material Design 3.
2. The Solution
Smart Calculator packs 15+ tools into a single app: scientific calculator, unit converter, tip calculator, percentage calculator, age calculator, BMI calculator, and more. Each tool is a separate Compose screen with its own ViewModel, but they share a common expression evaluation engine under the hood.
3. Technical Deep Dive: Custom Math Parser
The biggest technical challenge was building a reliable expression parser. Instead of using heavy libraries like exp4j or MathParser, I built a custom recursive descent parser in pure Kotlin. It handles operator precedence (PEMDAS), nested parentheses, implicit multiplication (e.g., '2(3+4)'), and edge cases like division by zero and overflow. The parser tokenizes the input string, builds an AST (Abstract Syntax Tree), and evaluates it — all in under 1ms for typical expressions.
4. Architecture
Single-activity architecture with Jetpack Compose for the entire UI. Follows MVVM with clean architecture: UI layer (Compose screens + ViewModels), Domain layer (use cases for each calculator tool), and Data layer (SharedPreferences for history, no database needed to keep the app lightweight). Dependency injection is done via manual constructor injection — this keeps the APK under 5MB without Hilt/Dagger overhead.
5. Performance Decisions
Every design decision was about speed: Compose's lazy composition renders only visible elements. No splash screen — the app opens directly to the calculator. R8 shrinking removes unused code paths. All icons are vector drawables, not PNGs. The result: cold start under 300ms on mid-range devices, APK size under 5MB, and zero ANRs in production.
6. What I Learned
Building a math parser from scratch taught me more about computer science fundamentals than any tutorial. Handling edge cases in real user input (people type weird things into calculators) improved my defensive programming. Publishing on the Play Store taught me about ASO, crash reporting with Firebase Crashlytics, and iterating based on real user feedback from reviews.