r/cpp • • Apr 07 '26

Can your AI rewrite your code in assembly?

https://lemire.me/blog/2026/04/05/can-your-ai-rewrite-your-code-in-assembly/
3 Upvotes

58 comments sorted by

View all comments

Show parent comment

3

u/domiran game engine dev Apr 08 '26

C#'s performance has nothing to do with the fact that it's compiled at runtime and more to do with its feature set and optimization capabilities of its compiler. C++ compilers have had a lot of work put into them over the years because performance was the language's primary feature.

One could argue the bytecode is a hindrance to the compiler but that's still another problem entirely.

-3

u/SoSKatan Apr 08 '26

Uh dude this is your second confidently incorrect comment that you’ve made within minutes.

C# perf loss is directly related to its JIT. JIT’s by nature dont have as many optimization opportunities AND its limited on compile time. With cpp it’s fine if it takes a 20 seconds to optimize a single unit, because it’s a one time cost.

The cost benefit ratio of different optimizations are different for JIT’s compared to one time compilers.

So JIT’s tend to be far less aggressive, and slower runtime performance as a result.

Now I’m going to wait for your next dumb confidently incorrect comment to come in.

4

u/domiran game engine dev Apr 08 '26

I'm not aware of anything about C#'s JIT adversely affecting optimization techniques. Can you explain?

JIT is capable of optimizing for the hardware it's currently on, something, say, C++ can't do (one person may have only AVX2 and another may have AVX512) but as far as I know, C#'s JIT isn't missing anything an equivalent C++ compiler might need.

2

u/MEaster Apr 08 '26

Are there any production JITs that actually do platform-specific optimizations like that? I've never seen anyone give an example of one.

2

u/domiran game engine dev Apr 08 '26

I would assume C#'s JIT does, reading the CPU capabilities and enabling what instructions it can, but I've been out of the C# world for quite some time and never really looked into it.

What is interesting, though, is the official C# compiler recently got some optimizations that are fairly common in C++ (which supports the idea that bytecode is not a hindrance to optimization).

-2

u/SoSKatan Apr 08 '26

Sounds like you need to educate yourself on modern optimization technics.

You completely missed my point. Some optimizations are more costly than others (both in turks of computation and memory cost)

Some of those optimizations only offer 2-3% increases. And for JIT, just aren’t going to bother using them.

Dude you are making incorrect arguments that are easy to google. Why are you wasting my time here?

5

u/domiran game engine dev Apr 08 '26

I asked you a very direct question and you ignored it. I asked because I thought maybe you knew something I didn't, and I could not find anything that supported the idea that the JIT in C# affects optimization. As I understand it, at least in game development, C# can be made as fast as C++ (and newer version of C# are making that easier to do) in some scenarios, barring the garbage collector, which will always be a hindrance.

Your comment history is littered with aggressive and condescending replies. I hope one day you learn to be a better person. 👍

-3

u/SoSKatan Apr 08 '26

Ok here’s the thing, modern compilers use hundreds of different optimizations.

It’s not just one or two, it’s hundreds.

Did you really need me to go make a list for you?

Can’t you just go Google it yourself?

I didn’t avoid your question, I’m just not your Google caddy. I’m willing to help you some and do part of the work, but you need to put in some effort yourself man.

Come back after you put in some legwork and then we can talk.

7

u/domiran game engine dev Apr 08 '26 edited Apr 09 '26

We're done. I'm not doing that. I already tried for a few minutes and couldn't find any specifics. I've already gone above and beyond by looking at all.

You want me to prove your claim? No, I'm not doing that. That's not how this works. You made the claim, you prove it.

-1

u/SoSKatan Apr 08 '26

I can’t say I’m surprised you aren’t going to put in the effort.

4

u/pjmlp Apr 08 '26

Neither have you been doing much this whole thread, /u//domiran is right.

0

u/domiran game engine dev Apr 08 '26

Thanks for the support. I thought I was taking crazy pills. 🫠

3

u/pjmlp Apr 08 '26

Like the ones using LLVM and GCC bitecode and GIMPLE passes?

You could also use Google to learn about compilers for those mainframes and micros I refered above, apparently not a skill.

Put some effort in learning about them, and then we can talk as well.

2

u/pjmlp Apr 08 '26

And you need to educate yourself in some compiler development lessons, apparently none taken so far.

1

u/pjmlp Apr 08 '26

Devil May Cry is one PlayStation 5 example of the C# compiler used by Capcom, what performance loss?!?