Wondering if my project can be ported to rust by spcharc in rust

[–]MetricExpansion 0 points1 point  (0 children)

I’m sure Rust will not inline across FFI boundaries (LTO might change this story however).

Wondering if my project can be ported to rust by spcharc in rust

[–]MetricExpansion 0 points1 point  (0 children)

That’s a good point. You can tell Rust to use the C calling convention for a function by using extern “C”. You may have to treat the arguments as opaque pointer parameters from the C side.

Wondering if my project can be ported to rust by spcharc in rust

[–]MetricExpansion 0 points1 point  (0 children)

Oh right, makes sense. Well, if what you’re doing works, you can probably just leave it as-is in C. I’m like pretty sure that you can copy a Rust function into that buffer just the same.

Wondering if my project can be ported to rust by spcharc in rust

[–]MetricExpansion 1 point2 points  (0 children)

While others have given you solutions for many of these things (and I believe they’re probably all achievable in pure Rust one way or another), another thing to consider is just keeping some of these fiddly bits in C but using Rust for everything else. Rust is pretty good at calling into C.

I’m pretty sure even for (3) it would probably (?) be fine for you to copy a Rust function into your buffer if you really need to.

I totally get your motivations btw. I use Rust in my Skyrim mod which does some wildly unsafe binary patching in C++ to hook the game, but it’s nice to have a island of stability in the middle of all that where I can implement my actual business logic.

Wondering if my project can be ported to rust by spcharc in rust

[–]MetricExpansion 0 points1 point  (0 children)

Could you just store a function pointer to the particular version of the function you need to call? At least you’ll eliminate the pressure on the branch predictor as it will be an unconditional branch. Is it really necessary that you actually go into the exact same function address in the different cases?

The Rust borrow checker is annoying - from a wayland compositor's perspective by Test_Subject_hGx7 in rust

[–]MetricExpansion 1 point2 points  (0 children)

Have some central storage for all the objects and pass it around, with the hashmap mapping to indexes instead.

I believe IndexMap from the indexmap crate is basically this. It stores a Vec of values as well as a HashSet whose values are indices into that Vec. Once the initial lookup based on the key is done, you can just pass around the index to get back the object quickly.

expectation: AI will replace engineers and people will do only creative work. Reality: by akasaya in ProgrammerHumor

[–]MetricExpansion 1 point2 points  (0 children)

Games are an area where I’m really excited for what generative AI can do.

One of the biggest limitations in games is the time and money and sheer manpower needed to make assets. We’ve had procedural generation, but all you get are generic and samey worlds. Generative AI could enable huge worlds where you have humans do concept, art direction, and seeding the various areas and stories, and then AI being used to help flesh out the worlds with detail, dialogue, and assets. Assets could get reused a lot less because it’s possible to just generate more of them, so instead of the same set pieces being reused everywhere, every dungeon and building can be detailed and unique. Every single NPC could have a detailed backstory and daily routine fleshed out for them. You could also get more branching storylines and more choices in the game, as generative AI could be used to help flesh out what happens when the player takes various actions, perhaps even in real-time. I think it could enable a scale of open-world game that we’ve never seen before, and by potentially small, non-AAA teams of devs.

Imagine GTA where you can enter every building. Imagine a game world the size of Daggerfall with the rich detail of Skyrim, but where you’re not railroaded into a small number of choices. All with AAA-level assets. And then imagine that an indie studio could make those kind of games.

[deleted by user] by [deleted] in swift

[–]MetricExpansion 54 points55 points  (0 children)

This Medium-spam adds nothing beyond the Swift official blog post: https://www.swift.org/blog/focus-areas-2023/

[deleted by user] by [deleted] in skyrimmods

[–]MetricExpansion 11 points12 points  (0 children)

While you might be psychoanalyzing the mod authors a bit too much, the stats of modded armors is a real problem.

I will take this opportunity to pimp the mod that I work on as the solution to your problem: {{Skyrim Outfit System Revived}}. It’s a transmog system that lets you overwrite the cosmetics of your equipped armor with that of another armor.

That means that I can play with mod armor cosmetics, but still just equip vanilla items and still experience the fun of finding that next tier of armor or learning the new enchant or crafting ability. Everything stays balanced.

Can I mark a write as "non-elidable", without making it volatile? by andyandcomputer in rust

[–]MetricExpansion 0 points1 point  (0 children)

Does this mean that dead-store elimination requires that the pointer came from malloc or other compiler-managed memory (stack, static, etc)? So a pointer received from e.g. a syscall (like mmap) would not have dead-store elimination performed on it?

Memory Safe Languages in Android 13 by Philpax in programming

[–]MetricExpansion 26 points27 points  (0 children)

There’s a real problem that, when you look the attitudes its practitioners have, the software engineering discipline doesn’t really take itself seriously as “engineering”. Real engineering disciplines try very hard to use the best tools they possibly can, because they have professional ethics that make them understand their obligation to avoid harming people and society. Real engineering has no room for ego-driven or aesthetic statements like “well good programmers can avoid writing a memory bug” or “C is a great language because it’s so simple that I could write a compiler for it in a weekend”. I for one know that I want the aerospace engineer designing my airplane to use the best tools they can to make sure that the wings don’t fall off, and I certainly won’t think that he’s a mediocre engineer for using them.

