3 ms·
You need the effects of frequent dopamine hits from seeing your code actually do things that you want it to do. This isn't a bad thing - nor is it specific to p
by davydm 2y ago
You need the effects of frequent dopamine hits from seeing your code actually do things that you want it to do. This isn't a bad thing - nor is it specific to people with ADHD or on the high-functioning autistic spectrum (like myself) - it's a side-effect of being (basically) a smart monkey.
So to progress, you need to "eat the elephant" - from the joke:
Q: How do you eat an elephant?
A: One piece at a time
TDD really helps here because you write a small test, implement a small bit of logic, and get the dopamine hit from your test passing. If you're resistent to (or unfamiliar with) TDD, you can get close by breaking the problem down into the smallest blocks you can and solving each one by one - though again, having some kind of test suite here will help to show your progress, and help to prevent regression.
A fully-compliant http server from scratch isn't trivial (as you know), but there are partial steps up to that point that you can take to get there, like first implementing a simple TCP server, and then implementing http, bit-by-bit, on top of that, eg with a first pass being: a query to a path on the server returns some string (which a browser will happily display, and a programmatic http client should be able to retrieve and print out - for tests!).
I've done something similar, though not in C, but in C#, so I know there's a lot of conveniences available in the runtime api that make it easier, but you can see this approach here: https://github.com/fluffynuts/PeanutButter/tree/master/source/SimpleServers https://github.com/fluffynuts/PeanutButter/tree/master/sourc...
A suggestion I'd make here might be to use another language with more conveniences (JS, Python, C#, whatever you feel like, but something a little more abstracted from the metal) if you want to tighten that dopamine loop. I also love learning new programming languages and have worked with at least:
- C/C++ (tbh, I wrote C++ like "C with classes" - I avoided much of the more esoteric stuff)
- VB6 (don't laugh: it's quick to learn and gets a lot done with little)
- .net languages: VB.NET, C#, F#
- scripted languages: python, ruby, tcl, bash, lua, javascript
- F#
- R
I'm sure I've missed out something; and it sounds like you have an equally interesting list. Anyway, I hope this helps.
- zwnow 2y agoThank you for the detailed answer! Its very insightful. I try to learn the lower level concepts, thats why I originally tried with C and Zig. I dont like languages that hide too much under the hood, like Python or Js, but I get the sentiment in which I actually might make progress. I'm almost through the book "Elixir in action". Maybe I will try to build something with Elixir in a TDD way. Never thought about it, but you are 100% correct that I need to see my code run for dopamine hits and a feeling of accomplishment. C# was my first ever language, I might get back into it once I am done with my Elixir journey. With TDD I always fear that my test implementation is wrong from the get go and I might have not thought about all edge cases. Nonetheless, thanks again!