Hacker News new | past | comments | ask | show | jobs | submit login

"This code omits error checking in the interest of brevity and simplicity."

In the interest of brevity and simplicity, and at the cost of correctness and reliability - I understand the intent, but I believe that there is a balance to be struck on this for all code, whether example, prototype, or production.

Because sample code so very often chooses an extreme of that spectrum, it is easy for neophyte coders to end up thinking that is how all code should be written.




I'd love to see a widget that would let you display and toggle between two versions of the code on a webpage:

* a first version illustrating the core concepts

* a second more complex version aimed at showing proper coding practices including comments showing where you can have performance or security issues.

It would be a nice addition to the many source code beautifiers/formatters out there.


Unfortunately if it's the first semi-working code sample in a Google result, it will still end up in production somewhere no matter how crappy it is and how many warning labels are put on it.


This is a really cool idea, and I'm going to have to see if I can incorporate it into future blog posts. I'm not sure if it'll be worth the trouble, but it certainly bears thinking about.


I guess it depends on the audience and the intent of the tutorial. Other posts on his blog include things like "let's have a look into the Objective-C runtime" and "let's unwind the stack on multiple threads to get a nice crash report", so I assume he's writing for people that understand enough to know that a final implementation needs to be robust and reliable.


You got it. While stuff for beginners is undoubtedly useful, I leave that to others.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: