HNHacker News
TopNewBestAskShowJobs

tyg13

499 karma · joined March 18, 2020

submissionscomments
tyg13··on Compiler Options Hardening Guide for C and C++
> Is the critical difference here that the array access happens outside of the "for" expression?

Precisely: this means that `d[k]` is guaranteed to execute before the check that `k < 16`. In general, if you have some access like `d[k]` where `k` is some integer and `d` is some array of size `N`, you can assume that `k < N` on all paths which are dominated by the statement containing `d[k]`. In simpler terms, the optimizer will assume that `k < N` is true on every path after the access to `d[k]` occurs.

To make this clearer, consider an equivalent, slightly-transformed version of the original code:

    int d[16];
    int SATD (void)
    {
      int satd = 0, dd, k;
      dd = d[k=0];
      do {
        satd += (dd < 0 ? -dd : dd);
        k = k + 1;
        dd=d[k]; // At this point, k must be < 16.
      } while (k < 16); // The value of `k` has not changed, thus our previous
                        // assumption that `k < 16` must still hold. Thus `k < 16`
                        // can be simplified to `true`.
      return satd;
    }
Now consider a slightly-transformed version of the correct code:

    int d[16];
    int SATD (void)
    {
    int satd = 0, k = 0;
    k = 0;
    do
    {
      satd += d[k] < 0 ? -d[k] : d[k]; // At this point, k must be < 16
      k = k + 1;
    } while (k < 16); // The value of `k` has changed -- at best, we can assert
                      // that `k < 17` since its value increased by 1 since we
                      // last assumed it was less than 16. But the assumption
                      // that `k < 16` doesn't hold, and this check cannot be
                      // simplified.
    return satd;
    }
It's important that this is understood in terms of dominance (in the graph-theoretical sense), because statements like "k < 16 can never be false because it's used in d[k] where k == 16" or "the compiler will delete checks for k < 16 if it knows that d[16] occurs" which seem equivalent to the previously-stated dominance criterion simply are not. It's not that the compiler is detecting UB, thus deleting your checks -- it's that it assumes UB never occurs in the first place.
tyg13··on Compiler Options Hardening Guide for C and C++
Leaving aside the fact that that code reads an array out-of-bounds (which is not a trivial security issue) that's a ridiculously obtuse way to write that code. For loop conditions should be almost always be expressed in terms of their induction variable. A much cleaner and safe version is

    int d[16];
    int SATD (void)
    {
    int satd = 0, k = 0;
    for (k = 0; k < 16; ++k)
      satd += d[k] < 0 ? -d[k] : d[k];
    return satd;
    }
tyg13··on Crew-9 Returns to Earth
I particularly like how they use `space` in two different ways, from Q-Tip's second verse:

   These notions and ideas and citizens live in space
   I chuckle just like all of y'all, absurdity, after all
   Takes money to get it running and money for trees to fall
   Imagine for one second all the people are colored, please
   Imagine for one second all the people in poverty
   No matter the skin tone, culture or time zone
   Think the ones who got it
   Would even think to throw you a bone?
   Moved you out your neighborhood, did they find you a home?
   Nah cypher, probably no place to
   Imagine if this shit was really talkin’ about space, dude
While the rich and powerful imagine of blasting off to outer space, advancing the frontiers of humanity, boldly going where no man has gone before -- the poor still find themselves squabbling for just a little space on the planet we all call home. Imagine if 'space program' really meant 'space' program?
tyg13··on Quote-unquote "macros"
Every time I see a post from Lisp fans about macros, I want to be amazed, but I always just walk away confused. I can tell there's something interesting in there, but the quote-unquote-quasiquote syntax is just so dense that my brain is incapable of comprehending it.
tyg13··on I have no constructor, and I must initialize
Just to further illustrate what I'm saying, are you really trying to say that

``` //explicitly annotating this struct is default initializable and copyable #[derive(Default, Copy, Clone)] struct Foo { ... } ```

is actually worse than

``` struct Foo {...}; // rule of zero, copy/move/default are defined/deleted based arcane rules predicated on the contents of Foo ```

tyg13··on I have no constructor, and I must initialize
Your post starts with the flawed assumption that you have to define constructors in Rust, and then your own wall of text (ironically longer than mine) about avoiding boilerplate which doesn't apply to Rust. I'm not sure you understood my point.
tyg13··on I have no constructor, and I must initialize
You're mistaken. Rust does not require you to define all constructors. Rust does not have constructors.

All structs in Rust must be initialized using brace syntax, e.g. `Foo { bar: 1, baz: "" }`. This is commonly encapsulated into static functions (e.g. `Foo::new(1, "")`) that act similarly to constructors, but which are not special in any way compared to other functions. This avoids a lot of the strangeness in C++ that arises from constructors being "special" (can't be named, don't have a return type, use initializer list syntax which is not used anywhere else).

This combined with mandatory move semantics means you also don't have to worry about copy constructors or copy-assignment operators (you opt into copy semantics by deriving from Clone and explicitly calling `.clone()` to create a copy, or deriving from Copy for implicit copy-on-assign) or move constructors and move-assignment operators (all non-Copy assignments are moves by default).

