Have you ever looked at code you wrote five years ago and wondered what you were thinking? Just think of code you authored even further back! You’ve heard about secure code, safe code, clean code, modern code, optimized code, clever code, user-friendly code, structured code, effective code, etc. Everybody thinks they write easy-to-understand code (including Walter), but your future self will likely have the last word on that.
Here Walter talks about writing easy-to-understand code. The talk is based on decades of experience writing code that is hard to understand. He shows how D makes it easy to write easy-to-understand code. It won’t cost anything, either. And who knows? Maybe your future self will sigh contentedly with “I wrote that!”
The PDF slides are available here:
https://dconf.org/2023/slides/bright.pdf
DConf '23 Homepage
https://dconf.org/2023/index.html
The D Programming Language Home
https://dlang.org/
#dlang #dconf #programming
TIMECODES:
00:00 Title and Introduction
03:43 A self-evident example in airplane cockpits
06:54 Don't try to make one language look like another
07:34 Don't reinvent bool
08:30 Horrors blocked by D
10:36 Code flows from left to right, top to bottom
13:31 Reduce conditionals
14:59 Avoid negation
19:31 Simplify compound if conditionals
21:39 Reduce the number of casts
22:57 Use self-documenting language features
24:43 Tips for memory allocation
25:56 Pass an abstract sink for a function's output
27:58 Pass files as buffers rather than filenames to be read
30:34 The caller, not the callee, should call the environment
31:45 Callee writes to buffer, caller writes to file
32:30 Use function pointers (or templates)
34:10 Functions should be in one of two categories, not both
35:48 Line things up
36:43 Use ref instead of *
37:02 Takeaways
38:43 Q: How to use the language to document range usage?
39:40 Comment about negating is expressions
41:04 Comment about doing something Walter said should be avoided
42:19 Comment about telling people what to do vs what not to do
44:35 Comment about sinks
46:27 Q about using nested scopes to divide steps
47:13 Q: Has Walter considered restricting access to global variables?