Scott Hanselman

Given I like reading Source Code by the fire with my smoking jacket and brandy snifter, a list of books

April 17, 2012 Comment on this post [34] Posted in Open Source | Source Code
Sponsored By

lilwaynesomecodeandsomebrandyJeff had a blog post yesterday (seems everything he writes in his retirement gets on Hacker News as well) about reading source code. While Jeff's post is largely a pull-quote of a post on Hacker News by Brandon Bloom, one bit stuck out to me as I'm sure it did to others.

"The idea that you'd settle down in a deep leather chair with your smoking jacket and a snifter of brandy for a fine evening of reading through someone else's code is absurd." - Jeff Atwood.

Absurd? Hardly. Nearly every programmer I've ever spoken to enjoys reading and discovering new code. I've been advocating that Developers need to read as much code as they write for at least half the time I've been blogging (10 years now, as of yesterday.) How could you not be excited about reading source with all the wonderful open source that's available in the world today?

In fact I have an entire category of my blog called the "Weekly Source Code" with 58 different specific entries at last code. That's 58 different great opportunities to read and learn from another programmer, some good some bad.

The idea that reading source code is absurd is really the wrong message to send. Here's a list of interesting books about source and source code that I'd recommend you settle down in your leather chair, stoke the fire and read.

Of course, you don't need to buy any of these books or pay for anything. Just read code. Read your coworkers code, your company's code, your favorite open source library's code. Don't stop reading code.

The Weekly Source Code was weekly but then become "whenever I get the time." Because of Jeff's article I'm going to get a smoking jacket and brandy snifter and start doing new Weekly Source Code posts every week. Ok, it will be a Code Zero snifter but you get the idea. Because you can't be a good writer coder if you aren't a good reader.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
April 17, 2012 20:42
Great post, Scott. Those kinds of posts by Jeff is the exact reason I stopped reading his blog.
April 17, 2012 20:47
I think that's when Lil Wayne was writing this song: http://www.youtube.com/watch?v=v85QPbLhjlE
April 17, 2012 20:47
Plus... there are plenty of times when you can learn something new by reading some of the answers on StackOverflow. It's especially nice when you see a good answer with good code along with a good explanation.
April 17, 2012 20:58
But, will you be so bold as to post a picture of yourself in said smoking jacket, with brandy snifter, in said leather chair? We're waiting!

Seriously, great post, and with my meager experience, totally valid. Keep on, good sir . . .
April 17, 2012 21:09
Thanks for the post. I read Jeff's this morning and was a bit disheartened by it. I came into the world of programming after studying linguistics, so I've always been fascinated by the process of learning programming languages. It seems approaches such as yours take the immersion theory to new levels, just jump in the code and figure it out as you go along. (Works for human languages wonderfully)

I still learn something new every day I read code.
April 17, 2012 21:09
if you didn't yet, you should read 'The Little Schemer' too. Life changer :-) The Little Schemer
April 17, 2012 21:14
ditto (pun intended).

Great response Scott. Reading and reviewing code is one the most valuable (but least done) things a developer can do to improve one's own coding skills. I'm not sure why Jeff thinks it is of little use but having the discipline of regular code reviews is highly beneficial to keep the codebase readable. I think it's along the lines of his earlier posts on Programmers Don't Read Books -- But You Should.

Beside the obvious learning benefits, it is also one of the PCI compliance recommendations to have regular security code reviews (formal reading/commenting process) since not everything security related can be caught by automated application scans. To reiterate, reading code provides insight into thought process, classification technique and help you learn optimization techniques to improve your own code.
April 17, 2012 21:29
Maybe my reading comprehension has gone to pot, but that entire post seemed to advocate reading source code. Even if you disagree with "Nobody reads other people's code for fun", the following paragraph states that "We must read other people's code because we have to understand it to get things done."

It just seems odd to disregard the entire post because of one dumb generalization.
April 17, 2012 21:57
Little Weezy in the Hansel Hizzy.


