Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes and no. There are underlying truths to programming that you can and should carry with you from environment to environment. Some are very difficult to put into words, but some are not. One example that is now considered trivial and well-known is "shun global variables"... but then, just today I was fighting with code that's hard to work with because it uses global variables. This stuff is always news to somebody....

Another more recent example that may pass into that peculiar state of "everybody agrees its common sense but by golly I sure see an awful lot of violations of it every week" is being suspicious of mutable state. I'm not quite 100% sold on the "never use mutable state" idea (getting closer every month, though...), but I sure am 100% sold on being suspicious of it. Doesn't matter what your environment is, that carries over. A lot of stuff does.



In a sense, global variables and mutable state are much the same. Even if the scope of the mutable variable is local, if it maintains state beyond any specific call, it has a global lifespan. I think using mutable variables within a function that don't live beyond the function is generally fine (for loops, etc).




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

Search: