Compiling C# into NATIVE code, just like Go, Rust and C++

Compiling C# into NATIVE code, just like Go, Rust and C++

Nick Chapsas

2 года назад

83,571 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@YabseraPython
@YabseraPython - 09.09.2024 21:07

So it can cross compile. From linux to windows binarys

Ответить
@Gaamaa-oz5ef2lf3n
@Gaamaa-oz5ef2lf3n - 23.08.2024 23:48

You at least understood the real worth of Native executable and talking this topic.
I see 90% of coders without knowing this, blindly coding in .NET and soon their applications is Cracked on the market.

How idiotic ?
For few lines of coded .NET app takes 75MB size of executable.

Note: This native compilation fails in bigger applications with additional nuget packages.

Ответить
@magnusm4
@magnusm4 - 22.04.2024 23:35

Now when starting a new project in VS. When you choose .NET 8; You can choose to use the Aot into native by default in a checkbox.
So when you open your project file. It has the <PublishAot>true</PublishAot> in it already.
This doesn't apply for .NET 7 or earlier.

Ответить
@lionellosanti
@lionellosanti - 04.03.2024 16:15

I've installed .net 8 and it's not possibile that I cannot find a compiler for c# 12 in the stuff I've installed, where is it? Not the old csc.exe for c#5 from the windows directory

Ответить
@Tolmachovtv
@Tolmachovtv - 23.01.2024 18:10

Nice, short, clear and simple for understanding! Way to go man!

Ответить
@DavidAlsh
@DavidAlsh - 24.10.2023 14:40

Microsoft took the long road to a home brewed llvm 😂

Ответить
@shbita
@shbita - 30.09.2023 20:29

Thanks for the video , I am new in c# , do you have any tutorials / courses that show how to create Apis in c# and deploy the final app to linux cloud ?

Ответить
@AlexanderEndless
@AlexanderEndless - 27.09.2023 06:37

This is so underdocumented thank you so much for this video!

Ответить
@HikingUtah
@HikingUtah - 31.08.2023 23:23

Why we had to wait for .NET 7 for this remains a complete mystery.

Ответить
@dginx
@dginx - 10.08.2023 00:25

.NETIVE

Ответить
@bobweiram6321
@bobweiram6321 - 21.07.2023 19:33

For iOS Apps, AOT is the only way to go.

Ответить
@user-tx4mm9py8e
@user-tx4mm9py8e - 26.05.2023 06:45

it's not a real native code. many of us want to compile c# into the native code, so others can not decompile the exe back to source code. but with this NativeAOT, one can easily decompile the exe/dll into source code again.
Is there any other tools to compile c# framework project into native code, so it can not decompile to source merely with exe/dll ? I am eager to find such tools

Ответить
@kinshowa17
@kinshowa17 - 22.05.2023 01:12

Love your explanation. Thank you

Ответить
@littlegandhi1199
@littlegandhi1199 - 15.05.2023 12:57

Can we convert windows forms into intermediate language? I'm guessing not lmk

Ответить
@tyunpeters3170
@tyunpeters3170 - 03.03.2023 12:50

I used "csc Program.cs" and the output was a single file and it wasn't stupidly huge.

Ответить
@FlavioO
@FlavioO - 02.03.2023 11:20

Coooooool, hope this come to webapis

Ответить
@semen083
@semen083 - 11.02.2023 22:27

Aot compiling dont supported for ASP .Net Core projects? Only for console?

Ответить
@Felipe-mg1pw
@Felipe-mg1pw - 12.01.2023 22:37

Imagine if you could AOT compile your c# program with clang -O3 and avx2 this would be nuts

Ответить
@7th_CAV_Trooper
@7th_CAV_Trooper - 27.12.2022 00:14

the single file option is only slow on the first run when it unpacks the file. after that it's fast.

Ответить
@znefas
@znefas - 22.12.2022 00:07

Finally!!! Since I've started the C# course I'm currently part of, and ever since becoming interested in C#, I've always hoped to find a way to build to every architecture natively in order to avoid relying on the end user having the .NET runtime, or having to ship gigantic amounts of supporting files!
The amount of performance optimization that can be done here is most likely a good chunk, and I can't wait to see what this AoT option evolves to!

Ответить
@DevMeloy
@DevMeloy - 17.11.2022 21:24

Electron apps face the same issue, without having a framework preinstalled on the local machine each application must contain everything to run which makes each project unnecessarily large.

I'm hoping at some point web browsers adopt the ability to install DLL's which can be used by any site so that we can get away from having to use JS to interact with the DOM. Assuming Blazor takes hold maybe we can work towards Wasm's being cacheable for all domains.

Ответить
@quachhengtony7651
@quachhengtony7651 - 15.11.2022 05:26

Question: Is this new to C#/.NET?

Ответить
@josephmoreno9733
@josephmoreno9733 - 02.11.2022 15:35

I have waiting this moment for years. I waiting it from when it was called CoreRT.

Ответить
@deniszelentsov4157
@deniszelentsov4157 - 31.10.2022 22:50

Thanks a lot for this video! Does it work if code contains reflection? Are there any other restrictions?

Ответить
@stoyandimov7914
@stoyandimov7914 - 27.10.2022 16:29

Does AOT apps have GC and if not how are strings cleanup?

Ответить
@Suriprofz
@Suriprofz - 24.10.2022 01:21

To bad only works on console apps...

Ответить
@aschwinwesselius
@aschwinwesselius - 21.10.2022 12:34

Forgive me if the question is silly. Would it be possible to load PHP core library (written in C) into C# and build extensions with it? Or maybe with a PHP-CPP intermediary layer library?

Ответить
@zxopink
@zxopink - 20.10.2022 16:32

Love your videos, thanks to this one I hadn't stop talking with friends about about how C# can now run naively without the CLR and JIT.
They all respond with "then you don't know what's a managed language" until I pull this video.
I think it's a game changer

Ответить
@gregcyrus2739
@gregcyrus2739 - 20.10.2022 13:36

Haven't they been announcing AOT for Blazor/ WASM too? I tried it once, it took very long to compile… and finally didn't work.

Ответить
@carstenberggreen7509
@carstenberggreen7509 - 18.10.2022 17:29

Very interesting. Comming from Commodore 64, Amiga, all native machinecode and then forward through C/C++, then now... C# and... Docker... and now we can get back to natively compiled code... I still love .NET for its scalability, but cool to know we can also bake and compile our code

Ответить
@yunodiewtf
@yunodiewtf - 16.10.2022 16:57

Hey man, how about write the exact same thing in C/C++ or Delphi and compare perf and memory footprint?
Because it's norm for me to pick a native code language when anything with client-side high performance is concerned.

Ответить
@haxi52
@haxi52 - 13.10.2022 06:43

Without supporting reflection.emit, does that mean EF lazy loading is out?

Ответить
@cuzsleepisthecousinofdeath
@cuzsleepisthecousinofdeath - 12.10.2022 21:23

Previous self-contained compilation was the NGEN?

Ответить
@thatsalot3577
@thatsalot3577 - 11.10.2022 16:38

Me when I read about generating native c# code : unity burst compiler

Ответить
@androth1502
@androth1502 - 10.10.2022 15:12

very interesting. i've always liked C#, having to carry around so much baggage (and expect target machines to have certain files installed) with every app had me go to another language. this will convince me to take another look at C# in the coming months.

Ответить
@RasmusSchultz
@RasmusSchultz - 10.10.2022 14:39

This is great! Now what we need is a lightweight web server and framework that doesn't rely on reflection. I'm not a fan of ASP, so I would have wanted that either way - but maybe now there's a more compelling reason to do it? 😄

Ответить
@dantenotavailable
@dantenotavailable - 10.10.2022 09:57

I tried AoT native compilation pre-Net 5 (iirc) and it was nice but wouldn't reliably work. Looks like it's still in much the same place but at least it's getting officially included in the runtime which is something. Definitely something to think about if you're running in containers.

Ответить
@julkiewicz
@julkiewicz - 10.10.2022 03:09

Can you talk about the hybrid mode? As far as I understand there is an AOT mode where dynamically loaded code is supported, however it actually runs using an interpreter (the eval is running off of IL directly). I'm really curious about the internals and details of that approach.

Ответить
@davestorm6718
@davestorm6718 - 10.10.2022 03:08

I wonder if this could be used on a Raspberry Pi - the small footprint

Ответить
@yuryschkatula9026
@yuryschkatula9026 - 09.10.2022 22:51

Ouch, that platform-specific headache... Not again :)

Ответить
@eknuds
@eknuds - 09.10.2022 15:56

Or Swift, which I created a whole shipping iOS app in but had to turn away from to go multiplatform.

Ответить
@PhilipAlexanderHassialis
@PhilipAlexanderHassialis - 09.10.2022 13:46

What is more interesting in and of itself is the build time. Trying the same stunt in GraalVM it takes ages and stresses the compile machine to its limits just to take a lot more time to simply compile a damn java application to a native image, which makes the whole DX simply disgusting.

Ответить
@iulikdev
@iulikdev - 09.10.2022 10:22

yes, like rust, but rust is 100x time faster, 100x smaller, 100x less memory usage.

Ответить
@xavhow
@xavhow - 09.10.2022 07:47

AOT is great! Thanks Nick for sharing. It finally solves self-contained exe's hugh size (with runtime packaged in it).

Ответить
@user-mw4yp3jm1v
@user-mw4yp3jm1v - 09.10.2022 02:23

We need winforms support.

Ответить
@noxagonal
@noxagonal - 08.10.2022 23:54

C# native will still have more safeguards to prevent any dangerous errors, it's still garbage collected and it's still primarily heap based. This makes C# a delight to program in, but it also limits how much you can optimize your code on the low level. On the other hand, C# has automatic memory pools which makes heap allocations faster in C# than, for example C++. C++ is propably faster overall but it's not usually that much faster unless you think about the performance. Though C++ allows for more deeper optimizations which makes it run circles around C#, in those cases however you'll be writing much more custom code and thinking about CPU cache lines.

So far my experiences are... C# is easy and fast to use. C++ anywhere from medium easy to absolute nightmare depending what you're doing and how much you care about performance. C++ doesn't really have a centralized ecosystem of libraries so you may end up spending a lot of time finding the stuff you need or programming it yourself. It's really about a tradeoff between how much time you're willing to spend programming to make the application spend less time executing.

I usually prefer C++ as I find it more interesting and closer to the metal, but I also like the relative simplicity of C#. I haven't used Go, or Rust yet but I can definitely see the appeal.

Ответить
@luisz0339
@luisz0339 - 08.10.2022 22:11

Compile C#? Isn’t that just the Beef programming language?

Ответить
@thepwrtank18
@thepwrtank18 - 08.10.2022 20:09

no winforms support unfortunately

Ответить
@Bodzilla001
@Bodzilla001 - 08.10.2022 13:19

Hey Nick, can you make a video on the purpose of .pdb files and how to use them, please?

Ответить