HNHacker News
TopNewBestAskShowJobs

moefh

853 karma · joined June 8, 2011

submissionscomments
moefh··on In Defense of C++
> All of such cases require unsafe blocks in Rust.

It's true that Rust makes it much harder to leak memory compared to C and even C++, especially when writing idiomatic Rust -- if nothing else, simply because Rust forces the programmer to think more deeply about memory ownership.

But it's simply not the case that leaking memory in Rust requires unsafe blocks. There's a section in the Rust book explaining this in detail[1] ("memory leaks are memory safe in Rust").

[1] https://doc.rust-lang.org/book/ch15-06-reference-cycles.html

moefh··on Creating a VGA Signal in Hubris
The internal DAC in most of these microcontrollers is way too slow for VGA. According to this[1], for STM32 you can generally expect at most 1MHz without external additions; that's way too slow even for e.g. 320x240 which has a pixel clock of over 10MHz.

A lot of hobbyist projects use simple improvised DACs made with a few resistors. Here are mine for the ESP32[2] and the RP2040[3] (Raspberry Pi Pico), both use 320x240 (just the standard 640x480 with half the pixel clock and every line repeated to half the resolution in both width and height).

[1] https://www.st.com/resource/en/application_note/an4566-how-t...

[2] https://github.com/moefh/esp32-loser

[3] https://github.com/moefh/pico-loser

moefh··on UTF-8 is a brilliant design
> This is how the HTML5 spec works and it's been phenomenally successful.

Unicode does have a completely defined way to interpret invalid UTF-8 byte sequences by replacing them with the U+FFFD ("replacement character"). You'll see it used (for example) in browsers all the time.

Mandating acceptance for every invalid input works well for HTML because it's meant to be consumed (primarily) by humans. It's not done for UTF-8 because in some situations it's much more useful to detect and report errors instead of making an automatic correction that can't be automatically detected after the fact.

moefh··on UTF-8 is a brilliant design
It's not 2 million, it's a little over 1 million.

