= Generic programming == Known programming articles chronologically sorted: • “Go To Statement Considered Harmful” author: Edsger Dijkstra date: 1968 example link: https://www.dcs.gla.ac.uk/~pat/cpM/choco4/nqueens/Goto-Harmful-Dijkstra.pdf • “Communicating Sequential Processes” author: C.A.R. Hoare date: 1978 example link: https://dl.acm.org/doi/10.1145/359576.359585 • “A plea for lean software” author: Niklaus Wirth date: 1995 example link: https://ia801608.us.archive.org/8/items/pdfy-PeRDID4QHBNfcH7s/LeanSoftware_text.pdf • “What Color is Your Function?” author: Bob Nystrom date: 2015-02-01 example link: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ • “From Imperative to Pure-Functional and Back Again: Monads vs. Scoped Continuations” date: 2015-08-17 author: Ron Pressler example link: https://www.youtube.com/watch?v=449j7oKQVkc example link: https://www.javacodegeeks.com/2015/08/from-imperative-to-pure-functional-and-back-again-monads-vs-scoped-continuations.html • “Notes on structured concurrency, or: Go statement considered harmful” author: Nathaniel J. Smith date: 2018-04-25 example link: https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/ impact: refines the notion of “structured concurrency” • “Backpressure explained — the resisted flow of data through software” author: Jay Phelps date: 2019-02-01 example link: https://medium.com/@jayphelps/backpressure-explained-the-flow-of-data-through-software-2350b3e77ce7 • “Parse, don’t validate?” author: Alexis King date: 2019-11-05 example link: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/ == Syntactic conventional names https://en.wikipedia.org/wiki/Naming_convention_(programming) lisp-case = kebab-case = brochette-case COBOL-CASE = TRAIN-CASE MACRO_CASE = ALL_CAPS snake_case = snail_case camel_Snake_Case Pascal_Snake_Case, Title_Case camelCase PascalCase == memory allocation bump allocator:: a simple pointer is maintained which tracks the end of the allocated memory commonly used for stack allocation represented by the sbrk() function on UNIX and memory.grow in WASM arena == region == zone:: contiguous block of memory instead of deallocating individual items, the entire arena is unallocated once all items are deallocated reduces memory management overhead depending on the implementations, arenas have uniform size (common) or variable size (less common) memory pool:: similar idea to arena common for real-time systems where allocations need to be predictable contiguous block of memory handle to access memory may be split into (pool index, block index, generation) pool index identifies the memory pool block index identifies the block/item within the memory pool generation verifies that the pool was not unallocated because the memory was kept allocated toooo long free list:: list of unallocated memory blocks which can be allocated again slab allocation (used in kernels like FreeBSD 5.0+ or Linux 2.1.23+):: memory for certain types (i.e. a certain size) is kept preallocated allocate? corresponding pre-allocated memory is returned unallocate? put memory on free list slab is roughly "some contiguous pages in memory containing pre-allocated memory chunks" SLOB (used in Linux kernel until 6.3):: "Simple List Of Blocks" - seems to be a slab allocator little memory usage for embedded systems suffers from external fragmentation first-fit algorithm for requested allocations https://lwn.net/Articles/157944 SLUB (default in Linux kernel 2.6.23):: "unqueued slab allocator" https://lwn.net/Articles/229984 https://lwn.net/Articles/229096 buddy allocation (e.g. used in jemalloc):: start with one large block, split the block into two buddies, does one buddy have the size a little larger than the requested size? then use this buddy, otherwise recurse usually sizes of 2^n are used little external fragmentation, some internal fragmentation internal fragmentation:: more bytes are allocated than actually needed (e.g. due to fixed-size requirements or alignment) external fragmentation:: items in a block are freed, but the free slots are too small to fit a new allocation overall the allocation request could be satisfied if the allocation are layouted out more compactly == Software patterns Strangler fig pattern:: architectural pattern which wraps old code with the intent to log access to the old code and eventually redirect the call to old cold with a new implementation through the same interface TODO see also Gang of Four TODO https://lukas-prokop.at/articles/2021-01-07-software-architecture-rules == objcopy === Embedding a file in an executable objcopy --input binary --output elf32-i386 --binary-architecture i386 data.txt data.o == xxd === Generate C character array source code from binary data file xxd -i [filename]