HNHacker News
TopNewBestAskShowJobs

beautron

160 karma · joined September 23, 2023

submissionscomments
beautron··on Vesuvius Challenge 2023 Grand Prize awarded: we can read the first scroll
I enjoyed the attention given to Herculaneum in a computer game called Rome: Pathway to Power (released in 1992). You start the game as a slave who has to escape Herculaneum before Vesuvius erupts. I loved the game as a kid. It's sort of like an isometric immersive sim (with a clunky interface). It got me interested in ancient Rome.

I hope to visit Herculaneum some day.

beautron··on Analysis of Bach's information-dense music
These are orthogonal concepts.

Roman numerals can describe scale degrees and harmonic function in any temperament. They do not require equal temperament to "work"; they work just as well in just temperament.

The numerals describe the degree/chord's relationship to the tonic. The difference is that in just temperament, you cannot switch which degree/chord is tonic (Roman numeral I) without re-tuning, while in equal temperament you can switch freely.

The Roman numeral notation did come a little while after Bach, but I believe the concepts the notation represents are older (though some of the concepts may have been more implicit in the past).

beautron··on How Doom didn't kill the Amiga
I grew up with a C64, which I loved. But my Dad would tell me stories about the Amiga, and we'd go look at one in the neighborhood computer store (Software Etc.—loved that place!). The store clerk was more than happy to show off the machine to us. And we'd dream about how someday we'd get one.

But by the time that day came, the writing was on the wall, and we bought an IBM 486 25mhz from Sears.

I feel like we dodged a bullet. But, at the same time, I get a sort of warm, fuzzy nostalgia every time the Amiga comes up. It was my future dream computer.

I love reading articles like this. It's a window into a path I was almost on.

And I really loved my C64. It's sad somehow that the PC won... In the mid 80s, the PC was so uninspiring compared to the other home systems, at least to a kid who liked colorful games and wild sounds.

beautron··on New GitHub Copilot research finds 'downward pressure on code quality'
If the box is simple, then it's easier to cast each individual complexity of the system, as needed, into an interpretation that fits and reinforces the box.
beautron··on From slow to SIMD: A Go optimization story
I feel like were talking past each other. I'm not saying that C has a slicing operator, or that it's typical to define one as a function, or that it's typical to define a slice-like struct in C.

I'm saying that if you look at how arrays get used in C, you'll see that you're usually passing around extra numbers with them. So Go added syntax than encapsulates this. And it encapsulates the most general case (hence both a length and a capacity, even though most cases in C only use one number).

Instead of passing (char *, int) in C, you just pass (slice) in Go. And the Go slicing operator gives a nice syntax for selecting ranges of buffers.

But a Go slice is just a pointer to an array underneath, and I think it's best to always think about them that way. And then it's natural that mySlice[:2] would keep the same underlying capacity, and that future appends would mutate that capacity. Defaulting mySlice[:2] to mean mySlice[:2:2] seems less convenient overall to me (though prevents mistakes like in your original hi/lo example, but those come from not thinking of slices in terms of the underlying array).

beautron··on From slow to SIMD: A Go optimization story
Yes, I'm saying Go's slice operator (and slice type, and related functions) grew out of experience from the way arrays are used in C.

To me, this becomes obvious if you read The Practice of Programming by Kernighan and Pike, the latter of which was a co-designer of Go. If you read the book, which was written well before Go, and pay attention to how it uses C arrays, you can almost feel Go slices emerging. The slice syntax perfectly encapsulates the C array bookkeeping.

beautron··on From slow to SIMD: A Go optimization story
Dear Lord, no! I depend on cgo for my game!

What's more, I have no complaints about cgo. It hasn't been a performance problem at all (my game runs smoothly at 240hz). And the interface for binding to C is quite simple and nice to work with (I made my own bindings to SDL2, OpenGL, and Steamworks).

Cgo did make cross-compiling trickier to set up, but I managed to do it with a fair amount of elbow grease (Windows and MacOS builds on my Linux desktop).

beautron··on From slow to SIMD: A Go optimization story
I think slices are wonderfully intuitive... if you've worked with C.