It's actually rather refreshing, and I find myself writing a lot of my C++ code in imitation of the Rust style.

tyg13··on Let's stop counting centuries
Seventeen-hundreds doesn't sound stilted at all, to this native English speaker. I would use this even in a very formal context, and certainly no one would bat an eye. One-thousand-seven-hundreds is almost certainly incorrect in English -- I would actually find this to be a very clear marker of not speaking English very well. Are you a native speaker? I find your claims rather bold and quite frankly incorrect.

Also, curious to find out (from elsewhere in this thread) is that Finnish does not typically use centuries. Rather, they use a construction that maps directly to 1700s (1700-luku). I would be careful in accidentally applying your own cultural bias when accusing others of the same ;)

tyg13··on After AI beat them, professional Go players got better and more creative
It's certainly capable of creating technically impressive music, and mimicry at a ridiculously competent level, but it absolutely will not replace the desire for recording artists. These tools will become part of an artist's arsenal, but they will not replace the artist any more than the countless digital composition tools that already exist have. It will just be the case that these tools enable more people to be artists than previously before. Music is a form of artistic expression. As long as people still care about what other people have to say, there will be a demand for recording artists.
tyg13··on After AI beat them, professional Go players got better and more creative
Am I stupid, or is this just AI covering Blackbird by The Beatles in a couple different styles? Is this supposed to be an example of AI writing "absolute bangers" or "soulful music with feeling" because I just don't see it.

It seems like the exact "paint-by-numbers" stuff that we always see with AI: it's capable of taking existing art and mashing it together, but there's nothing interesting or novel being created here. It's the pinnacle of carbon-copy, technically impressive but still soulless art.

If you played me either of these songs without telling me they were AI, I would think: OK, weird cover of Blackbird? Not particularly moving, but perhaps a stepping off point to something more. What would interest me more than the music itself is the story behind why the song was covered, who was performing it, what were their intended emotions in creating it? And of course, since it's a cover, if they had any original material of their own. Knowing that it's just an audio file being synthesized by an AI takes all of the enjoyment out of it for me (not that it was particularly good to begin with).

Music is not simply good because of the sound entering your ears. The story, the artist behind it, the intended emotion and artistry is part of the experience. AI does not deliver on this, and I doubt it ever will, because human connection is what underlies those extra-musical qualities. I care about the people who made the music; I will never care about the machine.

tyg13··on Omegle 2009-2023
How is age verification supposed to work? I don't suppose users of the site are going to provide legal documents just to use it. It's tantamount to shutting it down.

I ask because there was a similar moral outrage around age verification for access to porn sites that I recall being a big issue a while ago. I don't recall exactly how it played out in court, but it appeared to amount to nothing, which I can't help but to feel was due to the fact that mechanisms to verify someone's age online are either trivial to circumvent or present such a high barrier to entry that no reasonable user would surmount it.

tyg13··on How Wikipedia became the last good place on the internet
It's just a secular leftist response to Conservapedia that mostly focuses on debunking (mostly far-right) pseudoscience and conspiracy theories. I think you're taking the name a bit too literally and the concept a bit too seriously.
tyg13··on Google ends deal to build 15,000 Bay Area homes due to "market conditions"
Can we just stop with the nonsense about "people wanting to live where the rich people live" as if a good majority of the people who are fighting for affordable housing aren't people who _already_ live there and are fighting against being priced out of where they grew up?

Your only response is an absurd defeatist appeal to human nature and trite clichés like "life isn't fair", ignoring that legislation is very capable of addressing this particular issue. That is currently the plan, and the plan is being executed by the state of California. If you think individual rich homeowners are more powerful than the state, then I think it might be you who is out of touch with the state of reality.

tyg13··on Google ends deal to build 15,000 Bay Area homes due to "market conditions"
You're missing the point. The people in the area often do support building new housing, they just don't want it where they are. This is a fundamental paradox, as it has to be built _somewhere_, but seemingly none of the people who agree there is a problem want to disadvantage themselves to fix the problem.

Anyways, can I just say how absurd it is to call the government allowing developers to build new houses "tyranny"? Seems like a hysterical reading of the situation.

tyg13··on A Zoomer explains her generation's malaise to older generations
Just because you haven't experienced it, doesn't mean it doesn't exist; in much of the world outside of America, public transport is not unpopular.

And your own transportation system is vastly inefficient in the task of getting you and thousands of other people where they need to go. In a world where people's destinations are wildly divergent and travellers are few, cars make more sense. But when you see a clogged interstate filled with cars all mostly going to the same or similar destinations, whose occupants could easily fit into a couple of buses, you start to see the logic behind public transportation.

tyg13··on A Zoomer explains her generation's malaise to older generations
The smart and motivated ones will try to get to the grocery store. Unfortunately, for most, those services do so much more harm than good. What makes sense for a wealthy professional to pay for the convenience of food or grocery delivery ends up being a small fortune for a lot of young people who can't afford a car to go to the grocery store.

