

Ask HN: Web dev's – how often do you run your code? - KhalPanda

For web developers: How often do you run your code? Due to the nature of hot code reload&#x2F;interpreted languages like PHP, how often do you find yourself flicking back to the browser to check on things?<p>Just curious. Despite knowing that 99% of the code I write will work as intended, I can&#x27;t help but play with whatever functionality I&#x27;m developing every few lines to make sure things are coming together correctly. Is this normal? Or do people knock out a load of code and run it all at the end?<p>I suppose test-driven development somewhat combats the need to check on things for reassurance and this doesn&#x27;t apply as much to front-end devs, since that&#x27;s a large part of the job.
======
stelian
I do the same. I don't trust myself to not make a typo or a mistake. Even with
CSS, I will rarely write more than a class without checking the result.
Because debugging is hard.

------
nkantar
It depends on what I'm doing.

Most of the time I can afford to simply refresh and see the results. This
applies to both my backend and frontend work some 99.99% of the time.

Occasionally, however, I find myself writing something slow, like a snippet
that accesses the database and "mangles" some data. In these instances I try
and write a bit more code before checking my progress, so as not to waste too
much time watching reruns.

------
onion2k
Often enough that I use the livereload feature in grunt-contrib-watch[1] so
whatever I'm working on is reloaded in my browser without me needing to
refresh it. I've found that automating things like that has made me check
things are working a lot less often.

[1] [https://github.com/gruntjs/grunt-contrib-
watch](https://github.com/gruntjs/grunt-contrib-watch)

~~~
MalcolmDiggs
I do the same thing with Gulp's version of LiveReload. Love it, huge time-
saver. [https://www.npmjs.com/package/gulp-
livereload](https://www.npmjs.com/package/gulp-livereload)

I'm also a big fan of BrowserSync. Can be used for a similar use-case, and
lets you (for example) see the site updated on your phone, tablet and laptop
whenever you make any change.
[http://www.browsersync.io/](http://www.browsersync.io/)

------
danpalmer
I'd definitely echo @nkantar's comment, I generally refresh every 2-10 lines,
depending on what it is I'm writing. I'll very often just dump out raw results
from whatever database querying and data mangling I'm doing until it looks
right, then start tidying up the output.

A while ago though, I was working on a C# .NET MVC application, debugging in
Visual Studio, and the round-trip time for making a change in code, reloading
the development server (hot-code reloading was not working, spent ~3 months
trying to fix it but never did) and then refreshing the page, ended up being
around 1 minute rather than the < 3 seconds I was used to. It was amazing how
much this affected my productivity, it was a severe hit.

------
mikewhy
I don't manually reload, and haven't for years. Like others, we use browser-
sync for reloading of front-end assets. Each save either reloads the browser
or applies the changes live, if you don't care to see what the output is yet,
don't look at the browser.

Paired with jasmine / karma / a guard runner to run any specs as files are
changed there's not much need for the refresh button in development.

------
woah
I write js, but I often won't run code for a long time. I put together a
project, using the code almost just as notation for ideas, and then go through
testing everything to bring it to completion. I suspect that frequent running
of code and heavy use of the debugger leads to, or at least makes it easy to
write spaghetti.

------
jhildings
Almost all the time, for nearly every if condition or new function. When I've
got the basics right I contiune with error handling etc and tests that also

