HNHacker News
TopNewBestAskShowJobs

dietrichepp

4,384 karma · joined October 29, 2012

http://www.moria.us/
submissionscomments
dietrichepp··on There is only one amphibian emoji
It’s a common misconception that dragons are reptiles. The are actually mammals. For some reason, historical depictions of dragons depict them with scales—this is inaccurate, real dragons have fur, give live birth, and even produce milk. I think the misconception of dragons as reptilian has an origin in early European depictions of dragons. Dragons are not native to most parts of Europe so we can assume that the artists never saw a real dragon. You can see similar inaccuracies in depictions of other animals, like lions, leopards, beavers, and elephants.

You’d think the Unicode consortium would know better. Dinosaurs are also miscategorized as reptilian but I can understand the mistake, because dinosaurs are extinct.

dietrichepp··on Google Closure Library has been archived
I’ve used the Google Closure Compiler for some JS13K projects, since it is so effective at producing small JavaScript code. At the time (a few years ago), there were some rough edges trying to use the Closure Compiler without the Closure Library, but they weren’t major problems—in fact, there was only one thing I added to my project as a workaround:

  const goog = { define(name, value) { return value; } };
That was it. I used it to select between development and release versions of the project, because the release version had to fit in 13 KB (compressed).
dietrichepp··on Notris: A Tetris clone for the PlayStation 1
I’m not sure the N64 would be easier. The graphics hardware in the N64 is complicated.

In some ways the console is really modern (perspective-correct texture interpolation, z-buffering, subpixel positioning). On paper, it seems a lot like a more modern system. But the hardware complexity is a beast. and the design is permeated with bottlenecks. Half of the graphics pipeline is taken up by the RSP, which is a fully programmable vector processor--sounds cool, but in practice it is unapproachable. 4 KiB of texture memory (and if you use a palette, half of it is the palette). RAM bandwidth is barely fast enough to handle 3D scenes.

https://www.copetti.org/writings/consoles/nintendo-64/

The folks working on LibDragon have done a lot of work to make homebrew a better experience, but you’ll note that support for 3D graphics is still only in a preview branch.

https://github.com/DragonMinded/libdragon

dietrichepp··on Notris: A Tetris clone for the PlayStation 1
That’s a difficult project. Congratulations for even getting a 3D environment you can fly around!

My own experience is that it’s so difficult to make homebrew games not just because of the technical challenges you have to solve making the game, but also because of the poor experience with tools and debugging. Pretty soon, you find your project taking up more time than you can reasonably spare. I think it’s impressive when people manage to get something interactive working on these old consoles, anything at all beyond a “hello world” template.

dietrichepp··on Jsfxr: 8-Bit sound maker and sfx generator
They have the same heritage.

https://www.drpetter.se/project_sfxr.html

https://www.bfxr.net/

dietrichepp··on Understanding Linear Feedback Shift Registers in FPGAs
> Instead of checking `state == advance(state, 232-1)`, which takes 32 multiplies, it's cheaper to do `advance(state, 1) == advance(state, 232), which only takes 2 multiplies (they both still take 32 squares unless you cache those). And actually the special case of 1 didn't require constructing the matrix at all, allowing a cheaper direct computation.

Ah! That makes sense. But for N=2^32-1, there are also checks for N/3, N/5, N/17, N/257, and N/65537.

dietrichepp··on Understanding Linear Feedback Shift Registers in FPGAs
> when comparing that advancing by a given number is a period, it's much more efficient to advance both sides to minimize the number of 1 bits

I’m missing something here… what do you mean by “advance both sides?”

> an informative period failure is 15 = 6 + 6 + 3. Doesn't this conflict with something in the article?

You’re talking about, say, P(x) = x^4 + x^2 + 1, for a four-bit LFSR? This will have three nontrivial cycles, with length 6, 6, and 3. Rather than talk about this specific polynomial / specific set of taps, we can consider that the initial (non-zero) state is in one of those three cycles. There are three possibilities for the length of a cycle:

1. Maximum period 2^k-1. In this case, 15.

2. Period which is a factor of 2^k-1, such as 3.

3. Period which is not a factor of 2^k-1, such as 6.

We can distinguish these case by picking an initial state and then doing a series of checks, where we advance the LFSR by N steps, and then see if it is in the initial state again.

