Devlog 4 — Making it Interactive (REPL + UX Improvements)
What I learned:
- How to use
readlineto keep the program running and take input again and again - The difference between a script that runs once vs something interactive
- How small UX things (like input formatting and cleaner output) actually matter a lot
- How to handle messy user input using
trim()andsplit(/\s+/) - How to structure code so it doesn’t become a mess when it keeps running in a loop
Biggest struggle:
This part wasn’t “hard” in the usual sense but it was confusing at first.
Before this, my program would just run once and end. Now it stays alive and that changes how everything works. I had to think differently about how commands are handled because now the same logic runs over and over again.
Input handling was also kind of annoying. Even small things like extra spaces could break stuff which forced me to actually deal with it properly instead of ignoring it.
Another thing was output. At some points it felt too cluttered and at others it felt like not enough information was being shown. Finding a balance there took a bit of trial and error.
Current features:
-
REPL system using
readline(no need to restart the program every time) -
Continuous input like a real CLI
-
Support for both commands and symbols (
add++, etc.) -
Better input handling (spaces don’t break things anymore)
-
Validation for:
- wrong number of arguments
- invalid numbers
- division by zero
- square root of negative numbers
-
Cleaner output (less unnecessary logs)
-
History system:
- saved to
history.txt - can view with
history - can reset with
clear
- saved to
-
clsto clear the screen -
exitto quit the program
Next steps:
- Support actual expressions like
2 + 3 * 4instead of strict commands - Make history a bit smarter (maybe timestamps or search)
- Reduce repeated logic even more
- Add vector/matrix operations
- Add autocomplete for commands
- Add colored terminal output
Reflection:
This is probably the first version that actually feels like a real program.
The REPL made a huge difference. Before, it felt like I was just testing functions. Now it actually feels like something you can use.
Most of the improvements in this version aren’t big features, but small things that make the experience smoother. Stuff like handling spaces properly or adding aliases doesn’t sound like much but it changes how the program feels.
I’m starting to notice that building something usable is very different from just making something work.
It’s still simple and there’s a lot more I could improve but this is the first time the calculator feels complete in its own way.
Comments 1
the image is ai… try to put more effort into the image. even just a picture of the program with those improvements would be enough!
Sign in to join the conversation.