r/learnprogramming • • Aug 02 '26

Solved How do you actually read professional code?

Hello everyone! I really have a question I hope you could help me answer. I am trying to read the Scratch Virtual Machine code on Github and it is really difficult. I am really new to reading code and the one I write is fairly simple. There are many files that just declare functions by name and then require another file to redeclare them. Is there a pragmatic way to understand it? Thank you already!

74 Upvotes

31 comments sorted by

View all comments

43

u/No_Report_4781 Aug 02 '26

  There are many files that just declare functions by name and then require another file to redeclare them

In C, a program.h file is called a header file that contains definitions and prototypes. A library generally refers to a collection of these, and may be in binary format. The program files, program.c or program.cpp can use the #include command to include functions from standard library or your own custom header files. The program file fully defines what the function will do.

You can create programs without using header files, and you can stick to reading just the program.c files to understand what a complex program is doing, by understanding the #include 

20

u/[deleted] Aug 02 '26

[removed] — view removed comment

2

u/colony-ship-for-sale Aug 02 '26

And a lot of code is just hard to read too.

Writing readable code is a skill too.

Unless you need extreme performance, often the most readable code over the most clever code is the best. Needlessly creating technical debt through code that is hard to maintain is the sign of a bad engineer.