For exactly the LFSRs with maximum period, the LFSR will be in the initial state after advancing 2^k-1 steps, but it will not be in the initial state after advancing (2^k-1)/p steps for prime factors p of 2^k-1. In the case of a 4-bit LFSR, we check N=15, N=5, and N=3. The cycles of length 6 will fail the test because they will be in a different state after advancing 15 steps. The cycles of length 3 will fail because they will be in the same state after advancing 3 steps. The end result is that the LFSR with cycles of length 6, 6, and 3 will be rejected, no matter which cycle the initial state is in.

> tradition makes people produce LFSRs with very few taps but if you're doing it in software there's no real reason you have to do anything other than keep them even and use the end bits.

The reason I was looking at this in the first place was out of a kind of retrocomputing interest, and using something like 0x100001b as your polynomial for a 24-bit LFSR can make the implementation slightly shorter / faster, on some older CPUs and with memory constraints.

It was easy to find a lot of handwaving and code / numbers copied from place to place, and I wanted to know how to generate the polynomials / pick the taps in the first place. The program I wrote just goes through the polynomials in lexicographic order, so it’s not actually trying to pick the fewest number of taps, but it will prefer sets of taps where the taps are all clustered on one side.

dietrichepp··on M 4.8 – 2024 Whitehouse Station, New Jersey Earthquake
Personally, I’d rather have the generators off when the earthquake hits!
dietrichepp··on M 4.8 – 2024 Whitehouse Station, New Jersey Earthquake
I can think of some ideas: parking the heads on hard drives is one.

