Append-Only Programming
Ian Fisher's append-only programming methodology adds code to a single C file without editing, promoting clear interfaces and small functions, but complicating error correction and maintenance. Modifications are suggested for practicality.
Read original articleIan Fisher introduces a novel software development methodology called append-only programming, where all code is added to a single C file without the ability to edit existing code. This approach encourages programmers to define interfaces before implementations, promotes the writing of small functions, and enhances code readability by reflecting the programmer's thought process. However, it presents challenges, such as the need to append corrections for erroneous subprocedures and the potential requirement to retype entire programs. Fisher uses shell commands to enforce the append-only rules, but he acknowledges that this method is more of a fun challenge than a practical coding strategy. He reflects on the difficulties of maintaining and troubleshooting code under this paradigm, noting that it can become tedious. While he initially aimed to write programs incrementally, he found that real coding often requires revisiting and revising earlier functions, which append-only programming complicates. Fisher concludes that while the experiment was interesting, it may not be worth repeating in its original form. He suggests modifications, such as creating a header file for declarations and splitting functions into separate files, to maintain the spirit of append-only programming while reducing monotony.
- Append-only programming involves adding code to a single C file without editing existing code.
- The methodology promotes clear interface definitions and small functions but complicates error correction.
- Fisher uses shell commands to maintain the append-only structure but finds it impractical for real coding.
- The approach can lead to tedious retyping and troubleshooting challenges.
- Suggested modifications include using header files and splitting functions into separate files for easier management.
Related
Holding a Program in One's Head (2007)
The article highlights the cognitive processes in programming, emphasizing mental retention of code, the impact of distractions, and advocating for smaller teams and independent work to enhance creativity and understanding.
Functional PHP (2015)
The author advocates for using functional programming in PHP, highlighting benefits like improved modularity, reduced complexity, easier debugging, and enhanced maintainability through small, single-purpose functions and higher-order functions.
A high-velocity style of software development
High-velocity software development prioritizes coding and experimentation, enabling rapid testing and iteration. Small, reusable functions enhance code quality, while consistent styles improve collaboration and reduce confusion.
John Carmack on Functional Programming in C++
John Carmack discusses functional programming's benefits in C++, highlighting its ability to clarify code states and reduce multithreading issues. He emphasizes pure functions for improved safety, reusability, and maintainability.
If I Could Wave a Magic Wand
Rewriting code may not improve quality and can overlook edge cases. An iterative approach is preferred, balancing idealism with current limitations, and focusing on incremental improvements for better outcomes.
The unison language ecosystem leverages that property to implement distributed computation where the code can be shipped to remote workers in a very fine grained way, but I guess this building block can be used for other ideas (I don't know, didn't quite put my mind into it but sounds very interesting)
I kind of doing this with my AoC with my literary programming approach where I add only code to the markdown file that is then processed by the MarkDownC program [1], which takes all the C fragments in de markdown file and puts them in the right order to be compilable, overwriting earlier definitions of functions and variables. So, each markdown file, one per day [2], shows all the steps how I arrived at the solution. I do use a normal editor and use copy-and-paste a lot when making new versions of a certain function.
[1] https://github.com/FransFaase/IParse/?tab=readme-ov-file#mar...
[2] https://github.com/FransFaase/AdventOfCode2024/blob/main/Day...
On the other hand, it's not a problem if you start bottom-up, which is a natural style when writing in C; the low-level functions are at the top (and the standard headers included at the very top can be thought of as a sort of lowest-level), while main() is at the bottom.
"Once @cognition_labs AI Engineer Devin gets good enough, I will have it implement each feature as a series of Pull Requests: - One or more Refactoring PRs - modify structure of existing code but no behavioral change. - A final PR which is "append only" code - no structural change, only behavioral."
Gives you lovely stuff like the Win32 API (introduced in 1993 and still very much a thing!). CreateWindow, CreateWindowEx, CreateWindowExEx (OK, I made that up...), structs with a load-bearing length field, etc. etc. And read some Raymond Chen on the abuse that customers inflict on the more 'private' stuff...
- It would be less challenging if function pointers variables are used instead of function. In this case, the code appended later may override the function variables it needs to fix/change
- Since all the code is there, it is possible to invent some convention to compile/run previous versions without CVS machinery
These days of course we just use git, but there was a day that we could see the progress of a codebase by watching the diffs as they streamed in off the reels ..
10 print "helo"
20 print "world"
10 print "hello"
Worked as expected in both GW-BASIC 1.0 and pcbasic, printing "hello\nworld". Listing the program after loading it only shows the modified line 10.A bit awkward since the BASIC editor/REPL itself can not be used. It would work for writing BASIC using a regular text editor and then just running it with BASIC as an interpreter.
My thoughts in this is to somehow create a system where additional rules or changes to behaviour have marginal cost.
I am interested in the Rete algorithm, a rule engine algorithm. But we could run this sort of thing at compile time to wire up system architecture.
Boilerplate or configuration is an enormous part of programming and I feel there really could be more tools to transform software architecture.
Well, it's ridiculous. IMO, of course but... seriously. One of the greatest (and even joyful) things about being a software developer is that you can change old code. Literally go there, rewrite things, and end up with a new version of code (which is presumably better in some respect).
Art progresses with extreme restrictions. The same way Schoenberg put seemingly absurd restrictions in his music ((very roughly) don't repeat the same note before playing every other note etc...) to create something radically novel, we as software developers can do so to advance our art as well.
[1] This method is the anti-thesis of the common "never rewrite a working program" software development methodology. Here, the experiment is to see what happens if we always rewrite, and never add or modify, i.e. refactors are never allowed, instead if things need changing we need to re-design the whole thing top-bottom with the new understanding.
Anyone telling me to write software using `cat >> foo.c` better come with some receipts.
Sorry, but what? This does not make any sense.
like LLMs
very cool
Related
Holding a Program in One's Head (2007)
The article highlights the cognitive processes in programming, emphasizing mental retention of code, the impact of distractions, and advocating for smaller teams and independent work to enhance creativity and understanding.
Functional PHP (2015)
The author advocates for using functional programming in PHP, highlighting benefits like improved modularity, reduced complexity, easier debugging, and enhanced maintainability through small, single-purpose functions and higher-order functions.
A high-velocity style of software development
High-velocity software development prioritizes coding and experimentation, enabling rapid testing and iteration. Small, reusable functions enhance code quality, while consistent styles improve collaboration and reduce confusion.
John Carmack on Functional Programming in C++
John Carmack discusses functional programming's benefits in C++, highlighting its ability to clarify code states and reduce multithreading issues. He emphasizes pure functions for improved safety, reusability, and maintainability.
If I Could Wave a Magic Wand
Rewriting code may not improve quality and can overlook edge cases. An iterative approach is preferred, balancing idealism with current limitations, and focusing on incremental improvements for better outcomes.