Slices encapsulate an ubiquitous C pattern, where you pass to a function: a pointer (to an initial array element), and a length or capacity (sometimes both). This pattern is directly encapsulated by Go's slices, which can be thought of as something like:

  type Slice struct {
      Ptr *Elem
      Len int
      Cap int
  }
I love Go's slice syntax. It's the right piece of syntactic sugar. It removes tedium and room-for-mistakes from this prevalent C pattern. It lets me work as precisely with memory as I do in C, yet everything is simpler, lighter, and breezier.

For example, I'm making a game in Go. I don't want to be allocating memory throughout the game (which can cause frame drops), so instead I allocate giant arrays of memory on launch. Then I use slices to partition this memory as needed.

Some of these arrays get their elements re-accumulated at some interval (every level, or every frame, etc.). And so it works nicely to first set them to zero length:

  myMem = myMem[:0]
Notice that the myMem slice now has zero length, but still points to its same underlying array. Then I perform the accumulation:

  for ... {
      myMem = append(myMem, elem)
  }
Again, I don't want to be allocating in general, so I care very much that append continues to use myMem's preexisting capacity.

All this is to say, I don't see slices as being the way they are for the "sake of optimization." Rather I see them as an ideal tool for working with, referring to, and partitioning memory.

beautron··on Modeless Vim
Emacs uses the word "mode" to mean something different than Vim does.

An Emacs "mode" corresponds more closely to what Vim calls "plugins" (Emacs's "major modes" are like Vim's "filetype plugins", and Emac's "minor modes" are like Vim's other "plugins").

Vim's modes are more foundational in the sense that all Vim plugins are structured and organized in terms of the same set of modes. The core of Vim is the modes (insert, command, etc.), which are then customized. Emacs calls the customizations themselves "modes".

I don't consider Vim's definition of "modal" contrived, and I don't consider Emacs to be "modal" in the same way (though you can of course customize it to be).

beautron··on Modeless Vim
For me, Vim is not only (drastically) faster, but also more fun.

In Vim, I enjoy the process of text editing itself (in addition to any joy derived from the substance of the text edited).

beautron··on Modeless Vim
> Vim purports to be more efficient than other editors because it's a modal editor, but that's nonsense.

My understanding is that Vim purports to be efficient because it lets users make precise edits (large or small) with minimal input.

beautron··on Modeless Vim
> You have to glue together small painful commands to do what you want.

Painful?

Physically or mentally?

Physically I find Vim to be pain-free. I've studied and I practice good typing form, which is important—I would look there before blaming any physical pain on Vim's commands.

Mentally I find Vim's interface to be beautiful. Learning it gives your mind an amazingly coherent structure for thinking about the process of text editing.

beautron··on Modeless Vim
Modes are the core concept on which Vim's design is structured. They organize both the interface and the user's mental model of the text editing process. I did a quick case-insensitive search over Vim's help files, and they matched 'mode' 4470 times.

The first thing you must learn (to use Vim) is that it is modal. And this detail really tends to stand out when first meeting Vim. I think "modal" is a nice word to concisely describe and differentiate Vim.

beautron··on Veritasium: The SAT Question Everyone Got Wrong [video]
Oh wow! Hadn't heard it like this before, but now I like this way the best. I can finally see clearly where that "extra" rotation comes from.
beautron··on Text Editor: Data Structures
How does Vim feel sluggish? Everything in Vim feels instantaneous to me.
beautron··on Maze Generator
This is an enjoyable book! It's an easy read, and the code is nice and straightforward. It avoids getting lost in any programming weeds, revealing the maze algorithms and techniques clearly.

I used what I learned to add a maze generator to the game I'm working on! So far only one level makes use of it (since most levels are better off being hand-crafted), but I have ideas for some other interesting levels that might use the maze generator.

beautron··on C++ Should Be C++
>> I'm always saying that good way to learn language patterns and idioms is to look into standard libraries implementations. > >Why would that be true?

This isn't always true, and can't be generally expected, but I think it is true in the case of Go's standard libraries. These are high quality, and are one of my top examples of good, real source code to study (along with the DOOM and Quake source code). A nice touch in Go's library documentation is that you can click any API element (type, function, etc.) to be brought directly to its source code.

