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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Algorithms we develop software by

270 点作者 xal9 个月前

20 条评论

nkozyra9 个月前
Write everything (generally, new features) twice has turned out to be really good strategy for me, but it doesn&#x27;t sit well with bizdev or project managers and tends to be perceived as unnecessary slowness.<p>But if you plow through a feature and get it &quot;working,&quot; you&#x27;ll do much of that work cleaning up the logic and refactoring through your first pass. What rewriting allows you to do is crystalize the logic flow you developed the first time and start cherry-picking in a more linear fashion to meet the blueprint. It also tends to reduce the urge (&#x2F; need) for larger scale refactorings later on.
评论 #41284959 未加载
评论 #41285065 未加载
评论 #41285076 未加载
评论 #41288300 未加载
评论 #41293561 未加载
from-nibly9 个月前
&gt; &quot;gun to your head, you have to finish in 24 hours, what do you do?&quot;<p>PSA: if you are a project manager &#x2F; owner or some other similar position you do not get to ask this. This is a personal educational excercise not a way to get stuff done faster.
评论 #41284899 未加载
评论 #41285072 未加载
评论 #41284666 未加载
评论 #41290726 未加载
评论 #41284938 未加载
评论 #41284841 未加载
评论 #41292846 未加载
pkoird9 个月前
A good code, in my opinion, is written by appropriate selection of suitably contained abstractions. The problem with this, and the article does try to talk about it, is that for you to select appropriate abstractions, you need to know the &quot;entire&quot; thing. Which is to say, you need to have a knowledge of something that isn&#x27;t there yet.<p>In other engineering disciplines like say civil or architecture, this problem is solved by using a good blueprinting paradigm like CAD layouts, but I find a distinct lack of this in software[1]. Ergo this advice which is a rephrasing of &quot;know first and build later&quot;. But it is also equally easy to lose oneself in what&#x27;s called an analysis paralysis i.e. get stuck in finding the best design instead of implementing a modest one. In the end, this is what experience brings to table I suppose, balance.<p>[1]closest I can think of are various design diagrams like the class diagrams etc.
simpaticoder9 个月前
Very interesting suggestions, all worth trying. Having a very capable coworker can help here, because they can show you what can be done in a short amount of time. Specifically I&#x27;ve noticed that some devs get &quot;winded&quot; by a change and want to take a break before moving on; others simply continue. This ability can be improved with practice, both within and across contexts. Doing things quickly is valuable for many intrinsic reasons that are often overlooked because we descry the poor extrinsic reasons. As with car repair, the odds that you forget how to reassemble the car scales with the time the repair takes. Similarly, if you can execute a feature in a day (especially a complex one that requires changes to many parts of a repo, and&#x2F;or more than one repo) this is much less risky than taking many days or weeks. (To get there requires that you have firm command of your toolset in the same way a mechanic understands his tools, or a musician understands her instrument. It also requires that externalities be systematically smooth - I&#x27;m thinking particularly of a reliable, locally repeatable, fast CI&#x2F;CD process.)<p>(The calculus here is a little different when you are doing something truly novel, as long periods of downtime are required for your brain to understand how the solution and the boundary conditions affect each other. But for creating variations of a known solution to known boundary conditions, speed is essential.)
a1o9 个月前
&gt; Write everything twice<p>There&#x27;s an enhancement in a software I use&#x2F;maintain that I wrote once and lost (the PC I wrote kaput and I was writing offline so I also didn&#x27;t backup). It was an entire weekend of coding that I got very in the zone and happily coded.<p>After I lost that piece of code I never could get the will to write that code again. Whenever I try to start that specific enhancement I get distracted and can&#x27;t focus because I also can&#x27;t remember the approach I took to get that working and get lazy to figure it out again how that was done. It&#x27;s been two years now.
评论 #41285261 未加载
jesse__9 个月前
This is one of the best &quot;programming advice&quot; posts I&#x27;ve ever read, right up there with the grug brained developer.
评论 #41287162 未加载
评论 #41286178 未加载
评论 #41285478 未加载
vanjajaja19 个月前
&gt; If, after a few days, you can&#x27;t actually implement the feature, think of what groundwork, infrastructure, or refactoring would need to be done to enable it. Use this method to implement that, then come back to the feature<p>really good, this is key. building a &#x27;vocabulary&#x27; of tools and sticking to it will keep your velocity high. many big techs lose momentum because they dont
评论 #41287865 未加载
Etheryte9 个月前
I really like the footnote that indirectly says that sometimes you just need to spin up a background thread to figure something out. Resonates heavily with my experience, to the point where I feel like a lot of the value my experience brings is identifying this class of problems faster. You stumble onto it, recognize it&#x27;s the think about it passively type and move on to other things in the meanwhile. It would be easy to bang your head on it and get nowhere, sometimes you just need to let it sit for a bit.
halfcat9 个月前
Dan Abramov talks about WET (write everything twice) [1] as generally a good approach, primarily because you often don’t know the right abstraction up front, and a wrong abstraction is way worse than a copy&#x2F;paste.<p>He has some good visuals that illustrate how incorrectly dependent and impossible to unwind wrong abstractions can become.<p>[1] <a href="https:&#x2F;&#x2F;youtu.be&#x2F;17KCHwOwgms" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;17KCHwOwgms</a>
rmnclmnt9 个月前
&gt; Write everything twice<p>I’d say « Write everything three times » because it usually take 3 versions to get it right: first is under-engineered, second is over-engineered and third is hopefully just-right-engineering
评论 #41289663 未加载
hintymad9 个月前
I remember seeing somewhere a popular list of top 10 algorithms used in systems, and it&#x27;s kinda depressing to realize that the most recent algorithm on the list, Skip List, was invented roughly 30 years ago, and every single one of them was taught in an introductory data structure course. That is, we most likely do not need to study the internals of algorithms nor need to implement them in production. For such a long time in history, smart and selfless engineers already encapsulated the algorithms into well abstracted and highly optimized libraries and frameworks.<p>Of course, there are exceptions. ClickHouse implemented dozens of variations of HashTable just to squeeze out as much performance as possible. The algorithms used in ClickHouse came from many recent papers that are heavy and deep on math, which few people could even understand. That said, that&#x27;s just exception instead of norm.<p>Don&#x27;t get me wrong. Having a stable list of algorithms is arguably a hallmark of modern civilization and everyone benefits from it. It&#x27;s just that I started studying CS in the early 2000s, and at that time we still studied Knuth because knowing algorithms in-depth was still a core advantage to ordinary programmers like me.
评论 #41286624 未加载
layer89 个月前
This reminds me of <a href="https:&#x2F;&#x2F;ntietz.com&#x2F;blog&#x2F;throw-away-your-first-draft&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ntietz.com&#x2F;blog&#x2F;throw-away-your-first-draft&#x2F;</a>, previously discussed in <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37003910">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37003910</a>.
justinl339 个月前
&gt; start over each day This reminds me of &quot;spaced repetition&quot; in learning theory. Drilling the same problem from scratch is a great way to get better at iterating through your rolodex of mental models, but so many people prioritize breadth because they think it is the only way to generalize to new problems.
ww5209 个月前
I usually won&#x27;t rewrite the whole thing twice, but would rewrite parts of it multiple times. For the very least, the second time around I would format things and add comments to make things easier to be understood. Code should be written for comprehension.
DrScientist9 个月前
I find the follow approach quite useful.<p>1. First write down a bunch of idea of how I might tackle the problem - includes lists of stuff that I might need to find out.<p>2. Look at ways I break the task down to &#x27;complete-able in a session&#x27;.<p>3. Implement, in a way the code is always &#x27;working&#x27; at the end of session.<p>4. Always do a brain dump into a comment&#x2F;readme at the end of the session - to make it easy to get going again.
aleph_minus_one9 个月前
&gt; Another heuristic I&#x27;ve used is to ask someone to come up with a solution to a problem. Maybe they say it&#x27;ll take 4 weeks to implement. Then I say &quot;gun to your head, you have to finish in 24 hours, what do you do?&quot;<p>Pretend to be capable of doing this, and in the short moment where the other person is not attentive, get the gun and kill him&#x2F;her. This satisfies the stated criteria:<p>&gt; The purpose here is to break their frame and their anchoring bias. If you&#x27;ve just said something will take a month, doing it in a day must require a radically different solution.<p>&gt; The purpose of the thought experiment isn&#x27;t to generate the <i>real</i> solution.<p>:-)<p>---<p>Lesson learned from this: if you can&#x27;t solve the problem that the manager asks you for, a solution is to kill the manager (of course you should plan this murder carefully so that you don&#x27;t become a suspect).<p>:-) :-) :-)
gregors9 个月前
&quot;you have 24 hrs&quot; and &quot;write everything twice&quot; ......they go hand in hand don&#x27;t they? You&#x27;re definitely going to rewrite it if you slap code out there.
steve9189 个月前
I like the &quot;gun to the head&quot; heuristic but I would probably rephrase it to be something like &quot;If you only had 24hrs to solve this or the world would come to an end&quot;.
mgaunard9 个月前
Most software has a finite lifetime of a few years. You rewrite everything eventually.<p>What you should be worried about is the code that hasn&#x27;t been rewritten in ten years.
评论 #41288374 未加载
评论 #41292317 未加载
mempko9 个月前
&quot;Write everything twice&quot; is a great heuristic. Extreme programming and unit tests is a dumb and wasteful technique. You end up cornering yourself.
评论 #41284892 未加载
评论 #41284862 未加载