Muazzam wrote:
People, even those who are not programmers, casually claim they have read code of Facebook/Linux/Bitcoin/etc. Here's one who (casually) says that he has read all of code of Bitcoin:
https://www.quora.com/Is-the-cryptocurr ... s-AltucherI consider myself an above average programmer but still 90% of code written by others, even simple 1000 line programs, make no sense to me, even worse, getting how all these parts work together. And I'm assuming that I know the technology and language. I wonder if it's some programming version of dyslexia.
I have got to ask, do you have any trouble reading and understanding complex codebases? How long does it take and do you face any initial trouble getting how all parts work together?
I see myself as another computer who doesn't care how a program is written, the only thing I care about is knowing step by step what data is generated and sent to me, its structure, and for what.
I achieve this by adding lines to the programs to make it generate an UTF-8 HTML document with all data from a program step by step, even indentation, even categorized and capable of being enabled/disabled to inspect only a little part of it. In this way, I can make a program that produces a study document that is always becoming more humanly readable. If I want to understand something from a program, I concentrate on a part, I take my time, make it generate HTML at run time, and then I gradually understand what is happening. Then I can reimplement my own code without having to fully understand the programming style of it, only its tricks.
So you can make the analysis of the code as low level and fragmented or as high level and oriented to end results as you like with this.
Debuggers could be made to do the same so that running programs or OSes could be attached to an interface that knows the exact binary being analyzed, and then generate human-readable documentation from a pure binary running.
You can see how I do this, the program in which I've done it the most is my own C compiler attempt, but when I finish it, I will use this technique in any other program. I've only used it very little in other programs like DOS Wolf3D, or DOS z26 Atari emulator, but it's powerful as it lets you see how a program does things turning the computer into your teacher using your own words. And if there are tasks for which there are "magic" generated values you don't understand, you will get to know that fact, that you don't understand or know what they are using, which you couldn't have known if you don't understand how the program is written, but that now you can investigate to complete the documentation the program generates so that its data makes sense to you.
Remember that there is intermediate data specific to the implementation of a program, and data that corresponds to algorithms and standards. The objective is to get to reach that final data, know exactly what each value or set of values mean, and explain from there to re-implement those known tricks without really having to understand every single idiom used in the original code. The standard data is probably not cleanly generated until the last stage for its intended use, but it can be seen how it gets formed and we can intelligently use our brain to think how we could do something similar to form it too with our own implementation.
You can adapt the functions and macros called "WriteBookFromProgram__XXX" in your own programs. I've also attached a source file that contains the logs of what I write/think in categories. It shows extensively how to make a program human readable by basically making it write a book with real data. Later, functions to generate image or sound files, etc., can be added to make it more complete, not just plain/HTML text.
I call it SourceDoc, like source code and documentation at the same time built at run time with real tasks and real data:
http://sourceforge.net/projects/c-compiler/files/