Yes, there are differences between writing libraries and writing programs. But there is value in studying well-written source code, even when it has concerns and requirements that differ from yours. You can adapt what you learn to your needs.

beautron··on The Shunting-Yard Algorithm (2011)
A few months ago I wanted to add arithmetic parsing to my game's debug console, and went with this approach.

While researching the area, I came across this exact blog post, and thought it was perfect. It explains things clearly and concisely (without even needing code/pseudocode). Granted, it's a simple algorithm, but this post was just so much nicer than any of the (higher ranked) results that Google gave me. And it has no ads!

It made me sad. Years ago, it seemed like Google helped me find lots of nice little pages like this one. It's much harder to find web articles of this quality anymore.

Back to this article specifically, I particularly appreciated the "Advanced Usage" section, where it briefly (and clearly!) goes over some useful extensions to the algorithm. These were very much on my mind (since I wanted parentheses and function calls). They are simple extensions to a simple algorithm, but it's nice to have them summarized for you before you dive in.

It was a breezy joy to implement (did it even take an hour?). And I can think of other easy ways to extend its capabilities further. This style of arithmetic parsing would be a wonderful thing for beginner programmers to cut their teeth on. It exposes them to a number of important computer/programming ideas, yet is simple to implement while also being directly useful.

beautron··on Yabai – A tiling window manager for macOS
For me, it's less that I want to "tile" windows, than that I want whichever one I'm using to be fullscreen and distraction-free.

I don't like visual clutter. If I'm using a program, I want it to be the only thing on my monitor. But sometimes I want to keep more than one program open, or even be switching between them. Tiling window managers let me give each program its own full screen, and quickly switch between them with a keyboard command. I love it.

And then there's the exception that proves the rule: Sometimes I do want to have two programs on the same screen, side-by-side. An example would be Vim in the left 2/3rds of my screen (where I am programming), and then a browser with some documentation on the right 1/3rd. Obviously tiling managers also support this case, and I prefer them here too vs. mousing around windows into place (which still tends to leave behind windowing chrome and other visual clutter).

That reminds me of another reason: I prefer keyboard to mouse. I've learned good form and technique for keyboard use, which let me use it frequently and for long periods while avoiding injury. But I just can't figure out a way to use a mouse or trackpad that isn't harmful, were it repeated enough (a vertical mouse goes a long way though).

Tiling managers let me do everything using keyboard (unless the "tiled" programs themselves require mouse), whereas traditional windowing managers pretty much require mouse. I find it both more ergonomic and much faster using the keyboard.

beautron··on Making games in Go for absolute beginners
I'm making a game in Go, and it runs perfectly smooth on my 240hz monitor (and should run perfectly smooth on 1000hz monitors once we get there).

The garbage collector has not been an issue, because I use memory the same way as if I were doing it in the C language: Allocate all memory used by the game at program launch. I find this scheme easier to work with in Go than in C, because Go's slice type is a natural fit for partitioning these launch-allocated blocks of memory (as they get used and reused during the game).

The garbage collector doesn't get called if you don't allocate. And for the most part¹, it's easy to reason about where Go allocates (if you know C). So my rule is: Always know where your memory is; never allocate.

This may sound like it's going against the grain of Go, but I find Go to be handily amenable to this style. I had my concerns going in, but it just hasn't been a problem. My game runs silky smooth.

At this point, my only concern about using Go to make a game is that bringing the game to consoles does not have a well-trodden path.

¹ So far, the only thing that has surprised me is that assigning a value type (like an int) to an interface allocates! (So another rule is to only assign pointers to interfaces [pointers to memory allocated at launch].) And while this was a surprise to me, I was pleased with how quick the debugging went: I noticed frames were dropping, so I ran go's pprof tool, which led me directly to the (freshly coded) interface assignment that was stealth allocating. (Also, this allocation becomes less surprising the more I think about how interfaces are implemented.)

beautron··on The $55M saga of a Netflix series nobody will ever see
I enjoy Aliens—it's the bigger, more over-the-top production of the two.