April 17, 2012 21:59
I'm totally with you on this. I've learned a lot by comparing how I think with other people's approach.
April 17, 2012 22:55
Although I liked the tag line "Read the source, Luke", like you, I am a bit disturbed by Atwood's parting thought.

I guess I would question one's passion for software engineering when they don't like reading source code. Like the soap opera doctor, perhaps he's not really a software engineer, but plays one on his blog.

That said, I will probably still read his blog, since everyone from time to time has nuggets of gold.
April 18, 2012 2:39
There is a big difference in reading the code in one of the books you cite, which are excellent, and "read(ing) the source, Luke". If Luke could have convinced the Empire to branch/fork out a peaceful solution and end the tyranny and oppression of broken code, he probably would have happily allowed them to do just that. Planets don't get blasted by the Death Star because you didn't read code for pleasure. All analogies aside, don't you both advocate the same thing?
April 18, 2012 3:08
I agree with you about the need to learn from perusing other people's code, but I think that Jeff's main point is something else: he's advocating source code as the ultimate source of documentation.

I have blogged a response to his post (http://priscimon.com/blog/2012/04/17/what-the-source-code/), and the short of it is that there are inherent risks to relying on source code as documentation for third-party libraries. First, there is the risk of building upon undocumented features that are not guaranteed to be future-proof. Second, encouraging the practice of using code as a first-class source of guidance diminishes the importance of producing good documentation, yet good API documentation is not only essential for productivity but is also a measure of how good a framework is. For example, as great as the .NET Framework is, without the wealth of documentation in MSDN, it wouldn't enjoy the same degree of adoption.

Eddy.
April 18, 2012 7:32
I agree with Eddy Young that if I read Jeff's post in the spirit it was intended, it seems he is advocating for source code rather than saying it's absurd.

My interpretation is that he's saying most people might not be so passionate about their craft that reading source code each night seems more appealing than The Presidents Club, Hunger Games or whatever the cool kids are reading now. Rather, it is something that might grab people with a passing curiosity about a particular project, approach or style on occasion.

I think that people with a real thirst to learn and better their craft will likely derive a great satisfaction from learning from other peoples' examples, but perhaps the point here is that it would not ordinarily be considered a regular, exciting and stimulating passtime.
April 18, 2012 11:51
Of course it's absurd! With some code you need the whole bottle...

[Now off to categorise further into sipping code and gulping code]
April 18, 2012 12:47
I am sorry if this sounds aggressive, but it really frustrating when I see posts phrases like "How could you not be excited?", I am not excited because everywhere I have ever worked burns me out.

Maybe I don't deal with it well, maybe I am in the wrong environment. But it hard to get interested in development when some of the things I used to face daily makes me want to cause physical harm.

I found a decent place now, and I like it. But I still find myself saying to myself "WTF!" or "WHY? WHY?", I found myself saying to another developer "This code would make the baby Jesus cry".

Most of the source I get to read on a daily basis is so bad, I don't want to look at any one elses code. It not that I don't want to learn, it is because I am tired and frustrated and just want to forget about it.

When I get home and If I want to look at code, It will be mine own that I will look at, because at least I think I have some control over that.

Sorry Scott but you happen to work with code where people care about quality.

Maybe it is time you went to

http://thedailywtf.com/
April 18, 2012 14:27
Another good book for looking at source code (IMHO) is this: Find the Bug: A Book of Incorrect Programs

It helps you get better at "offline debugging" by training you to spot problems in code. So, not so much learning by looking at good code, more controlled exposure to bad code, for learning purposes.
April 18, 2012 16:32
I've been meaning to go through the source of Nuget because I'm very interested in VS extension best practices. At work I made an extension using Caliburn but the setup/teardown stuff is just alien to me.

Also, you'll sometimes find the source code of your favorite libraries actually pretty "sub-optimal." The token input jQuery plugin is excellent but its implementation is less than ideal. I rewrote the thing using Knockout and it uses way less code to do the same thing, plus it lets you use templates, choose what type of search you want, and probably more by the time I'm done.
April 18, 2012 18:01
Luke,

I have found that nobody writes code or approaches problems like one's self. While I to have puked over poorly written code, I have come to realize that what is considered "normal" or "acceptable" is relative to one's self.

Passion is established when you desire to grow beyond your own normalcy. Otherwise you will find yourself stuck in a rutt.
April 18, 2012 18:59
Scott, you're so obsessed with code it's manifesting as Freudian slips. I would like to try drinking some Code Zero though - that sounds enlightening.
April 18, 2012 19:28
Reading code is not unlike reading math proofs. It can be delightful when the proof is elegant, makes sense, and seems obvious after the fact. It can also be hell. The books you list are like the "Proofs from the Book" in math.

So you're both right - it just depends on the code.
April 18, 2012 19:31
@Randy

I appreciate this, but when you work in an environment where you just leave the office upset. All you want to do is forget about it.
April 18, 2012 22:38
Btw, the link to Jeff's blog post links to the Lil Wayne image instead...

Cheers,
Timothy
April 19, 2012 5:06
I would add to the list game programming books - years (all of them) before I was writing games I was reading game code. It's most fun to read through source code that is alien to the way you write.

The Game Programming Gems series is excellent - like Beautiful Code it is one chapter / one author / one topic style. There are many book that cover writing a type of game - they build the entire game over the course of the book.

I stopped paying attending to Jeff's reading recommendations when he dismissed a Petzold book because it didn't have code examples in color. Kids these days...
April 19, 2012 5:49
Unless my eyes deceived me, there does not seem to be a free online copy of Case Studies in Common Lisp. Just only some parts of the book and source code are free.
April 19, 2012 9:56
I've heard mixed reports about "Beautiful Code", but I think I'll check it out. A shame the Kindle version costs so much.
April 19, 2012 12:10
Scott, you need a smoking jacket with code patterns on it!
April 20, 2012 4:11
Great post as always. I really enjoy reading code from all over the place. It's definitely help me become a better problem solver. I also agree with some of the other comments, (IMO) no one should pay any attention to Jeff.
April 20, 2012 15:15
Wow, I think alot of people have missed Jeff's point and knee-jerked him in the plums quite unnecessarily.

Eddy Young and Phil got it.

Primarily, Jeff is advocating reading and understanding the source code as the primary form of documentation. I'm sure many people who have flamed him would agree with that.

I think the remark which has stolen the limelight somewhat is not entirely without merit however. Yes, it is great to read code and learn new techniques from it, but when I "settle down in a deep leather chair with [my] smoking jacket and a snifter of brandy" my idea of a good time is spending time with my family or tending to my other hobbies.

It peeves me greatly to hear people say that if you don't live and breath code 24/7 you are not a "real" or "passionate" developer.

It feels like all the post-Jobs soul searching about work/life balance seems to have been forgotten very easily.
April 20, 2012 19:59
You are both right. Jeff might be a little pessimistic, but he is telling some of us whiney coders what we need to hear. STFU, Dive in, and fix the problem. Reading code for fun and advancement of skills is one thing every code professional needs to do, but this blog came across as "more Responsibility and Less Finger pointing". Someone probably pissed him off that morning. :)
April 23, 2012 20:35
Scott,

You mentioned the book "Artificial Intelligence: A Modern Approach". I was happy to participate in a recent online class using that book, and it was taught by Peter Norvig (one of the authors) and Sebastian Thrun (leader of the Grand Challenge winning team, now at Google). Here's the address: https://www.ai-class.com/

Although the class is over, I believe anyone can still see the videos, and they help explain the concepts in the book A LOT. Both men are now teaching new classes at Udacity.com, and I'm looking forward to learning more from them in the future.
April 24, 2012 3:44
I love reading code and blogs about coding. I often work at night with some whiskey and a fine cigar. You have to be reading something and trying new things to keep up to date on coding and to better yourself.
April 28, 2012 0:22
Although brilliant, Jeff is a Mort. So it is not about the code details for him. Just sayin...
Ed
May 11, 2012 0:19
"I'll retire when I die." - Lil Wayne

Had to post that. Loved the picture.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.