Master Programming Advice for the Ages

David Warman has been writing code since 1967. With 50 years of experience, he has advice for creating superior software in terms of performance and reliability. The advice he presents in response to a question on Quora and his answer covers intuitive concepts oft washed over by alternative, mainstream counsel on software development technique. The question was, “What are some advanced concepts in programming that most average programmers have never heard of?” to which his reply can be summed up as consider the machine and consistent instruction execution (input into output) within a fixed time window.

If possible, avoid the following (remember, avoid is not the same as never):

  • Concurrency abstractions (threads, async frameworks, parallel processing language syntax).
  • Automatic recovery of allocated memory (generally known as garbage collection).
  • Algorithms higher than O(1) or O(n) complexity.
  • Too much boilerplate processing in the start and end of a function.
  • Languages that are not really compiled.
  • Be wary of global events and associated event interpretation.
  • Code libraries without source code.
  • Over reliance on IDE or gdb debugging when not dealing with hard crashes.
  • Computation that does not result in output.

If possible, try to emphasize the following:

  • Algorithms with O(n) or O(1) complexity.
  • Functional style programming with functions returning functions with the same signature (this can be done many languages besides the functional ones). I will also add that this can be quicker to code than OOP in some cases and require far less source files. Instead of laboring with 1 file for each class and/or 1 file for each interface and implementation, a function library can often exist across fewer source code files.
  • Higher order functions (see preceding point) in general.
  • Higher order functions combined with Finite State Machines (FSMs).
  • Schedulers in the code that leverage the preceding (4 points).
  • Designing sub-machines in with FSMs can be modular and combined (this is often not necessary, but is done with great regularity often accidentally, (see recurring switch statement patterns in code)).
  • Closures and coroutines can be okay if there is minimal stack involved and the situation allows headroom for state.
  • Pointer arithmetic combined with the preceding combined with hardware interrupt handling, register stacks, and other machine representations for data and computation.

The concepts presented here are core concepts in writing solid code. A huge challenge you see in most commercially distributed code (which many apply these ideas) is in combining these concepts with secure coding concepts. Code can be made to run fast, to run reliably, to run well and written in an immaculate way. The high art of code does emphasize these things and will for the foreseeable future. I’ve noticed some large software such as Microsoft SQL Server Management Studio 17 has so much boilerplate stuff going on that there is a huge regression in performance. However, such tools may be more secure and perhaps there is a tradeoff between fast, reliable, solid code and more secure, safe, reliable code and yet, even the latest SQL studio crashes from time to time and thus boilerplate does not always equal reliable. Malware theory holds that a good crash is a good entry point for malware so maybe the current concepts on safe isn’t so safe after all. Meanwhile, if the more timeless code concepts result in software that doesn’t crash and is more deterministic and when written by a true expert, is not susceptible to a crash, then maybe, just maybe such code can be more secure.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.