TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Writing code that works on first go

23 pointsby chegra84almost 14 years ago

6 comments

qntmalmost 14 years ago
I instinctively distrust code that works first time. I advocate error-driven development.
评论 #2747624 未加载
评论 #2747693 未加载
评论 #2748070 未加载
dustingetzalmost 14 years ago
1. an ide/language with really good static analysis 2. aggressively minimize codebase complexity<p>done. when my code doesn't work the first time, and i'm writing in a static-typed language, it's usually due to high accidental complexity in my code or code i interface, requiring me to keep too much context in my head, causing logical problems and problem states to be non-obvious.<p>stupid errors like writing an if statement wrong, is sophomoric. "most common errors" really means avoiding mutable state &#38; leaky abstractions[1]. i do think the OP gets this, it just doesn't come across too clearly.<p>[1] nostrademons of HN, "how to become an expert swegr" <a href="http://news.ycombinator.com/item?id=185153" rel="nofollow">http://news.ycombinator.com/item?id=185153</a>
评论 #2748097 未加载
gtanialmost 14 years ago
Should generate some debates, depending on if you're from the static/dynamic typing, IDE vs. wetware, TDD or not, etc camps.<p>3. If you use IDE's or vim/textmate/emacs and a decent language plugin, you'll argue the IDE should match braces and insert skeletal control structures.<p>5. Self-contained function, so no side effects, isn't that part of the definition of functional purity in them "academic languages" (heh)?<p>6. How do you define edge and corner cases? Is there something like QuickCheck for your dev environment?
jaxnalmost 14 years ago
I think it would be great if there was a way to easily capture my "most common error categories".<p>Years ago I got bit a couple of times by assignment instead of comparison errors (i.e. if(x = 1) instead of if(x == 1))<p>I noticed a pattern and made a conscious to always put the variable last in comparisons, so for years I have written if(1==x) so that the compile would fail if I wrote if(1=x).<p>Having a way to see my most common errors would give the opportunity to look for similar error-proofing measures.
评论 #2747836 未加载
评论 #2747936 未加载
评论 #2748102 未加载
kstenerudalmost 14 years ago
I'm far more interested in code that works when it ships than code that works the first time it's run.<p>Code that works the first time it's run is magical, and therein lies the problem: Magic code is untested and unproven code. It offers a false sense of security, which is why it fills experienced developers with a sense of dread.<p>Until you prove that code's correctness (such as with tests), it is almost certain that it has nasty bugs in it that your initial successful run haven't uncovered. So what does having it work the first time give you? Bragging rights, maybe, but nothing of any real value to shipping code.
评论 #2747947 未加载
评论 #2748060 未加载
评论 #2748021 未加载
chopsueyaralmost 14 years ago
Non-IDE Python programmer comments, please?
评论 #2748485 未加载