The exact number is 1112064 = 2^16 - 2048 + 16*2^16: in UTF-16, 2 bytes can encode 2^16 - 2048 code points, and 4 bytes can encode 16*2^16 (the 2048 surrogates are not counted because they can never appear by themselves, they're used purely for UTF-16 encoding).

moefh··on UTF-8 is a brilliant design
UTF-16 is an abomination. It's only easy to parse because it's artificially limited to 1 or 2 code units. It's an ugly hack that requires reserving 2048 code points ("surrogates") from the Unicode table just for the encoding itself.

It's also the reason why Unicode has a limit of about 1.1 million code points: without UTF-16, we could have over 2 billion (which is the UTF-8 limit).

moefh··on A clickable visual guide to the Rust type system
> Only difference being that you need to do a bit more work to determine negativeness (work which in hardware you'd already likely have the bulk of for determining is-zero).

The work needed to calculate the overflow flag (done in every add/sub operation in most ISAs) is also way more complicated when the high bit does not represent sign.

moefh··on Will Smith's concert crowds are real, but AI is blurring the lines
That's insane. Here's the same-ish frame from the original: https://imgur.com/a/dWS20oP

The extreme blur here was obviously a creative choice by the director/editor, the rest of the video has lower resolution but it's not nearly that bad (which is why Bowie still looks like himself in other parts of the upscaled video).

The process used to upscale the video has no subtlety, it's just "make everything look crisp, even if you have to create entirely made-up faces".

moefh··on What is a color space?
The amount of energy in a wave depends on both its wavelength and amplitude.

So a "blue wave" has more energy than a "red wave" if both have the same amplitude (blue has a shorter wavelength, and energy is inversely proportional to wavelength). But you can have a "blue wave" with the same energy as a "red wave" if you increase the amplitude of the "red wave" to compensate for its longer wavelength.

moefh··on Is 4chan the perfect Pirate Bay poster child to justify wider UK site-blocking?
Right, what I meant is that private copying is allowed because these levies exist -- but the fact that they exist only allows you to make private copies, not (as was stated) download anything.
moefh··on Is 4chan the perfect Pirate Bay poster child to justify wider UK site-blocking?
No, it doesn't. From that Wikipedia entry:

> A common misconception is that levies are compensation for illegal copying such as file sharing. This is incorrect, however, levies are only intended to compensate for private copying that is legally allowed in many jurisdictions. For example, uploading a purchased CD on to another personal device such as a laptop or MP3 player.

"Private copying" is generally allowed under copyright law -- except that under DMCA, it's only allowed if you're not circumventing DRM. So for example, you can legally make a private copy of a CD, but not a Blu-ray disc.

moefh··on RFC 9839 and Bad Unicode
> On physical typewriters, suffix was more customary I think

Why would anyone type like that? Instead of pressing two keys (the accent key followed by the letter key), you'd need to press four (letter, backspace, accent, space bar) for no reason.

moefh··on It’s not wrong that "\u{1F926}\u{1F3FC}\u200D\u2642\uFE0F".length == 7 (2019)
I'm not GP, but I think you're completely missing their point.

The problem they're describing happens because file names (in Linux and Windows) are not text: in Linux (so Android) they're arbitrary sequences of bytes, and in Windows they're arbitrary sequences of UTF-16 code points not necessarily forming valid scalar values (for example, surrogates can be present alone).

And yet, a lot of programs ignore that and insist on storing file names as Unicode strings, which mostly works (because users almost always name files by inputting text) until somehow a file gets written as a sequence of bytes that doesn't map to a valid string (i.e., it's not UTF-8 or UTF-16, depending on the system).

So what's probably happening in GP's case is that they managed somehow to get a file with a non-UTF-8-byte-sequence name in Android, and subsequently every App that tries to deal with that file uses an API that converts the file name to a string containing U+FFFD ("replacement character") when the invalid UTF-8 byte is found. So when GP tries to delete the file, the App will try to delete the file name with the U+FFFD character, which will fail because that file doesn't exist.

GP is saying that showing the U+FFFD character is fine, but the App should understand that the actual file name is not UTF-8 and behave accordingly (i.e. use the original sequence-of-bytes filename when trying to delete it).

Note that this is harder than it should be. For example, with the old Java API (from java.io[1]) that's impossible: if you get a `File` object from listing a directory and ask if it exists, you'll get `false` for GP's file, because the `File` object internally stores the file name as a Java string. To get the correct result, you have to use the new API (from java.nio.file[2]) using `Path` objects.

[1] https://developer.android.com/reference/java/io/File

[2] https://developer.android.com/reference/java/nio/file/Path

moefh··on Ted Chiang: The Secret Third Thing
> At the very least its an indicator that atheist and superstition are a common combination.

The very least is even less than what I wrote: it's the smallest possible overlap between convinced atheists and fengshui believers: (47-(100-61)) = 8% of the population being both.

You can call it common if you want, but again I don't see how you'd get from that to anywhere near "the majority of atheists globally believe in astrology".

moefh··on Ted Chiang: The Secret Third Thing
I don't see anything in your links that remotely supports your original claim that "The majority of atheists globally believe in astrology".

Even if you expand your claim to add fengshui, it's entirely plausible that only about 10% of the Chinese population are atheists who believe in fengshui. That would mean only 17% of Chinese atheists believe in fengshui.

moefh··on There is no memory safety without thread safety
I agree that there are two groups here talking past each other. I think it would help a lot to clarify this:

> the issue here is that the "Rust and Java sense" of memory safety is not the actual meaning of the term

So what is the actual meaning? Is it simply "there are no cases of actual exploited bugs in the wild"?

Because in another comment you wrote:

> a term of art was created to describe something complicated; in this case, "memory safety", to describe the property of programming languages that don't admit to memory corruption vulnerabilities, such as stack and heap overflows, use-after-frees, and type confusions. Later, people uninvolved with the popularization of the term took the term and tried to define it from first principles, arriving at a place different than the term of art.

But type confusion is exactly what has been demonstrated in the post's example. So what kind of memory safety does Go actually provide, in the term of art sense?

moefh··on Piano Keys
> I will post it if I remember/find it

If you remember and have the time, please do! (And thank you for the links you already posted).

I see now that everything I read about this was way too focused on keyboard and violin, since I had never heard any of this about fretted instruments. I'm glad I get to correct a bit of my understanding, so thank you. Now I'm left wondering about wind instruments.

moefh··on Piano Keys
> The western 12TET scale is not actually 12TET or 12EDO, we temper the scale itself and tweak some notes [...]

I think you and I must be using words differently. To me (and to Wikipedia, and everything else I've ever read, including[1] which I just consulted to make sure I'm not crazy), 12TET is a way to specify by how much you have to multiply the frequency of the first note of the scale to get the other notes' frequencies. Wikipedia[2] has a table with the numbers for 12TET (the column "Decimal value in 12-ET"), but it's very simple: you just multiply the value of the preceding note by 2^(1/12). If you take 12TET and adjust/change the notes a bit, then it's not 12TET anymore.

> EDO on fretted instruments goes back to at least the 16th century

I'd love to see a reference for that. I just consulted [1], it has a chapter called "Non-Keyboard Tuning" and it doesn't mention that (although admittedly it spends most of its time talking about violin, with a ton of references to stuff that Mozart said). The book does say that equal temperament was known for centuries before it was used, but the people who first discovered it simply didn't think it sounded good.

[1] "How Equal Temperament Ruined Harmony (and Why You Should Care)" by Ross W. Duffin

[2] https://en.wikipedia.org/wiki/12_equal_temperament

moefh··on Piano Keys
I don't see how you can divide the octave equally and not end up with equal temperament: that's exactly what equal temperament is!

> Tempered scales are generally EDO with tempering.

That's not historically accurate. EDO wasn't used until very recently (about the middle of the 19th century I think), tempering was used way before that.

For example, the first widely used temperament (which became popular in the Renaissance) was the quarter-comma meantone, which shrinks each fifth (from the natural 3/2) so that the major thirds are perfectly 5/4. The name "quarter-comma" means that the amount of shrinkage is 1/4 of the "syntonic comma", which is the difference you get beteween going up 4 fifths (e.g. C->G->D->A->E) and a major third plus 2 octaves (C->E->E->E). Those final Es can only be the same if you shrink the fifth or stretch the third (or both). What this tempering does is shrink each fifth by 1/4 of the difference (so that going up 4 fifths closes it) and doesn't touch the major third. That means the major thirds are beautiful, and the fifths are a little off. For a chosen key, that is -- everything sounds horrible as soon as you try to change the key too far away from the chosen key.

In the Baroque period a lot of other temperaments were invented, the Werckmeister temperaments were very widely used in (what is today) Germany for example (a lot of people believe Bach had one of these in mind when writing the Well-Tempered Clavier). Those temperaments were also defined by how much each fifth is changed from the "normal" 3/2, but each fifth was to be changed by some different amount in some complicated way.

It was only much later that EDO (12-TET, or "equal temperament") started to be widely used. You can think of it (and people do!) as a "temperament" because it just means you shrink the fifth from the "normal" 3/2 = 1.5 to be instead 2^(7/12) =~ 1.4983, so that going up 12 fifths lands you exactly 7 octaves above (since 2^(7/12)^12 = 2^7). That also means that the octave is divided exactly equally, because going up 12 fifths goes through every one of the 12 notes before going back to the original note.

moefh··on Piano Keys
Do you mean equal-tempered?

I never heard someone describe a tuning system as "untempered", but I guess it would mean something like just intonation -- which sounds really great for playing anything in a specific key but falls horribly apart if you try to change the key (which is why it has seen very little use since the renaissance).

moefh··on Piano Keys
I always thought the canonical way to place the black keys was to divide the octave in the two parts that have the sequential black keys (C-D-E and F-G-A-B), and then simply place the black keys so they're the same distance away from each other and the edge of the parts.

That means that the white keys in each of the groups have "mirrors": for example, C is a mirror of E, D is a mirror of itself (it's the only key like that), F is a mirror of B, and G is a mirror of A.

I just looked at the keyboards I have around me (a slightly-above-low-end digital piano, a small midi controller, and a small 90s synth), and they all seem to fit that description.

ETA: note that the image in the article doesn't fit this description: for example the D is way too narrow (the black keys around it should be much further apart).

ETA2: I just noticed that this seems to be the "B/12 solution" described in the article.

moefh··on Dogwalk: Blender Studio's Official Game
> This game is available for free to the general public, so this situation (and the text from the FAQ) do not apply -- they need to provide the source code to everyone that they distribute the binaries to.

They don't need to do anything the GPL says if they're the sole copyright owners. People are bound by the GPL because copyright law normally prevents them from distributing works without the author's permission, and the GPL is the only thing that allows them to do that.

The GPL itself even points this out explicitly in section 9:

> You are not required to accept this License in order to receive or run a copy of the Program. [...] However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.

Another way to look at it is this: the only people able to take them to court for violating the GPL are themselves.

moefh··on We accidentally solved robotics by watching 1M hours of YouTube
> It therefore follows that robots should be able to learn with just RGB images too!

I don't see how that follows. Humans have trained by experimenting with actually manipulating things, not just by vision. It's not clear at all that someone who had gained intuition about the world exclusively by looking at it would have any success with mechanical arms.

moefh··on Engineered Addictions
I'm curious to know why you see it that way, as I don't interpret it like that at all.

Quite the opposite in fact: if anything it's a reaction to people who do try to understand a system by looking at its original plan: it says that you should disregard that and look at what the system actually does (which includes "interactions of independent parties and random variables", as you say).

In any case, that's how I meant it: it's a bit useless to dig up the original purpose of corporations in history books to talk about how corporations work today, like the comment I replied to suggested.

moefh··on Engineered Addictions
I agree that when taken literally, it's a dumb thing to say: literally (i.e., the dictionary definition), the purpose of a system is the reason why it was built, not what it does. But it's a slogan, and slogans don't always make sense taken literally. The point of the slogan is to remind people of the (obvious, I hope) fact that, as I wrote:

> you can't (well, shouldn't) judge something by its intended purpose if what it ends up doing goes against it

If you check my Wikipedia link it shows that the original quote says more or less the same thing: "[this slogan] makes a better starting point in seeking understanding than the familiar attributions of good intention, prejudices about expectations, moral judgement, or sheer ignorance of circumstances".

In other words, it doesn't matter what's the historical context of why corporations were created, what matters is what they do now. You can argue, like it was argued, that corporations as a whole currently are a net benefit. My point is that bringing up the historical context of their original purpose adds nothing to the discussion.

As to your other point, I completely agree that it would be useless to try to defend the Staling regime by pointing out what communism was intended to be. That's more or less the point I was trying to make.

moefh··on Engineered Addictions
There's an old saying: The purpose of a system is what it does[1]. You can't (well, shouldn't) judge something by its intended purpose if what it ends up doing goes against it.

[1] https://en.wikipedia.org/wiki/The_purpose_of_a_system_is_wha...

moefh··on AGI is Mathematically Impossible 2: When Entropy Returns
Where am I assuming that we have perfect knowledge of physics?

To make it plain, I'll break the argument in two parts:

(a) if AGI is impossible but humans are intelligent, then it must be the case that human behavior can't be explained algorithmically (that last part is Penrose's position).

(b) the statement that human behavior can't be explained algorithmically is about physics, not mathematics.

I hope it's clear that neither (a) or (b) require perfect knowledge of physics, but just in case:

(a) is true by reductio ad absurdum: if human behavior can be explained algorithmically, then an algorithm must be able to simulate it, and so AGI is possible.

(b) is true because humans exist in nature, and physics (not mathematics) is the science that deals with nature.

So where is the assumption that we have perfect knowledge of physics?

moefh··on AGI is Mathematically Impossible 2: When Entropy Returns
That's true, but we should acknowledge that this question is generally regarded as unsettled.

If you accept the conclusion that AGI (as defined in the paper, that is, "solving [...] problems at a level of quality that is at least equivalent to the respective human capabilities") is impossible but human intelligence is possible, then you must accept that the question is settled in favor of Penrose. That's obviously beyond the realm of mathematics.

In other words, the paper can only mathematically prove that AGI is impossible under some assumptions about physics that have nothing to do with mathematics.

moefh··on Sega mistakenly reveals sales numbers of popular games
I remember that one: the two blacks were not slightly different, they were both exactly black but written in different ways.

The image was in PPM format, which stores the color components of the pixels as ASCII text (so a white pixel is stored as "255 255 255" and a black one is "0 0 0"). To redact the image, the code replaced every digit of the numbers with '0', so white became "000 000 000" and black stayed as "0 0 0". Both are black and indistinguishable if you're viewing the image, but you can tell them apart by looking at the file text.

Sadly the UCC homepage seems to have vanished, but I found this account from the author: http://notanumber.net/archives/54/underhanded-c-the-leaky-re...

moefh··on Using Microsoft's New CLI Text Editor on Ubuntu
That's not it, the lower case 'a' is very different.
moefh··on Learn Makefiles
Not sure if you're being snarky, but the manual has a list of all options accepted by make: https://www.gnu.org/software/make/manual/html_node/Options-S...

(`make --help` will only print the most common options)

← PreviousPage 2 of 9Next →