It's a clear short- vs long-term thinking issue, but the reality is most young people are living with so little hope for the future that denying immediate pleasures in search of a future payoff seems naive and pointless.

tyg13··on A Zoomer explains her generation's malaise to older generations
This generation grew up in the middle of at least two of those economic crises, has witnessed countless riots, faced down a soul-crushing pandemic at the peak of their childhood, and has lived their entire life without even a shred of hope in their political system. The few of us who got blessed by the tech lottery live comfortably, while the rest live with no hope of making a decent living, owning our own house, or starting a family.

This article discusses Gen Z diving into their phones as a symptom of the generational malaise, but don't mistake the symptom for the cause.

tyg13··on Apple backs national right-to-repair bill, offering parts, manuals, and tools
Because corporations are not people.
tyg13··on Nakatomi Space
The author seemed to offer no particular criticism of the invading Israelis, as far as I can tell. In fact, they almost seemed to praise their tactics for their unconventional nature.
tyg13··on Rethinking the Luddites
> If your job was X by hand and now a machine does X better what gives you the right to deny others who want to use such a machine?

Self-preservation? Do you expect them to roll over and die?

> Did Luddites not feel it was their right to impose costs on others to maintain their way of life?

Did the factory owners not feel it was their right to suddenly and massively disrupt the industries that Luddites were making a living in? What about the cost on them?

tyg13··on Googlers told to avoid words like ‘share’ and ‘bundle,’ US says
I feel like this comment exists in a capitalist fairy tale where the only way a business could grow to overtake its competitors is by being better for consumers. Or where a business that has done so will always continue to do so once it has achieved market dominance.

> But if your laundromat is better in some way (service, cost, marketing), why wouldn't you want to grow?

Maybe you just want to run a laundromat? Is that not enough these days?

tyg13··on Using uninitialized memory for fun and profit (2008)
I'd be quite interested to read that post, given that one of the big UB hammers is strict aliasing which gets used a _lot_
tyg13··on Using uninitialized memory for fun and profit (2008)
This seems like the sort of a comment that can only be written by completely refusing to understand why compiler writers take advantage of UB. Compiler writers are not engaging in "adversarial" behavior with their users -- they are their own users!

The simple truth is a lot of UB exists to allow for optimizations that programmers entirely take for granted. In order to optimize something, you have to make assumptions, particularly when dealing with languages as permissive as C and C++. By programming to an abstract machine and explicitly specifying which behavior is defined and which is not, we allow a compiler to make these assumptions. Despite what you may wish, a compiler is not able to read your mind to know when a given piece of UB is actually code that you intended to execute with particular semantics, or whether it's the result of some other optimizations on a code path that will never execute.

tyg13··on Some of the error messages produced by Apple's MPW C compiler (2006)
You're correct, although I'm fairly sure dereferencing a `void*` is a compile error on all but the most ancient and non-conforming compilers. I'm not even sure what it _could_ compile to, given that `void` has no size.
tyg13··on This isn’t the way to speed up Rust compile times
I'm not complaining that it's not curated, specifically because it's exclusively a source code package directory. Auditing source code for safety is hard, doing so with a binary is much harder.
tyg13··on What’s the world’s oldest language?
Sure, maybe not entirely isolated. I just mean that the geographic isolation of being an island means you don't see a dialect continuum between English and other languages the way that you do with say, the various Germanic languages.
tyg13··on This isn’t the way to speed up Rust compile times
crates.io is just a platform for people to make their Rust code distributable; it's not curated in any way really (other than removing obvious malware). An OS distribution is explicitly curated.
tyg13··on What’s the world’s oldest language?
Yes, you are correct the Saxons would be in ancient Saxony, not Britain.
tyg13··on What’s the world’s oldest language?
It seems multi-dimensional. Isolation allows for parallel language development, but that development could be conservative relative to the rest of the speakers, or it could be heavily divergent.

Basque is an example where there's an obvious motivation for linguistic conservatism: the maintenance of a language that is "untainted" by the constant and unbalanced contact with French and Spanish speakers. There's a need to preserve a language that would otherwise be consumed and die out.

English is actually a great example, I think, of how isolation can lead to divergence. Compared to other languages in its family (e.g. Dutch and German) it's wildly unintelligible, largely owing to the fact that English was spoken on an island where contact with speakers of other Germanic languages was much less common.

tyg13··on What’s the world’s oldest language?
Hebrew as it's spoken today in Israel, or ancient Hebrew? There's a lot of intelligibility between the two, but it's mostly in the written form. In ancient Judea you'd be more likely to find a speaker of dialect that'd entirely dead today.

As far as English goes, obviously you wouldn't find any English speakers in ancient Britain, but you could find Saxons that spoke a language that English is descended from. There won't be much intelligibility, if any at all, but I wouldn't be surprised if it was equally unintelligible as ancient spoken Hebrew.

← PreviousPage 3 of 5Next →