3 ms·
This is a bit weird to me since I never thought someone would just go and read source code of some program from start to finish. It would be something like read
by eterevsky 3y ago
This is a bit weird to me since I never thought someone would just go and read source code of some program from start to finish. It would be something like reading an encyclopedia starting from the letter A.
That said, I personally DO read code. Besides code reviews that were mentioned in the article I read the code that my code depend on. Especially when I want to better understand some API, I read not only the headers, but the actual implementations of the functions that I'm using.
Sometimes I read code to better understand some algorithm. I only understood how Transformer architecture worked when I read some of its implementations.
So yeah, reading code is cool. We just don't read it as we read books.
- LeanderK 3y agoyeah, weird. I read a lot of code. I often read code to exactly understand what's going on, how specific functions are used or how the API was intended to fit together. That may mean that I read random code on github, code of my dependencies etc. But it's not a continuous reading of code. I don't read the code of my dependency from start to finish.
- Joker_vD 3y ago> someone would just go and read source code of some program from start to finish. Well, one has to start reading from somewhere, and the start seems like a good way to start, is it not? Well, actually, no, it's not, because you have to waddle from main through like ten levels of procedure calls until some actual work starts being performed, but if you don't know where exactly the interesting parts are the only other options are either try to grep (doesn't work reliably in repositories where the authors like short and cryptic names) or to read source files until you find the relevant place. > It would be something like reading an encyclopedia starting from the letter A. I actually did something similar as a child, except I'd just open it on a random page and start reading. There is nothing really wrong with that as a recreational reading IMHO.
- kaba0 3y agoI remember there was a blog post saying that everyone should write an ARCHITECTURE.md file as well for their projects. It’s content can be a great starting point(s).
- deleted 3y ago[deleted]
- lofatdairy 3y agoYeah the encyclopedia analogy is actually better than GP probably intended because both encyclopedias and source code can take on a branching, fractal information flow. I obviously don't read an encyclopedia start to finish linearly, but as a kid I would start on a random Wikipedia article that caught my attention, and just keep clicking blue links, backtracking whenever I've gone to far. Reading a new codebase is usually not so deep, but it's a similar process of previous definitions.
- sophacles 3y agoI used to do this with the paper encyclopedia too... Id sit on the floor surrounded by books open to a page with slips of paper, pencils and whatever else was around as markers. I'd try to keep track of where i came from so i could backtrack through my side quests. When tabbed browsing came around it was a relief, the browser did all that for me well enough. Unsurprisingly I frequently find out how many tabs is too many for my current computer (less frequently than 20 yeas ago tho since browsers and computers are a lot better than they used to be.)
- yakubin 3y agoWith the difference that encyclopedias are cyclical, whereas a working program has to reduce at some level to primitives.
- deleted 3y ago[deleted]
- dfxm12 3y agoThere is nothing really wrong with that as a recreational reading IMHO. Yeah, but I think that this is beside the point since the encyclopedia isn't colloquially literature, either.
- mytec 3y agoThere is a YouTube channel where the person reads the code (not start to finish) of various open source projects. https://www.youtube.com/@ants_are_everywhere/featured https://www.youtube.com/@ants_are_everywhere/featured
- mcguire 3y agoThis is actually one of the major features of Knuth's tangle/weave: you write the code as a book or article and give information to a compiler that puts everything in the right place for the program.
- smaudet 3y ago> "from start to finish" I think perhaps this is not even a valid concept... The simple case of a program with a main maybe has a "start"? (Although due to program loading, there is quite a lot of code that executes before main, often not your code but sometimes static initialization, e.g.). In the case of async programming (queues, services, interrupt handlers, etc.), a "start" is pretty arbitrary, and needs to be defined some other way (start of a data scenario e.g.)... And in all sceanrios except pure batch processing, a "finish" doesn't exist, except in the sense of a "quit" or termination scenario, but not in relation to rest of the code base...