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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Walter Bright: Crafting Self-Evident Code with D [video]

19 点作者 open-source-ux超过 1 年前

1 comment

peter_d_sherman超过 1 年前
There is some serious programming wisdom in this video! For that reason, it is worth re-watching in the future. What follows is a highly abridged list of some of the relevant takeaways from various time points in the video:<p>06:54 Don&#x27;t try to make one language look like another<p>07:34 Don&#x27;t reinvent bool<p>10:36 Code flows from left to right, top to bottom<p>13:31 Reduce conditionals<p>14:59 Avoid negation<p>19:31 Simplify compound if conditionals<p>21:39 Reduce the number of casts<p>22:57 Use self-documenting language features<p>25:56 Pass an abstract sink for a function&#x27;s output<p>27:58 Pass files as buffers rather than filenames to be read<p>30:34 The caller, not the callee, should call the environment<p>31:45 Callee writes to buffer, caller writes to file<p>32:30 Use function pointers (or templates)<p>34:10 Functions should be in one of two categories, not both<p>35:48 Line things up<p>36:43 Use ref instead of *<p>Of these, I think I find:<p><i>&quot;25:56 Pass an abstract sink for a function&#x27;s output&quot;</i> -- the most potentially interesting...<p>Why? Because it can almost be thought of as borderline functional programming -- within an Imperative and&#x2F;or Object-Oriented programming language... at least as far as the function using this method goes... it also has a wide variety of applications, i.e., instead of having a function do memory allocation (requiring that memory to be freed somewhere else in the program), why not pass such a function an additional memory allocator function pointer or object -- where the allocation (and subsequent deallocation) of memory -- is managed in some other well-defined place in the code...<p>Anyway, it&#x27;s a great video! Well worth watching!
评论 #38019075 未加载