More from Paolo Amoroso's Journal
<![CDATA[My journey to using and programming computers started around 1983 with a Sinclair ZX Spectrum 48K, the very first I owned. At the time I was clueless. For example, I wondered whether, once I loaded a program from tape, I needed to write it back at the end of the session so that it didn't vanish when turning off the machine. The Sinclair ZX Spectrum Introduction and the Sinclair ZX Spectrum BASIC programming guides that came with the device were my first learning resources, complemented by the great Italian computer magazine MC-microcomputer. Aside from some books, in that pre-online era technical documentation wasn't easy to come by in Italy, especially foreign works in English. I pored over the Spectrum manuals, reread them many times, and experimented with the sample code. I've never been into gaming but did run many games to see what the machine could do. I've come a long way since then, hopefully. #retrocomputing #personal a href="https://remark.as/p/journal.paoloamoroso.com/the-origins-of-my-computing-journey"Discuss.../a Email | Reply @[email protected] !--emailsub--]]>
<![CDATA[I started working on the class Universe of GravityLoops, my gravity simulator in Interlisp and LOOPS. I defined the class itself and the main methods, Universe.Register and Universe.Simulate. The class represents a collection of bodies and manages the parameters and state of the simulation. Universe.Register adds a body to a universe, Universe.Simulate runs the simulation. In the C++ code of the article my design draws inspiration from, an instance variable of the class UNIVERSE holds a pool of bodies in an array, with the most recently added body indexed by another instance variable. In GravityLoops the corresponding instance variable bodyPool is a list which, as the article notes, is more versatile and doesn't need the index. Universe.Simulate, just a stub for now, is the core method. It will update the state of the simulation, display the bodies in a graphical window along with status information, and check whether the user interrupts the simulation. The C++ program runs the simulation until the user presses a specific key and GravityLoops will have a similar feature. I'll also have the program accept a number of time ticks to step the simulation through. For Universe.Simulate I'll mostly follow the C++ code. But I plan to revisit the decision after I have something running to experiment with. I may want to split the simulation functionality into more than one method to separate the simulation itself from output, or redesign control around LOOPS' active values. #GravityLoops #Interlisp #Lisp a href="https://remark.as/p/journal.paoloamoroso.com/representing-the-universe-of-gravityloops"Discuss.../a Email | Reply @[email protected] !--emailsub--]]>
<![CDATA[I started working on GravityLoops, a software that simulates a collection of bodies interacting under the mutual gravity. I develop it on Medley in Interlisp and its object extension LOOPS, the Lisp Object-Oriented Programming System. GravityLoops will show an animation of the bodies and their motions, along with facilities for defining the parameters of the system and controlling the simulation. Motivation I've been meaning to do a LOOPS learning project but none of the ideas I initially came up with clicked. I wanted something more complex than a toy but easy enough to implement with reasonable effort. The project should also incorporate naturally the features of LOOPS, such as the gauges library of graphical meters and dials for displaying quantities. I finally stumbled upon the gravity simulator described in the article Force-Based Simulations by Todd King in the September, 1989 issue of Dr. Dobbs Journal. It's just perfect. I'm adapting to LOOPS the design of the sample C++ code that comes with the article. It's nice as it reads like an object-oriented domain specific language for simulation. The code is so short and clean I can fully understand it despite my minimal C++. I never thought I would say that of C++. There is much to like of King's program starting from its domain, astronomy and physics, which overlaps with some of my passions. The project is period accurate too as when Dr. Dobb's Journal published the article LOOPS was still under development. And, along with window systems, simulation was among the killer applications object-oriented programming proponents pointed to. The program comprises only two, hierarchically unrelated classes, a shallow inheritance design more in line with the later evolution of object-oriented programming. But the application does offer other potential classes that are a good fit for LOOPS. For example, I plan to specialize the LOOPS class Window to represent the simulaton window. I will likely need more classes for the GUI, such as dialogs for entering the simulation parameters. LOOPS is one of the subsystems best integrated with the Interlisp environment and comes with good documentation. I want to experience this high integration, the ability of combining tools designed to work together that comes natural once you're familiar with the environment. Adapting King's program to the Interlisp environment is also an opportunity to employ useful programming techniques like screen buffering to improve animation fluidity. Plus, anything that draws pretty graphics is fun. Design To adapt Todd's design to LOOPS I create matching classes with similar instance variables and methods, named according to the LOOPS style. I will rename a few confusing methods, such as UNIVERSE::service() to register a body with a universe which I'll call Universe.Register, and UNIVERSE::big_bang() to run the simulation which will become Universe.Simulate. The C++ code represents a 2D vector as a struct that I map to an Interlisp record. A class seems overkill. Todd's program outputs to the MS-DOS text console via the conio library. GravityLoops instead will draw graphics in a window. So far the code implements the Body class that represents a body. I'm about to start working on the Universe class that holds a collection of bodies and manages the parameters and state of the simulation. Once the core classes are in place I will turn to implementing the animated simulation. #GravityLoops #Interlisp #Lisp a href="https://remark.as/p/journal.paoloamoroso.com/gravityloops-a-gravity-simulator-in-interlisp-and-loops"Discuss.../a Email | Reply @[email protected] !--emailsub--]]>
<![CDATA[Insphex adds the Hexdump item to the File Browser menu to view the hex dump of the selected files. The initial implementation called the public API for adding commands at the top level of the menu. To later move the item to the See sumbenu that groups various file viewing commands I resorted to list surgery, as the API doesn't support submenus. The problem is internal system details can and do change, which happened to the File Browser menu and led to an Insphex load error. I fixed the issue by reverting the public API call and now the item is back at the top level of the menu. Insphex is a hex dump tool similar to the Linux command hexdump. I wrote it in Common Lisp on Medley Interlisp. #insphex #CommonLisp #Interlisp #Lisp a href="https://remark.as/p/journal.paoloamoroso.com/rearranging-the-file-browser-menu-for-insphex"Discuss.../a Email | Reply @[email protected] !--emailsub--]]>
More in programming
In 1978, the ACM published an algorithm by Robert Morris for counting large numbers of events in small registers. It uses one byte to keep track of the approximate logarithm of the count, and randomly increments the logarithm with a probability that scales with the value of the count. You can tune the range and precision of the counter by adjusting the base of the logarithm. Morris suggests pre-calculating a table of probabilities so that no difficult calculations are needed at runtime. Recently I learned from emsenn about a 2009 paper by Miklós Csűrös titled approximate counting with a floating-point counter. It changes Morris’s algorithm to use a binary log-linear counter instead of a pure logarithm. It reminded me of my hg64 log-linear histograms, so I thought it would be fun to implement, especially since the algorithm can be made shorter and faster. representing a counter We need to choose the number of bits to use for the exponent and mantissa of each approximate floating point counter. Typically the exponent will be 5 or 6 bits, corresponding to an unpacked exact counter of 32 or 64 bits. The mantissa will typically be the rest of an 8 or 16 bit integer (though languages such as Zig and C23 allow more adventurous integer sizes). I’ll call the approximate counter type usmol and the unpacked counter type ubig. #define EXPBITS 5 #define SIGBITS 3 typedef unsigned _BitInt(EXPBITS+SIGBITS) usmol; typedef uint32_t ubig; static_assert(sizeof(ubig) * 8 == 1 << EXPBITS, "ubig must match EXPBITS"); It’s straightforward to extract the exponent and mantissa from a usmol counter. Unpacking a usmol into a ubig is slightly tricky. Like hg64 and IEEE754, normal numbers (with a nonzero exponent) have an implicit leading bit, and denormal numbers (exponent is zero) do not. The effect is that small counts are represented exactly in a usmol (up to 2*MANTISSA, covering denormal numbers and exponent == 1), and larger counts are shifted by the exponent. (I don’t need the inverse conversion here, but it is used by hg64 to map a sample to a histogram bucket, truncating the value by shifting right.) #define MANTISSA (1 << SIGBITS) static inline ubig exponent(usmol approx) { return(ubig)(approx / MANTISSA); } static inline ubig mantissa(usmol approx) { return(ubig)(approx % MANTISSA); } static inline ubig unpack(usmol approx) { ubig e = exponent(approx) - 1; ubig m = mantissa(approx) | MANTISSA; return(approx < MANTISSA ? approx : m << e); } bumping a counter Because binary floating point uses logarithms in base 2, we need the probability of incrementing the counter to scale with 2^-e. Specifically, we want the probability of increasing the counter to be 100% when its exponent is 0 or 1, 50% when the exponent is 2, 25% when it is 3, etc. Csűrös does this by getting a random bit e times in a loop and incrementing the counter if they are all zero. A more efficient way to do this on a computer is to get a ubig word full of random bits and count the leading or trailing zeroes. There are a variety of bit scan functions that differ in how they number bits and what they do when the word is entirely zero. The POSIX ffs() family has the advantage of no undefined behaviour, but it weirdly counts from one. However this oddity turns out to match the way denormal numbers give our exponent an off-by-one bias. So for instance, when our exponent is 2 and we want a 50% probability, we want ffs() to return 2 or more. OK, that determines when to increment the mantissa given a particular exponent. But how does the exponent get incremented? Like Csűrös, we put the exponent immediately to the left of the mantissa; when the mantissa overflows, it rolls over to zero and the exponent ticks up. No special cases are needed. The resulting code is short: usmol bump(rng_t *rng, usmol approx) { ubig r = ubig_random(rng); ubig z = (ubig)ffsll((long long)r); ubig e = exponent(approx); return(approx + (z >= e)); } considerations Morris allows you to smoothly tune the allowable range and precision of a counter by adjusting the base of the logarithm. By contrast, Csűrös has very lumpy 2^2^n choice of ranges; that isn’t necessarily bad because it’s normal for programmers to have to choose between uint32_t and uint64_t. Morris uses a lookup table to determine the probability of incrementing, which is tolerable for an 8 bit counter, but it can get large for wider counters. Csűrös just uses a few instructions and bigger counters don’t need much more. So I don’t think either algorithm is clearly better than the other, except that Csűrös has the winning fun factor of bithacking a bespoke floating point format.
Parallelize discovery and execution, but serialize judgement.
Sending email is easy. Making sure good emails land where they should is not.
This is an article about user preferences. It is also about the larger framework of decisions designers sit inside of when employing them, and the outcomes that they can create. I wrote this article because the power dynamics and downstream effects surrounding user preferences is something multiple accessibility practitioners I know are aware of. My, and their thinking about these dynamics and end results is worth being aware of. Discussing the concerns that surround how user preferences are introduced can also be, ahem, counterproductive to healthy working relationships when brought up in the moment. So, I am writing it out here instead for people to read and digest at their own pace. What are user preferences? For the uninitiated, user preferences are different modes you can set in your operating system to help you use a digital device. Examples include, but are not limited to: Dark mode, Reduced motion, Reduced transparency, Increased contrast, Forced colors, etc. All of these user preferences enable, improve, and enhance someone’s ability to operate digital experiences. Consequently, they can be considered assistive technology. However, someone enabling user preferences isn’t a given. This is worth emphasizing because the existence of user preferences can also serve as an excuse during the product or feature design process. Just because a user preference exists does not mean someone who could benefit from it is using it There are a whole host of reasons as to why this is. Here’s a few: Low digital literacy means someone does not know how to navigate to their operating system preferences, or that said preferences even exist in the first place. Someone might not know they have a disability, and consequently will not seek out a related user preference. Related, internalized ableism means someone does not think the accessibility section of operating system preferences applies to them. A device might be locked down by someone’s employer, with large swaths of functionality set to be restricted. A device may be shared due to economic circumstance, where individuals in disadvantaged communities share a device or access one from locations like a public library or shelter. A device’s operating system may not be updated to a version where support for the user preference was added. etc. An example of where the existence of user preferences gets abused A common example I’ve had to contend with is color contrast. A common response to contrast issues being brought up is to propose setting a high contrast theme that kicks in if someone has the increased contrast user preference enabled. This is done in an attempt to avoid the minimum contrast ratio demanded by the Web Content Accessibility Guidelines (WCAG) requires. More abstractly, this response enables a designer avoiding deeper inquiry into their sense of aesthetics. This in turn avoids questioning how personal opinions around taste impact the audiences they ultimately serve. The reason why a low-contrast-experience-as-default is a non-starter is obvious if you understand what the spirit of WCAG is getting at. It is also why a website offering an increased contrast theme switcher using color values in the UI that are too low contrast is also not a viable approach. That reason is content in its default state may be unable to be perceived. And if it cannot be seen, it cannot be read or used. It’s as simple as that. These examples, and other related ones compels a change of mindset. Accessible by default, opt-out by choice Disability intersecting with digital experiences creates a range of outcomes from mild annoyance, to hard barriers, and even direct harm. This intersection compels an approach that means proactively accommodating the widest swath of unknown people with unknown preferences, capabilities, devices, and circumstances as the default. Another example: I know someone who had a seizure because of a full-screen animation a website played. The animation implementation itself honored a reduced motion user query. However, the person did not know that the reduced motion user preference existed and consequently did not enable it. Are we to blame them? People who work in the digital accessibility space are already aware of this accessible-by-default approach. It is why the WCAG is phrased the way it is. As a positive example of this, this is why GitHub underlines its links by default now, but also enables you to switch link underlines off. However, this accessible by default, opt-out by choice mindset isn’t always present for designers. This brings about three tough, yet vital questions that need to be asked, and this article’s format is a safer way to provide the larger surrounding context of why they need to be asked. Who do you want to exclude? Asking this question in a structured way, in good faith at the beginning of a project is a great way to help build awareness and consensus. This question is what an in-house accessibility practitioner is likely thinking when they hear a proposal to present an accessible alternative hidden away under a user query. I will also note that asking it directly at later stages of the design process isn’t feasible in most professional environments. What are you deciding? Here’s another question your peer really can’t ask in the moment. Accessibility practitioners tend to think of their work as an output coming from an ethical or harm prevention way of thinking. Unfortunately, this kind of thinking isn’t always the most compelling or effective strategy in contemporary business culture. Because of this, there are three more pragmatic lenses we can view design choices through: Usability Constraining the methods of operation of a digital experience to work in only the ways you personally use something is a decision. And that decision limits how usable the experience is to others. In opposition to this artificially-applied constraint, conferring the ability for someone to efficiently navigate and take action on a digital experience is one of the main jobs you have as a designer. This applies to both the public and private sectors. Profitability Another main job of designers working in the private sector is to enable the creation and continuation of profit, and profitability is impacted by usability. To that point, poor usability leads to less profitability if your product is actively competing in the market. Consequently, choosing to limit usability also chooses to limit profitability. Here, in the context of lucrative SaaS contracts I would like to call out both the tyranny of the majority and also the correlations between age, disability, and decision-making power. Law At the end of the day it is a court—and not you—that decides whether or not a barrier is present for a disabled person using a service. Here, know two things: There is also plenty of precedent in the private sector in the United States to draw from, and also WCAG helps inform how to avoid many forms of barriers in digital experiences. I am not going to say that you are choosing to break the law when you lead with an inaccessible default. However, I will say that a jury might. Where do you want to place the burden? Learning about and enabling user preferences takes effort. Forcing disabled people to fiddle with obscure operating system preferences places the burden on them to get basic accessibility accommodation. Also know It is a fallacy to assume the presence of an active user query means someone is accommodating their disability. For example, I use a reduced motion media query on my laptop and phone because I am impatient and want OS transition effects to get out of the way and take as little time as possible. As alluded to earlier with my comments on age and decision-making power, it is also a fallacy to assume the presence of disability or use of a user query means a lack of ability, competency, or value. This mindset is largely due to how pervasive ableism—and how it shapes ideas about disability—is in our culture. Try sitting with this To quote my friend Soren: User preference settings or accessibility settings cannot replace our responsibility to design and build accessible apps and websites. The ideas and viewpoints shared in this post article are something you may not be exposed to due to both a historic lack of disability theory in design education, and also a lack of organizational prioritization of accessibility in design practice. Your ideas and values may be challenged by this, as well as your aesthetic sensibilities. Spend some time reflecting on why you feel this friction and unease, as well as the power and responsibility you wield as someone who creates digital experiences.
The US is updating its primary spatial reference system, replacing NAD 83 with NATRF 2022 and other systems.