Magnetic hard drives are sensitive to vibration. You can shout at hard drives and measure the effects (video: https://www.youtube.com/watch?v=tDacjrSCeq4).

One of the worst-case scenarios is a head crash. A head crash will damage the media and may result in data loss. https://en.wikipedia.org/wiki/Head_crash

My guess is that earthquakes powerful enough to cause a head crash are powerful enough for widespread destruction anyway, but I’m no expert. I did some quick searches for hard drives damaged by earthquake, and the only results I got were scenarios where the hard drives or the whole rack got knocked over by the earthquake and hit the floor.

dietrichepp··on Understanding Linear Feedback Shift Registers in FPGAs
I have a more mathematical / software oriented article about LFSRs here:

https://www.moria.us/articles/demystifying-the-lfsr/

dietrichepp··on Electronic project kits: hands on with a vintage 160-in-1 (2016)
I had one of these! The 130-in-1, maybe?

It has that “wow” factor, but as I kid I think I moved on to breadboards pretty quickly. That, and we had a bunch of Engineer’s Mini-Notebook by Forrest Mims III. These kits are very cool but I remember that it felt a little more like paint-by-numbers.

dietrichepp··on Electronic project kits: hands on with a vintage 160-in-1 (2016)
During the same era, science museums picked up some of the slack and now have hands-on chemistry labs. Depending on where you live.

I have a lot of fond memories of, like, going to OMSI and doing the experiments in the chemlab.

dietrichepp··on Building for DOS, OS/2, and DOS on a MacBook Apple Silicon
A different option is to grab a standard ELF toolchain for i386, like GCC + Binutils, and then convert your ELF binary into a format that can run on DOS.

Which is what I did: https://github.com/depp/elf2dos.git

This is not really a polished, supported product, just a program I wrote to make DOS programs on Linux or Mac.

dietrichepp··on Leaving Arizona – the Story of the Motorola 6800 part 2 and creation of the 6502
The main difference between X and Y is in the indirect addressing modes.

You can use X as an index when you are looping through an array of pointers.

You can use Y as an index when you are looping through an array, where you have a pointer to the beginning of that array.

There are also a couple operations that always use X as a source or destination. There’s TXS/TSX, but no TYS/TSY.

https://www.masswerk.at/6502/6502_instruction_set.html

dietrichepp··on Leaving Arizona – the Story of the Motorola 6800 part 2 and creation of the 6502
I think of it as having a nice set of 256 “registers”, in the zero page at addresses 0-255. I think of the A register as kind of an intermediate location for data that is going from memory to the ALU or the ALU to memory. The article says as much:

> In effect the 6502’s ‘page zero’ in memory provides a large number of ‘pseudo’ 8 and 16-bit registers, slower than real registers, but still faster and more versatile than having to use other parts of memory. A skilled programmer making effective use of ‘page zero’ could write code that was fast when compared to other 8-bit designs.

I haven’t done a lot of 6502, though. I learned Basic on the Apple II when I was young but moved to Think Pascal, HyperCard, and CodeWarrior on the Mac.

dietrichepp··on Automatic Syntax Error Recovery (2020)
Why are the code snippets animated? That’s such a frustrating way to read.
dietrichepp··on Dennis Ritchie on the priorities of && || vs. == etc. (1982)
Choosing false = 0 and true = 1 is putting the cart before the horse.

It is equally true that 1*0=0 is the same as false|true=true, and 0+1=1 is the same as true&false=false.

But it is also not true that 1+1=1, so it is probably wrong to equate 'or' with '+'. The operation has the wrong properties.

As someone who sometimes dabbles in electronics, 0 = true makes a lot of intuitive sense to me. You have your pin with an open collector, your pull-up resistor, and “true” (as in, it is true that the transistor is conducting) pulls the voltage to ground, which is 0.

As someone who uses a Unix shell, 0 = true makes a lot of intuitive sense to me.

  $ true; echo $?
  0
  $ false; echo $?
  1
dietrichepp··on Dennis Ritchie on the priorities of && || vs. == etc. (1982)
My problem here is that I distinguish between multiplication and addition by seeing which one distributes over the other.

  a * (x + y) = (a * x) + (a * y)
However, the reverse doesn’t work…

  a + (x * y) =? (a + x) * (a + y)
Why is this a problem?

  a ∧ (x ∨ y) = (a ∧ x) ∨ (a ∧ y)
  a ∨ (x ∧ y) = (a ∨ x) ∧ (a ∨ y)
Both are true. So, who are we to say that one corresponds to multiplication, and the other corresponds to addition? The two operations are too similar to each other.
dietrichepp··on Do we think of Git commits as diffs, snapshots, and/or histories?
> This is an excellent comment and one should also note that the claim is wrong.

I’ll pretend that this isn’t pedantry. I can understand why you’d say this, but I think you just haven’t explored the way that git diff works, including the configuration options it takes.

  $ git diff 'HEAD^'
  diff --git a/file b/file
  index efb8e76..ca03496 100644
  --- a/file
  +++ b/file
  @@ -1,3 +1,3 @@
   This is context.
  -I am studying tonight.
  +I am not studying tonight.
   This is also context.
Try it with --word-diff…

  $ git diff 'HEAD^' --word-diff
  diff --git a/file b/file
  index efb8e76..ca03496 100644
  --- a/file
  +++ b/file
  @@ -1,3 +1,3 @@
  This is context.
  I am {+not+} studying tonight.
  This is also context.
dietrichepp··on Ask HN: What 1980s/90s-era shareware did you purchase?
I was a Mac user back in the 1990s… bought some games like Taskmaker, Spacestation Pheta, Avernum (a 2000s remake of Exile from the 1990s). Later on, Carbon Copy Cloner.

I think I may have used a pirated Escape Velocity key.

dietrichepp··on Booking.com hackers increase attacks on customers
The ideal solution is that each of the front desk / office staff use their work credentials to access booking.com. One customer accounts, many user accounts. Use OIDC so you’re not entering your work password on booking.com.

I know it’s not gonna happen industry-wide. But this is how we do things everywhere I’ve worked for the past many years.

dietrichepp··on Rust std fs slower than Python? No, it's hardware
The way I describe mmap these days is to say it allocates address space. This can sometimes be a clearer way of describing it, since the physical memory will only get allocated once you use the memory (maybe never).
dietrichepp··on Zelda the Movie Shows Nintendo Has Learned Its Lessons
Global offset table. When you go to the theater to see it, you’ll find a piece of paper on your seat with the address of the real theater written on it. This means you can still buy tickets to your local theater, but Nintendo can show the movie at position-independent theaters, dynamically.
dietrichepp··on A linear algebra trick for computing Fibonacci numbers fast
> what if you use the closed-form answer, but without any floating-point or other approximations

You can use a field extension here, ℚ(√5), to represent your numbers. The numbers would be represented as pairs, (a,b), which represents the number a+b√5. You can see for yourself that this set is closed under addition and multiplication.

But when you try to implement code that computes exponents with this representation, you’re probably going to fall back to the old “repeated squaring” trick. But that’s how you calculate exponents with your matrix representation anyway—and you can note that the matrix powers (for this matrix) always take the form

  | a b |
  | 0 a |
So you can represent these matrixes as (a,b) pairs anyway. We are right back where we started—our state is represented as a pair of numbers, and we use repeated squaring to calculate an exponent.

Sometimes these different ideas for representing the problem give us new insight or new algorithms, and sometimes it turns out to be a new perspective on the same piece of code.

dietrichepp··on A linear algebra trick for computing Fibonacci numbers fast
My own personal experience is that, in linear algebra, there are a lot of different ways to prove the same thing. When you search for a proof of something, you may find a proof that is overly basic and verbose, or a proof that is overly advanced and terse.

Finding an explanation of a linear algebra concept that strikes the right balance can be time-consuming or difficult. This is why you see, for example, a hojillion different articles explaining what quaternions are. Everybody is most comfortable at a different place on the complexity spectrum—from “a vector is (x,y,z), here are rules for how that works” to “a vector space is an abelian group V, field F, and a map in Hom(F,End(V))”.

dietrichepp··on A linear algebra trick for computing Fibonacci numbers fast
I think the proof for the closed-form version is accessible to people with a background in linear algebra. The matrix is diagonalizable (not all matrixes are diagonalizable, but this one is):

  M = P Δ P^-1
Here, P is some invertible matrix and Δ is a diagonal matrix. The powers of M reveal how useful this is:

  M^N = (P Δ P^-1) * … * (P Δ P^-1)
If you adjust the parentheses, you’ll see N-1 terms of (P^-1 P), which can be removed, giving:

  M^N = P Δ^N P^-1
The powers of a diagonal matrix is done by taking powers of the entries on the diagonal.

You see the φ values (1±√5)/2 in the matrix Δ.

Diagonalization of a 2x2 matrix is simple to do on paper. The diagonal of Δ contains the eigenvalues of M, which can be found using the quadratic formula. Proving that this is a correct way to diagonalize any diagonalizable matrix is more of a chore, but for this specific 2x2 matrix, you can just show that that you’ve found the values for P and Δ.

This is very elegant mathematically, but I would not use the closed-form solution if I wanted the exact answer, because you’d need a lot of precision, and that’s inconvenient.

dietrichepp··on Ask HN: What outdated tech are you still using and are perfectly happy with?
I had a 2013 MBP and only upgraded this year, earlier in 2023.
dietrichepp··on Why is Debian the way it is?
Yeah, maybe it’s not inconsistent any more. But meanwhile, systemd has gotten really nice, even a good version of rc.d seems awful by comparison.

I had the same feeling when Apple came out with launchd in 2005. It felt like such a massive improvement over the existing state of things. Systemd also feels like a massive improvement.

dietrichepp··on Why is Debian the way it is?
Yeah, I agree.

Systemd is incredibly controversial among a niche group of people who have strong opinions about how init & core system functionality should work, and then there’s an outer ring of people who focus on one or two problems with some relatively minor problems that Systemd caused for which there are viable workarounds. Like how Systemd terminates processes that belong to your session when you log out.

I remember writing SysV style init scripts or rc.d / BSD style init scripts. It was awful. You had all these copy-pasted shell scripts with various gaps in functionality depending on who wrote them. Getting a service to run in Systemd feels like heaven by comparison. I don’t even care about, like, Docker.

I think the reports of problems (like background processes getting termed on logout, how any security problems in Systemd tends to be severe by nature) were just so numerous compared to the reports of the benefits (like the boot time improvements and the massive improvements running daemons). It was some bad decisions and a lot of bad PR, but the overall impact IMO is very positive.

dietrichepp··on Why is Debian the way it is?
Yeah. I keep coming back to Debian after trying out another distro for a while.

There are some specific complaints I have about technical choices for Debian, like the way daemons autostart post install. But these complaints are outweighed by the benefits of using a distro with coherence across packages and upgrades.

Apt is also just such a phenomenal package manager. It is fast out of the box, and supports some relatively tricky scenarios—like using stable for your system, but a newer Nginx from backports. Feels like I can get the newer features for the one or two packages that I really care about, and then use something stable and boring for everything else.

← PreviousPage 2 of 32Next →