What code should I read?
-
[I hope this doesn't cross the line of what I _shouldn't_ post about here...] I was just reminded of the oft-given advice that to improve your coding skills you should "read lots of code". This made me wonder: _What_ code should I read? If I were a painting instructor, I would advise my students to study the masters: Michelangelo, VanGogh, Norman Rockwell, Bill Watterson. But what about coders? What are some of the classic code-bases that every aspiring software developer should read at least once in his/her life? Alas, some of the best are doubtless locked up behind proprietary firewalls, but of the code that is publicly available, which programs would you suggest are worthy of studying or even emulating?
As always, It Depends. I recommend this a lot to new coders. People learning a new language. I also recommend learning/reading code that solves problems you understand, or you truly want to understand. LZW Compression was eye opening. Also, are you reading for a Novel experience or to emulate the Greats? Learning a new language or fine tuning your skills? It all matters. Are you going to skim and then focus or focus on every line of code, executing it in your head? Reading many of your replies, it sounds like you are pretty far along in programming. You are more interested in learning from the masters. To me, that means delving down into the more complicated code like Roslyn. I enjoy reading well written libraries the most. Even the elegance of x = passed || default; to initialize something conditionally is cool. A line of code is like a single thought. Developing such thoughts to harness a little more value than 3 lines of code is cool. Of course, always read the old C standard library code!
-
I dunno... I've seen code from MS that leaves me scratching my head and wondering :omg: :omg: :omg: :confused::confused::confused: WTF was this guy thinkin?
If it's not broken, fix it until it is
-
There's a lot of the .NET world that is now open source (Roslyn code compilers, Entity Framework)...I'd say reading through how they organise their code would be somewhat informative.
If you're the person who wants to drive a humvee or a unimog, then microsoft code is for you. It's ugly. It's functional. It's uninspired. It's very durable. I have never seen microsoft code that was in any way elegant or subtle. It's ok code to learn on, but will never inspire you with beauty.
-
Come on, OG. I expected this from some of the others, but not from _you_! Would you advise an auto-designer not to study a Lamborghini? Would a growing architect gain nothing from a study of the Burj Al Arab, or the One World Trade Center? Can an aspiring composer learn nothing from analyzing the techniques Beethoven, Bach, and Bublé? The same argument about "the final product" could be made about each of those fields, but it wouldn't hold up. Of course I would love to study the personal notes of Tolkien where he divulges all his inner grapplings with plot twist connundrums, but in lieu of that I am still a much better author having merely _read_ LOTR three times. All I am saying, is that when it comes to code, it is much more difficult (for me, anyways) to find the open source code that is worthy of being studied. So I am simply asking for recommendations. Have you ever read a program -- perhaps in a completely different field than your own -- which made you say, "Wow, that was put together well. It's intuitive, clean, elegant, and robust." I think somebody needs to start compiling a list of such masterpieces for the rest of us to study and admire.
kdmote wrote:
Would you advise an auto-designer not to study a Lamborghini?
It's easy to spot a lamborghini by its smooth lines and the sound its motor makes. With code, you have to get it into your head before discovering if it's a lamborghini or a rusty Yugo with 100,000 miles on it. For every epic software poem, there are 10,000 drab tomes of uninspired code.
-
[I hope this doesn't cross the line of what I _shouldn't_ post about here...] I was just reminded of the oft-given advice that to improve your coding skills you should "read lots of code". This made me wonder: _What_ code should I read? If I were a painting instructor, I would advise my students to study the masters: Michelangelo, VanGogh, Norman Rockwell, Bill Watterson. But what about coders? What are some of the classic code-bases that every aspiring software developer should read at least once in his/her life? Alas, some of the best are doubtless locked up behind proprietary firewalls, but of the code that is publicly available, which programs would you suggest are worthy of studying or even emulating?
Anything with 101 samples... Official Visual Studio 2010 Samples for C# 4.0 in C#, VB.NET, C++[^] 101 LINQ Samples in C#[^]
-
kdmote wrote:
Would you advise an auto-designer not to study a Lamborghini?
It's easy to spot a lamborghini by its smooth lines and the sound its motor makes. With code, you have to get it into your head before discovering if it's a lamborghini or a rusty Yugo with 100,000 miles on it. For every epic software poem, there are 10,000 drab tomes of uninspired code.
-
Anything with 101 samples... Official Visual Studio 2010 Samples for C# 4.0 in C#, VB.NET, C++[^] 101 LINQ Samples in C#[^]
-
I dunno... I've seen code from MS that leaves me scratching my head and wondering :omg: :omg: :omg: :confused::confused::confused: WTF was this guy thinkin?
If it's not broken, fix it until it is
You mean those "example code" sections that presume you have reached the page after having read the preceding twenty, when really all you did was search straight to this one? I may not last forever but the mess I leave behind certainly will.
-
EXACTLY. Which is why I'm asking for recommendations. I'd like somebody to start compiling a list of the epics, so we can all benefit from studying them.
I've never looked at it in total to be sure, but Stepanov's original Standard Template Library is probably brilliant. Unfortunately, the version that comes with Visual Studio has been messed up with non-core stuff and compiler dependencies, so it's quite hard to understand.
-
[I hope this doesn't cross the line of what I _shouldn't_ post about here...] I was just reminded of the oft-given advice that to improve your coding skills you should "read lots of code". This made me wonder: _What_ code should I read? If I were a painting instructor, I would advise my students to study the masters: Michelangelo, VanGogh, Norman Rockwell, Bill Watterson. But what about coders? What are some of the classic code-bases that every aspiring software developer should read at least once in his/her life? Alas, some of the best are doubtless locked up behind proprietary firewalls, but of the code that is publicly available, which programs would you suggest are worthy of studying or even emulating?
kdmote wrote:
If I were a painting instructor, I would advise my students to study the masters: ... Bill Watterson
I agree!