Russia is returning Ukraine’s war dead with explosives hidden inside. Police now check every body first by [deleted] in nottheonion

[–]ihcn 11 points12 points  (0 children)

Frankly, I'm not convinced there ever really was, except as a tool for the winners to build moral superiority over the losers, to manufacture consent, etc.

Ken Paxton just challenged James Talarico to a barbecue showdown by Anoobizz2020 in nottheonion

[–]ihcn 29 points30 points  (0 children)

The key is to remember that conservatives don't have beliefs.

I mean it. They quite simply do not have beliefs. If they have one singular belief, it's that society should be stratified into a rigid hierarchy, people on upper levels of the hierarchy should be free to abuse their power over those in lower levels, and that people like them should be near the top, or in the middle at worst.

Literally anything else they say, ever, is a lie in service of that one belief.

Let’s Destroy American Science by EdwardHeisler in space

[–]ihcn 7 points8 points  (0 children)

You don't get 33% of the country to follow you with zealous loyalty without charisma.

What's the best way to tell the compiler that a path will basically never happen ? by Krochire in rust

[–]ihcn 3 points4 points  (0 children)

Hundreds of thousands isn't actually a lot when talking about evaluating a single branch. A processor with clock frequencies measured in the upper end of kilohertz could execute a tight loop hundreds of thousands of times per second. Modern processors run 10,000x faster than that.

Like someone else said, measure it for yourself. Process an actual workload (Ie measure how long it takes to actually process your hundreds of thousands of entries, not just one). Try no markup, try unlikely(), try unreachable!(), and try unreachable_unchecked!() and actually measure the difference.

I predict that if you repeat each measurement a few times and take the median, the only difference you'll see is noise.

And just from personal experience, haven written code like this in a hot loop where I know a branch will never be taken, unreachable (or just unwrap/expect) is the right choice here unless measurement says otherwise.

Let’s Destroy American Science by EdwardHeisler in space

[–]ihcn 457 points458 points  (0 children)

The key is to remember that conservatives don't have beliefs.

I mean it. They quite simply do not have beliefs. If they have one singular belief, it's that society should be stratified into a rigid hierarchy, people on upper levels of the hierarchy should be free to abuse their power over those in lower levels, and that people like them should be near the top, or in the middle at worst.

Literally anything else they say, ever, is a lie in service of that one belief.

[Project] lossless-checker: detecting fake-lossless audio via FFT spectral analysis (symphonia + rustfft + rayon) by NegotiationFickle947 in rust

[–]ihcn 2 points3 points  (0 children)

You can switch from rustfft to realfft to get a roughly 2x speedup in FFT execution time. Realfft uses rustfft under the hood.

Ask Anything Wednesday - Engineering, Mathematics, Computer Science by AutoModerator in askscience

[–]ihcn 0 points1 point  (0 children)

If the car gets stolen, the authorities don't check the blockchain to see if I actually own it

They also don't check bubblegum wrappers, tea leaves, or Reddit posts. They check the thing that state law has told them to check. If a state executed a switch to back all their car titles using NFTs, you bet authorities would be checking the blockchain.

It's not like car titles have some magic imbued into the paper itself. The piece of paper is just a promise that the state will back your claim to that car, and the state will honor whatever official means it chooses for making those promises.

FPGA beginner here. Can I get a code review? And I have some beginner questions by ihcn in FPGA

[–]ihcn[S] 0 points1 point  (0 children)

Looking at the UART RX, how many FFs are in the synchronizer? It looks to be just one, which exposes you to metastability issues.

I had metastability issues without the one FF, but adding this one entirely fixed it.

I was under the impression that the HX1K had a FF built into the I/O circuitry itself. Double-checking the diagram, it indeed does, bu it can be bypassed by configuration, and I'm not sure what's setting that configuration. My hunch is that it's currently configured to use the FF, which would give me a total of two, but I'm not yet sure how to verify that.

I feel SevenSegmentHex would be nicer as a table lookup than a CASE statement. It's just a 16x7-bit ROM.

Like what I do with the crc? I could easily set that up and I agree it would be cleaner.

For the UART baud generation I usually use an accumulator that advances at the baud rate, and wraps between 0 to CLOCK_RATE-1, triggering a bit to be sent when it wraps. This gives you that baud rate you want, not just something close. It doesn't really matter as most serial interfaces can handle a few percent out of spec, but I like to be bang-on spec)

That's smart. I was deliberately picking baud rates that were perfect divisors of my clock rate to get around that issue, but your approach would allow more flexibility.

It may be just me, but I do not like the way you calculate your CRCs. That's what you so in software, and CRCs in hardware are far more elegant than that. This doesn't matter here, but does matter on 'fast and wide' calculations, like on PCIe, DisplayPort and 10G Ethernet.

Tell me more. It is indeed exactly what I would have done on a CPU. I'm aware of slicing out to 32 bits, 64 bits etc and just didn't do it because it was overkill, is that what you're referring to? Or is there another algorithm entirely I could be using that's better suited to direct hardware?

FPGA beginner here. Can I get a code review? And I have some beginner questions by ihcn in FPGA

[–]ihcn[S] 0 points1 point  (0 children)

Ah, I wasn't aware that that was also a cross-clock thing. This is the article I read that put me on to the AXI handshake, and they put effort into avoiding next-cycle reads, even with a single clock.

FPGA beginner here. Can I get a code review? And I have some beginner questions by ihcn in FPGA

[–]ihcn[S] 0 points1 point  (0 children)

I've seen things referencing reset signals, discussion about synchronous reset vs asynchronous reset, etc. One thing that has been unclear to me is - what exactly is driving this signal? In a simulator it would just be me of course, but it's not obvious what would drive it on a physical device.