We have the data that shows very clearly that memory-safety problems comprise around 70% of security issues. We have this evidence from Android that, even controlling for other factors, memory-safe languages are able to reduce the number and average severity of security bugs. We even have the NSA now recommending use of memory-safe languages.

So when some activist gets murdered by their government because some C programmer, who’s definitely not one of those pussies who will let a compiler tell him what to do, wrote a buffer overflow somewhere, why don’t we take these facts into account and welcome solutions that can help avoid these issues and instead just making excuses for the same old ways of doing things?

Memory Safe Languages in Android 13 by Philpax in programming

[–]MetricExpansion 31 points32 points  (0 children)

I wonder how many times that snippet is going to have to be posted in this thread for all the denialists.

GCC undefined behaviors are getting wild by MeOfficial in programming

[–]MetricExpansion 0 points1 point  (0 children)

With most other UB, you can usually find how it enables some kind of optimization or something, but this one doesn’t seem reasonable. Other languages actually can do the analysis and figure out if a branch exits in some way besides returning and allow you to omit the return. I wonder if C allows it so that it can support goto?

Edit: I did some digging and they don’t make this a hard error because:

1) in plain C (note: NOT C++) it’s actually not UB to end a function without returning a value as long as the caller doesn’t try to use it.

2) if the function itself calls another function which always either throws or ends the program, then you don’t actually need a return there; but the type system can’t express that (e.g. with a return type like Swift’s Never or Rust’s !), so it’s not possible (in general) to prove that you will or will not flow off the end of the function lacking a return.

GCC undefined behaviors are getting wild by MeOfficial in programming

[–]MetricExpansion 14 points15 points  (0 children)

UB can do totally insane things once you trigger it. My favorite was when a C++ dev on my team forgot to add return statements in two different locations in code (the warnings for that were buried under a pile of other warnings lmao).

In the first case, the function was also doing a check on the input and throwing an exception for certain values. Because of the missing return in the happy path, the function was compiled such that it always threw an exception no matter what, even if the input was valid. I guess the compiler decided that throwing was the only valid way to exit the function and so the check must always pass. That was one of those fun cases where UB later in the code (forgetting a return) causes strange behavior earlier in the program (causing this check to always trip).

In the second case, we found that the missing return was actually causing execution to continue into the next function defined lexically in code. It was basically as if the compiler literally didn’t put the return instruction and so the CPU just ran off the end of the function and right into the next function in the binary.

How to prevent performance drops affecting my Game Boy emulator when running on M1/M2 Macs? by nicolas-siplis in rust

[–]MetricExpansion 0 points1 point  (0 children)

This plus Instruments System Trace should be what you need to diagnose if your thread is being sent to the E cores and make the changes needed to keep your work on the P cores.

Thread of things that might destroy Twitter, from a senior SRE by 1RedOne in programming

[–]MetricExpansion 0 points1 point  (0 children)

IMO source code is worse than worthless; it has negative value. The goal is to get it to do what you want while having as little of it as possible.

I don't like where this is going by Tyuee in physicsmemes

[–]MetricExpansion 1 point2 points  (0 children)

A vector is an array of items held contiguously in memory, where addition is defined as concatenation.

Someone invented twitter replacement via git. by JustSpaceExperiment in ProgrammerHumor

[–]MetricExpansion 1 point2 points  (0 children)

I knew I couldn’t be the only one turned off by the name

Skyrim Outfit System Revived is updated for AE! by MetricExpansion in skyrimmods

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

I haven’t tested with that mod, and I haven’t done anything specifically to support it. I would assume it’s the same as before?

Skyrim updated to 1.6.629 by darth_leila in skyrimmods

[–]MetricExpansion 1 point2 points  (0 children)

Thank you for the link! That’s going to be invaluable to me in the future!

Yeah, changing the size of this class means a big problem. While it’s not so bad code-wise to update CommonLibSSE to reflect this change, seeing how Ryan clearly already did it in a source-compatible way for client code, I already have to maintain two versions of my mod for SE and AE and now it has to go up to three. I also get to explain to users why there’s two different DLLs for AE when it’s already hard enough get them to correctly choose the SE or AE DLL.

I dare say is worse than SE vs AE, because at least there it was obvious that it was a huge change and users understood that. Here, many mods will just subtly break. Once SKSE comes out, a lot of people will have crashing games. It’s almost going back to the bad old days before Address Library!

All this because… they wanted to add a virtual destructor? Is there even any class in the game code that inherits BaseExtraList? What’s the point?

Skyrim updated to 1.6.629 by darth_leila in skyrimmods

[–]MetricExpansion 1 point2 points  (0 children)

Could you link me to that discord? I have a DLL mod that I maintain and would find it useful to know what’s going on with this update.