I've been spending time recently doing structured deep dives into topics I want to genuinely understand — and implement simple toy models around those topics. So, over the weekend I spent a lot of time exploring web-sockets with Claude Code.
The approach I followed:
1. Theory first. Before writing a single line of code, I spent time building a mental model — basic preview of how web sockets work, why they are so expensive, how statefulness affects every layer of the infrastructure, when to use / not-use WebSockets. Some real-world examples of when they are used and when they are not.
2. Design before implementation. I defined the scope and agreed on a test list before touching code.
Scope: A WebSocket client and server where:
- The server echoes client messages
- The server can also push messages independently
- The client can close the connection cleanly
Test list (same 9 tests implemented in all three languages):
1. Server starts and listens on a port
2. Client connects to the server
3. On connection, client receives a welcome message from the server
4. Client sends a message and receives the echo correctly
5. Server sends an independent message, client receives it correctly
6. Client closes the connection cleanly (close code 1000)
7. Server handles multiple sequential messages correctly
8. Client handles multiple sequential messages correctly
9. Server handles multiple clients independently
3. Strict TDD. Kent Beck style — write the test list first, then one test at a time: red → green → refactor. No additional code before a failing test.
4. Three languages. Python (`websockets` + `pytest-asyncio`), Go (`gorilla/websocket`), and C# (`System.Net.WebSockets` + `xUnit`). I consider myself pretty proficient with python and use C# at work, but have been wanting to get a better understanding of Go for some time.
Tell me how are you using Claude and other llms to learn and do things better?
P.S. - Repository link in comments, I typed in everything for the source code, and didn't use auto-edits at all. The article is generated by Claude, and edited by me. Any feedback is greatly appreciated!
Discussion about this post
No posts