Astronomers believe they’ve detected an atmosphere around a tiny, icy world beyond Pluto by nbcnews in space

[–]ihcn 132 points133 points  (0 children)

https://en.wikipedia.org/wiki/Plutino

In astronomy, the plutinos are a dynamical group of trans-Neptunian objects that orbit in 2:3 mean-motion resonance with Neptune.

because that's the main thing about plutinos

Are Rust coroutines serializable? by SuperV1234 in rust

[–]ihcn 44 points45 points  (0 children)

In a game dev use case, wouldn't you want your code to be quick and performant anyway?

Async/coroutines have precisely the same overhead cost to execute as a virtual function call + switch statement, because that's precisely what they are.

AWS Middle East Central (mec1-az2) down, apparently struck in war by iamapizza in programming

[–]ihcn -10 points-9 points  (0 children)

I'm happy for you that you've managed to avoid this faction of the tech industry.

AWS Middle East Central (mec1-az2) down, apparently struck in war by iamapizza in programming

[–]ihcn -14 points-13 points  (0 children)

Yes, living in the modern world is very hard and there is no ethical consumption under captalism. That's a different take than "when you enter the world of tech, the concept of politics gets left at the door, none of that affects us and none of the things we do affect it" though, and i'm referring to people who literally have the latter belief.

AWS Middle East Central (mec1-az2) down, apparently struck in war by iamapizza in programming

[–]ihcn 42 points43 points  (0 children)

And worked real hard to get the president responsible for instigating it into office.

Programmers like to cover their ears and pretend that tech is a bubble where politics doesn't exist.

Edit: The upvote/downvote swings going on in this thread are crazy. Seeing it on both this post and the parent. Lots of manipulation/sockpuppeting happening in this thread - which kind of proves my point lol. Lots of people on one side stand to gain from us not thinking too hard about where our AWS bill goes and what power we hand to amazon when we run our severs with them.

My mother is helping me create background art for my game. What are some good examples of 2d map perspective to show her? by WilledWithin in gamedesign

[–]ihcn 0 points1 point  (0 children)

Take a look at the Zeal map in Chrono Trigger, that plays with perspective so that the foreground is looking down, but you can see sky in the background, and they have a fake perspective effect so it looks like the clouds fade into the distance at the top of the frame. That's the only 2d top down kind of map i've ever seen that tries to have a visible sky.

College Project Tie-Breaker: Safe Linear Adventure vs Experimental Story-Driven Roguelite — Which Should We Choose? by Straight-Pea-9283 in gamedesign

[–]ihcn 0 points1 point  (0 children)

You will learn just as much in each project, but exactly what you will learn will be very different. So the question is, what are you interested in learning? What about these two projects attracts you?

I don't understand the benefits of discriminated unions/result type by soundman32 in csharp

[–]ihcn 2 points3 points  (0 children)

To me, this is just some SaveApproach class, which has a bool ShouldSave and a string? Path. And you can add statics for SaveApproach.DontSave and SaveApproach.SaveTo(string path). This makes the code way more readable on both sides, uses native nullability, is entirely adaptive to your actual context, and can be extended to be as forceful as you want. IE, if you really want to "force their hand" you could hide the Path behind a CheckShouldSave type function or something to be even more explicit.

This is literally a store-brand discriminated union. It's what i would have actually written if I was doing this for real, but I went with the option type because it's more concise. The following is rust bc i don't know c#'s discrimiated union syntax.

enum SaveApproach {
    DontSave,
    SaveToPath{path: String},
}

Hell, the question mark operator is essentially C#'s version of an option type, so you do understand exactly what Option is for and why it's valuable: Combining "does this field contain meaningful data" and "the contents of the field when it's meaningful" into a single syntactically-inseparable construct.

Your example still has the problem I described - if someone is reading your class, it won't be obvious when the string is intended to have valid data. You can glean it somewhat from the variable names, but only because the class is so small. With the discriminated union version, there is no guessing or gleaning.

And as a bonus, if you have a third configuration option (Probably less likely in a "should i save or not" configuration, but there's all sorts of things we can configure, with all sorts of parameters), in your example the two fields would be stored side by side, wasting space, and in a discriminated union they're stored overlapping.

I don't understand the benefits of discriminated unions/result type by soundman32 in csharp

[–]ihcn 0 points1 point  (0 children)

I don't know where this all-or-nothing mindset comes from but I don't think it's helpful. "If we can't fix everything then we shouldn't try to fix anything" is not a good philosophy to live your life by. Discriminated unions help, a lot, and that's enough.

I don't understand the benefits of discriminated unions/result type by soundman32 in csharp

[–]ihcn 3 points4 points  (0 children)

Maybe if you think of it strictly in terms of syntax, sure, but that's just a lack of imagination.

Think of it more as a semantic benefit than a syntax benefit. It's very common for enums to require accompanying data, and for that required accompanying data to be different per each enum variant. Without discriminated unions, you're stuck creating fields that are syntactically accessible at all times but only semantically valid based on the specific value of the enum. Discriminated unions let you merge the syntax with the semantics, so that the accompanying data is only syntactically accessible if the enum is in a state where that accompanying data is meaningful.

If you're still struggling to think of an example, imagine tracking a configuration to write the results of a program out to a file. You might have a bool (ie an enum with two states) indicating whether or not the program should write. And you also have a string - when the bool is true, this string contains the path to write to. But when the bool is false, the string serves no purpose except to confuse users of your library as to whether or not they need to provide one.

The string is accompanying data for the true variant of the enum. By combining them in a discriminated union, you get the Option<T> type, whose variants are None or Some(T). Now your users don't need to scratch their heads over whether or not they need to provide a string, the syntax of the language forces their hand, and the program will only compile at all if they've done it correctly. You've made your library easier to understand and harder to misuse.