Live data from Hacker News

Portrait of a Noob

steve-yegge.blogspot.com

41–43 of 43 posts

Re: Portrait of a Noob

#41

I've shared Yegge's disdain for static typing for quite some time. One of the best examples of how awful it can be is type hinting (optional type constraints on parameters) in PHP. Many times I've explained to people why type hints are awful thing deserving banishment to hell — along with Facebook suggestions and Microsoft product recommendations — but so many PHP programmers seem to love them! Now that I read this I…

I think part of the reason the type system in Haskell works and doesn't seem to get in your way is because of type inference.

Also, Haskell is more strongly (and richly) typed than Java\C++\C# so having strongly-typed code works really well.

About proving correctness, I guess you may have seen this amusing piece: http://perl.plover.com/yak/typing/samples/slide030.html

The type system found an infinite-loop bug in the code at compile-time.

Re: Portrait of a Noob

#42
This completely does not match my experience. When I first started programming, and even after a year or two in the industry, I used to write zero comments. Or maybe a line or two of comments every few thousands lines of code. Then, I started adding comments in places I thought required explanation and above function declarations. After I joined Google I was taught by smart people to add a comment every ten lines of code or so explaining what the next ten lines of code do.

I still don't write much comments when doing hobby programming at home (after all, the whole point of hobby is to indulge yourself), but there is no slightest doubt in my mind that abundance of comments is a good thing. I've never really seen code I considered overcommented. I see code which is severely undercommented all the time.

Re: Portrait of a Noob

#43
post #24

From the article: If you're a n00b, you'll look at experienced code and say it's impenetrable, undisciplined crap written by someone who never learned the essentials of modern software engineering. If you're a veteran, you'll look at n00b code and say it's over-commented, ornamental fluff that an intern could have written in a single night of heavy drinking. I have never seen this so succinctly expressed before.

A guy who works for us just read that and laughed and said: "To be honest I'd sit there and say both were equally shoddy and unlearned in their own way. There is a sweet spot middle ground that the really really good programmers learn" I suspect he is right.

I've found that the best compromise is to use verbose "n00b-style" commenting in header files (or wherever your interfaces are defined), and sparse commenting in the implementation. Interfaces are like contracts, so you want to make sure everything (including how corner-cases are handled) are explicitly described. With well-designed and fully-documented interfaces, the implementation code can usually be quickly understood even if it lacks comments and is written in a more "advanced" style.
Post reply on HN