I'm convinced that the best way to learn a specification, such as algorithm descriptions and pseudocode in RFCs, is to implement it in your favorite programming language. I did PackBits from page 42 of TIFF6.pdf a few days ago, and am now working on LZWEncode. I did LZWDecode a few years ago. This method forces you to resolve any ambiguities in the text, such as the missing “prefix string” variable name on pages 58-60. Only go look at OPC (other people's code) when in the final debugging phases.
The approach that works for me (every coder has his own, according to his own temperament) is:
1. Start with a top-level placeholder function in Python. Add a doctest to it, the first few lines of code, and the `if __name__ == '__main__':` idiom at the bottom. Make sure to import logging right from the get-go and use the configuration: `logging.basicConfig(level=logging.DEBUG if __debug__ else logging.WARN)`. Sprinkle debugging statements liberally; running with `python -OO` effectively strips them from the code and doesn't slow down the script. In this step, also copy key parts of the spec, especially pseudocode, into your program, either the docstrings or comments, to guide coding.
2. After those first few lines, `pylint myscript.py` and fix any problems, or add the `# pylint: disable=xxx` comments for things you want to do regardless of the "best practices" consensus. This linting also catches the grossest bugs.
3. Run `python3 -m doctest myscript.py` even if your doctest isn't complete, and even if you haven't yet coded what's needed to make it work. Every little test like this gives you a boost (like "likes" on a Facebook post) of serotonin and/or other “feel-good” chemicals that gives you the impetus to continue.
4. Loop back to #1 and add a few more lines of code, until everything is working.
End of lesson. Happy coding!
PS: Just found a copy of TIFF6.pdf that has the missing character (Ω).
PPS: I plan to eventually clean this up, flesh it out, and post to Best Practices.
PPPS: I sure wish substack supported Markdown…