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

To me, the biggest lesson I've learn from game programming tips and tricks was to not model the world exactly. Just model it enough to trick the eye. My first inclination was, "but of course you need the splats where the rain drop line ends! How would it make sense otherwise?" But it's not until you see the video that you get that, hey that worked well enough.

I imagine it's applicable to other realms of programming as well, like web programming. We should question if we really need something on the page, or if there's just some way to fake it or get away with doing less. Or same with scheduling notifications to be delivered. Does it really need to be real-time? Or can we just cheat a little since the tolerance is much higher?

Or can we just cheat a little since the tolerance is much higher?

Sure, we call this caching. Imagine you have a blog with comments. You can generate the page for each user when he wants it, and then it's a real view onto the data that you have available. Or, you can generate it once a second and just serve the stale version -- not much can happen in one second. Making that compromise is the difference between handling 10 requests a second and 10,000 requests a second. Almost always a good tradeoff.

(Doesn't NYTimes do this?)

I've noticed this on Reddit. When you submit a comment it's inserted into the page with a bit of JavaScript but when you refresh the page it's gone. Refresh the page again after a few seconds and it's there.

My point was that asking the question in the first place is good practice to avoid doing work you don't need to, rather than the actual specific examples I made up on the spot. But thanks for the example!

A good example is probably progressive enhancement with javascript. You create a page that is just HTML, CSS, and images and send that to the user, at the end you specify the scripts that load and add all the functionality and enhance the page. For most users they won't even notice that the javascript isn't loaded for 0.5 seconds. If they do click in that small window of non-operability, they get a little confused and click again, by which time it works. Most people won't even notice though.

This can be used to add fancy animations, add an actual embedded video over an image of an empty video player, add comments to the end of a blog post via AJAX. Most people won't even realize you're giving them static content initially.

This is such a good point. As little javascript should be run client-side on initial page load. What little does shouldn't be vital to the layout or presentation.

Not taking this into account causes unusual UI lag, frequent dropped initial clicks, fast responses from the server but slow page load times, or visual "chunking."

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