TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Is it inefficient to execute programs while working?

2 点作者 abhnv超过 2 年前
tldr; I execute my programs without dry running them in my head first, is that inefficient?<p>I have a habit of executing the entire program, after I implement a feature to check if it&#x27;s working correctly.<p>I usually isolate my functions, in a small test environment, so the feedback loop is fast enough to highlight issues, if any.<p>But since I started working with a larger code bases, this approach feels inefficient. So my question is, would it be more efficient to read through the code and find out any typos or logical issues before actually executing the code?

2 条评论

GianFabien超过 2 年前
Depends on your environment. When writing C&#x2F;C++ code, I rely on the compiler to find many problems. Once a module compiles cleanly, I link with tests to verify and then the app. When using Python and Javascript, I just repeatedly run the tests and program. Of course, I do sort of dry run the function &#x2F; method &#x2F; class as I write it. I&#x27;m probably in the minority, but I do write copious comments to remind myself in the future why I did things the way I did.
评论 #32807306 未加载
dieselgate超过 2 年前
It seems difficult to say, one idea is you could proceed with this approach but then write tests for any failing conditions when they arise. It seems inefficient to check every line of code works after writing it as well - especially for larger systems with complex state setup.<p>Probably somewhere in the middle is right but will be different for everyone&#x2F;is variable
评论 #32806854 未加载