news
Programming Leftovers
-
Zach Flower ☛ Elseless
Here's a little "cognitive complexity" tip for your next programming project: get rid of your else statements.
Okay... maybe not all of them. But as many as you can, because unnecessary else statements can decrease the readability of your code in small, but often very meaningful, ways.
-
Luca Lombardo ☛ Who Owns the Memory? Part 2: Who Calls Free?
In the first part of this series, we saw that objects occupy storage, that storage has duration, and that the type system imposes structure on raw bytes. But we have sidestepped a question that dominates systems programming in practice: when heap-allocated memory must be released, who bears responsibility for releasing it?
-
Luca Lombardo ☛ Who Owns the Memory? Part 3: How Big Is your Type?
This is the third part of a series exploring how C, C++, and Rust manage memory at a low level. In Part I we examined how memory is organized at the hardware level. Part II explored ownership and lifetime, showing how the three languages answer the question of who is responsible for freeing memory and when access to that memory is valid.
-
MaskRay ☛ GNU indirect function
GNU indirect function (ifunc) is a mechanism making a direct function call resolve to an implementation picked by a resolver. It is mainly used in glibc but has adoption in FreeBSD.
For some performance critical functions, e.g. memcpy/memset/strcpy, glibc provides multiple implementations optimized for different architecture levels. The application just uses memcpy(...) which compiles to call memcpy. The linker will create a PLT for memcpy and produce an associated special dynamic relocation referencing the resolver symbol/address. During relocation resolving at runtime, the return value of the resolver will be placed in the GOT entry and the PLT entry will load the address.
-
Jussi Pakkanen ☛ Jussi Pakkanen: Converting Chapterizer from Cairo + Pango to CapyPDF
Chapterizer (not a great name, I know) is a tool I wrote to generate books. Originally used Cairo and Pango to generate PDF files. It works and was fairly easy to get started but has its own set of downsides: [...]
-
Python
-
HowTo Geek ☛ Make Python scripts smarter with regex: 5 practical re examples
If you work with strings in your Python scripts and you're writing obscure logic to process them, then you need to look into regex in Python. It lets you describe patterns instead of writing procedural logic. Let's look into some real-world examples where Python’s re module makes scripts smarter.
-
-
Standards/Consortia
-
Frills ☛ HTML named colors
Filterable HTML named colours with colour contrast values and copy functionality
Explore all 140 named colours supported by modern browsers! Complete with contrast values, easy filtering, and one-click copy. These built-in names work in both HTML and CSS, no HEX or RGB required.
-