Programming Leftovers
-
Stephen Kell ☛ Rambles around computer science
This requirement is common if you do research with compilers. The time-honoured way is to write a Python script or Perl script or shell script that parses a command line, delegates to the real compiler while also doing the desired extra stuff. Then you build the existing software using this wrapper script, e.g. by setting CC to point this wrapper script.
There are some problems with this.
-
James Bennett ☛ There can't be only one
The basic idea of the Highlander problem is that you can cause yourself a lot of trouble, as a programmer, by introducing a “there can be only one!” limit into your code. To take a real example: I once worked at a company that managed medical visits via video calls. The original data modeling for this treated a visit as being between one patient and one doctor. That becomes a problem when the actual visit in front of you involves the patient, a primary doctor, a nurse who does triage, a second doctor who consults on the case, a translator who helps them all communicate with the patient, and the patient’s legal guardian/decision-maker. A better model would accept that the visit has multiple participants and multiple possible roles, and keep track of who was in which visit and in which roles.
-
Buttondown LLC ☛ State and time are the same thing
There's no trick here, the answer is "different photos". Since the clock looks different, time must have passed between the two. More formally, we can represent the clock as a state vector of (hours, minutes, seconds). Since the two pictures have different state vectors, they must represent different photos.
-
Benny Siegert ☛ The code is not enough
In my job, I read a lot of code. I read more code than I write. I suppose that’s true for many engineers at the senior level or above.
For instance, a new piece of code integrates with a library, or with another code base, and I want to understand how the integration works. Or I am the supplier of the infrastructure/library/framework and I need to debug someone’s (mis-)use.
-
Karl Seguin ☛ Zig's BoundedArray
In Zig an array always has a compile-time length. The length of the array is part of the type, so a [4]u32 is a different type than a [5]u32. But in real-life code, the length that we need is often known only at runtime so we rely on dynamic allocations via allocator.alloc. In some cases the length isn't even known until after we're done adding all the values, so we use an std.ArrayList which can dynamically grow as values are added.
-
Perl / Raku
-
Perl ☛ What's new on CPAN - July 2024
Welcome to “What’s new on CPAN”, a curated look at last month’s new CPAN uploads for your reading and programming pleasure. Enjoy!
-
-
Python
-
Juha-Matti Santala ☛ Quick prototyping with sqlite3
Many applications require some way of storing information and often that storage is a database. Setting up a full database integration with something like Postgres or MySQL can be a project of its own and might not be worth the work in the early prototyping stage.
Python has built-in bindings with database system sqlite3 that can operate on files on the disk or run completely in memory. I really like the flexibility of it when figuring out things before commiting to building a more permanent database system for the software.
To use it in Python, you need to have sqlite3 itself installed. If it’s not already installed in your system, you can follow the instructions behind the previous link to find out how to get it up and running on yours.
-