But I prefer Alien for its intimacy and slowly growing horror. John Hurt's character's arc stunned me as a child, and is still one of my favorite turns of storytelling. I love the set design and overall tone of the movie. It's a different space mood than other space movies. And it nails that feeling of being hunted on a spaceship (so far as I would know).

beautron··on Cosmopolitan Third Edition
Same for me on centurylink. I've run into this on a number of sites. I don't like it.
beautron··on Was Rust Worth It?
> Later comes along Go. No dependency management at the start. There ended up being two ways of specifying dependencies. At least one included putting github.io/username/package into your code. That username changes and all your code has to change. Awful design.

"github.io/username/package" is using a domain name, just like Java. Changing the username part is like changing the domain name--I don't see how this is any worse in Go than in Java.

If you don't like that there's a username in there, then don't put one in there to begin with. Requiring a username has nothing to do with Go vs. Java, but rather is because the package's canonical location is hosted on Github (which requires a username).

I don't know why so many programmer's use a domain they don't control as the official home of their projects--it seems silly to me (especially for bigger, more serious projects).

beautron··on Banging errors in Go
The caller can check if the result != nil.

If I get a result that came with a non-nil error, and I still plan to do something with the result, then it seems natural to think about the possibility that the result might be nil. I would consult the function's documentation, and maybe its source, and then maybe put in a nil check.

This is too rare a problem to be worth adding complexity to the language. There needs to be a big payoff for adding complexity. A language gets hard to use if it adds micro-complexities all over the place for the sake of preventing rare programming mistakes.

beautron··on Banging errors in Go
Documentation has immense value beyond just this specific error situation. Its a burden worth taking on regardless of how errors are handled.

So it's not that a type is more of a burden than documentation, but rather that a type is an additional burden (since we're taking on the documentation burden either way).

I like that Go's error handling is simple enough that I can keep all its rules in my head. And I like that the other parts of Go are simple like that too. It allows me to easily know exactly what is going on at the language level (while my attention is focused on higher levels).

beautron··on Banging errors in Go
I've been using Go for almost a decade, and I don't recall this ever biting me. It doesn't feel like a trap.

Go has a convention of documenting each function with a comment (which is adhered to by the standard library, my own code, and any other code I'd consider worthy of depending on).

So when I think this subtlety matters, I check the documentation. Usually I don't care either way: When I get a non-nil error, I typically don't care about the other result (whether partial or the zero value).

The distinction rarely matters in practice (and when it does, the documentation is there). I think this simplicity is the right tradeoff (vs. being burdened with more types to think about).

beautron··on Banging errors in Go
This is exactly how I feel about Go error handling (which I prefer to other languages).

Error checks become a syntactic formalism that are easy and quick to type, easy and quick for the eye to scan, but have just enough presence to make sure you think through your error situation whenever and wherever you need to.

Go gives me a confidence in my code's error handling that is harder to get in other languages I've used, where the error situation is typically muddier.

beautron··on Banging errors in Go
I don't consider this an anti-pattern, but part of the flexibility gained by Go's lightweight approach to error handling. I believe Go was even designed with this use case in mind (the standard library uses it in many places, and I don't consider their documentation about it "snarky").

Sometimes you want to return a partial result along with an error. Go's idiom of returning multiple values, with the final value being an error, allows this situation to be easily supported.

beautron··on The Banality of Genius: Notes on Peter Jackson's Get Back (2022)
This is a neat perspective.

I think it can help for avoiding creator's block (more commonly known as "writer's block," but I'm being more general here).

It's easy to avoid getting started because you don't think you have a good enough idea yet. But when the thinking gets long, try just diving in and making something. Now you have something to react to, and you can often quickly identify things you don't like about it.

Then you think of ways to avoid these things you don't like, and dive back in to make the next something. Gradually you fill in the negative space, and after enough iterations are left with something good.

beautron··on The Banality of Genius: Notes on Peter Jackson's Get Back (2022)
I see what you did there ;)

Yes, Paul McCartney is a big fan of the album Pet Sounds. He bought a copy for each of his children to teech them about music. He elaborates about Pet Sounds a great deal in the interview below:

https://www.the-paulmccartney-project.com/interview/paul-mcc...

← PreviousPage 2 of 3Next →