Building the Smallest C# Game That Doesn’t Need .NET

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024

ความคิดเห็น • 128

  • @pritishranjan
    @pritishranjan 8 หลายเดือนก่อน +51

    This is insane. Please tell us more on bflat and more like this.

  • @F1nalspace
    @F1nalspace 8 หลายเดือนก่อน +43

    Wow i never expected this in C#. Really cool!
    I didn't read the article, but i assume it works by fully stripping out the entire runtime and unused functions. Because the game itself just calls pure system functions from the win32 api stack and does not use the GC. Also the win32 libraries that are used (kernel32 and user32) are not statically linked, instead it is runtime linked - meaning LoadLibrary() and GetProcAddress() is used. Btw. these techniques are well known in the demo-scene and used in languages such as C and object pascal. For example there was a fully working C64 emulator (Brotkästchen) written in borland delphi 5 that compiles to an executable with just 64 KB.

    • @shahzaibhassan2777
      @shahzaibhassan2777 8 หลายเดือนก่อน +1

      Does static linking kinda mean 'Embedded'?

    • @F1nalspace
      @F1nalspace 8 หลายเดือนก่อน

      @@shahzaibhassan2777 Yes, the more libraries you statically link, the more larger your executable will become.

    • @xormak3935
      @xormak3935 8 หลายเดือนก่อน

      @@shahzaibhassan2777 Pretty much, yeah.

    • @ProtossOP
      @ProtossOP 8 หลายเดือนก่อน

      @@shahzaibhassan2777 it means code is pasted inside your program

    • @patvax532
      @patvax532 8 หลายเดือนก่อน

      @@shahzaibhassan2777 Static Linking effectively means that whatever you linked will be inside of your final output, as opposed to dynamic linking where your libraries will be linked during startup. Embedded as in contained in your final exe/dll.

  • @XennialGeek
    @XennialGeek 8 หลายเดือนก่อน +17

    I read that article yesterday. Pretty cool that you are doing a video about it, despite its extremely niche use case.

  • @tonicblue
    @tonicblue 8 หลายเดือนก่อน +8

    This was super interesting and I'm glad the algorithm recommended it. I was a C# dev for about 8 or 9 years but switched to pretty much straight Node.js for the last 7.
    Seeing tooling and this sort of thing is making want to come back a bit and see what I can do. I've got enough gripes with JS and its eco system but I see it's benefits. Knowing that you can do this sort of thing with C# is inviting. I'd really want to see how it compares to Go in performance. Might give it a try, just hope it plays well with Linux!

  • @EduardoAG
    @EduardoAG 8 หลายเดือนก่อน +4

    I just got this article on yesterday's C# Digest but I prefer a 12 min video than a 14 min read lol

  • @jemakrol
    @jemakrol 8 หลายเดือนก่อน +2

    IOCCC for C# next? :D
    The line between language abuse and optimization is thin.
    AWESOME!!

  • @jongeduard
    @jongeduard 8 หลายเดือนก่อน +6

    Wow! NO garbage collector! That is one of the points that Bflat mentions. I guess that means that most standard dotnet stuff becomes totally impossible, even Strings. LOL.
    But an unsafe application that only targets native Win32 stuff should indeed be able to run. Everything completely unmanaged.
    However, to be honest, I don't think C# is really a serious option anymore here. Here is where I just like Rust a lot more, or even C and C++, because those languages are actually designed for this job. And C# is simply not.
    As an experimental showcase though, I think this is cool.
    Rust with a garbage collector would also by nice for one moment. Just to see that it's possible.

  • @dsuess
    @dsuess 8 หลายเดือนก่อน +3

    **Make Code Small Again**
    I LOVE this!! Amazing video, Nick. Every year new toolings come out and default sizes only get larger and larger. Long gone are the days of KB sized GUI apps with minimum resource usage. Really hope this makes a come back again.

    • @mariocamspam72
      @mariocamspam72 8 หลายเดือนก่อน

      The idea itself I agree with, but like, this is sacrificing essential parts of the runtime and portability just for code size reduction

  • @SudhanshuMishrafxpert
    @SudhanshuMishrafxpert 8 หลายเดือนก่อน +1

    Great to see what's possible! Please make a video about bflat, it looks intriguing.

  • @JoelBrage
    @JoelBrage 8 หลายเดือนก่อน +39

    This just so cool. I love optimizations in general but this is something extra. What happened to performance and memory usage along the way?

    • @felipealves4856
      @felipealves4856 8 หลายเดือนก่อน +1

      For this particular project, you say? If it is, I believe that it is very optimized, as the maze game makes full usage of OS API calls and unsafe, self-managed resources. There doesn't seem to be any need for garbage collection at all, in this case.

    • @mona_raiden
      @mona_raiden 8 หลายเดือนก่อน +1

      memory? GC left from building a long time ago in the video lmao (jk jk)

  • @ukasz-xn8kn
    @ukasz-xn8kn 8 หลายเดือนก่อน +1

    Some ideas for practical usage of bflat would be welcome. Thank you for the video!

  • @brucebroussard2565
    @brucebroussard2565 8 หลายเดือนก่อน +1

    Reminds me of the old borland turboc from the 80's which as very fast and could be optimized extremely well. Everything old is new again.

  • @josephizang6187
    @josephizang6187 8 หลายเดือนก่อน +2

    Please a bflat video would make a ton of sense

  • @Lombardio
    @Lombardio 8 หลายเดือนก่อน +2

    I don't see myself using bflat in my day job, but I would watch a video about its features.

  • @Biztactix
    @Biztactix 8 หลายเดือนก่อน +2

    Yeah, I'd like to know more about the limitations for Bflat... as I have a few apps which call external windows functions, registry, eventlogs, wmi etc... and I have them AOT'd already... but if there's a significant difference in size, that could be interesting

  • @logank.70
    @logank.70 8 หลายเดือนก่อน +2

    If I'm being honest. My brain is saying two things. The first is "this is really cool" and the second one is "but why?" There are times where just because you can doesn't mean you should. Maybe the Bflat project falls into that or maybe it doesn't. I honestly don't know. It definitely is really neat though.

  • @CharlesBurnsPrime
    @CharlesBurnsPrime 8 หลายเดือนก่อน +1

    Look up 4k demos. One I remember is droplets of water, rendered with software raytracing, merging and splitting in real-time (and the program was under 4KB.
    This C# demo is in some ways more impressive because it is written in a high-level (sort of, looking at the code) language rather than assembly language, and it doesn't use any crazy tricks like fractal data generation.
    Another was the first level of the Interplay game Descent, including music, the 3D level, and lava animations, in 4k.
    Another was a terrain generator called "mars", which was, IIRC, about 2.8K, and generated unlimited random Martian terrain (the detail wasn't great, mostly red hills). Still a better plot than most Bethesda games.

  • @ErazerPT
    @ErazerPT 8 หลายเดือนก่อน +27

    Impressive, but in the end i think it more illustrates how the "usual thing" is pretty wasteful and "loose" than anything else. Reason that "trim obvious fat" isn't default is probably because lord knows how much dependency you have on reflection and/or dynamic code creation.

    • @qj0n
      @qj0n 8 หลายเดือนก่อน +2

      There is also a tradeoff between binary size, memory allocation, startup time and performance. If you optimize towards one of them, you probably loose the others
      In this case, he compresses the binary, so startup is longer and possibly you might store both versions in ram, at least for some time. The static loading of libraries prohibits you from usibg gac or sharing the same lib between apps. Size optimisation will not expand loops, so you loose performance on branch prediction
      Everything has its cost

  • @nimce4u
    @nimce4u 8 หลายเดือนก่อน +1

    bflat sounds amazing! please do a video about it

  • @antonmartyniuk
    @antonmartyniuk 8 หลายเดือนก่อน

    After seeing this I need to hire Nick to trim one of the applications running on the paying terminal device

  • @tellur808
    @tellur808 8 หลายเดือนก่อน +6

    Reminds me of that 64Kb game from a couple years back that was a fully fledged shooter with for the time decent graphics and sound, all in a 64 kilobyte install.
    Technologically completely different (they used DirectX or openGL to do most of the heavy lifting) but still crazy what can be done with extremely little

    • @instazx2
      @instazx2 8 หลายเดือนก่อน +2

      farbrausch!

    • @samuelschwager
      @samuelschwager 8 หลายเดือนก่อน +2

      kkrieger?

    • @reikooters
      @reikooters 8 หลายเดือนก่อน

      I remember playing it when it came out and that was more like 20 years ago actually

    • @tellur808
      @tellur808 8 หลายเดือนก่อน

      @@reikooters don't think it was quite 20 years, but more than 10 definitely

    • @samuelschwager
      @samuelschwager 8 หลายเดือนก่อน

      @@tellur808 2004!

  • @waleed-alshinawi
    @waleed-alshinawi 8 หลายเดือนก่อน +1

    Thank you for the video Nick, can you make a video where this is related to dotnet api.
    Thanks again

  • @Spud9
    @Spud9 8 หลายเดือนก่อน +1

    I think if this was boiled down to a single tool and simplified command flags it would be super useful if size was something you were focused on.

  • @aurinator
    @aurinator 8 หลายเดือนก่อน +2

    While I can definitely agree with more than a few posters that this is insane, I'm also going to argue that this isn't really C# - certainly not by itself IMO. But I can at least agree that everything is being orchestrated in C# but it's just P/Invoking into the native land where all the magic happens. So in that respect C# is almost like a Kubernetes to all of the linked (P/Invoked) Services.

    • @obinnaokafor6252
      @obinnaokafor6252 8 หลายเดือนก่อน

      It is C#. Every programming language has interoperable capabilities as well as ability to call into the native layer.

  • @ВладКалашников-м8п
    @ВладКалашников-м8п 8 หลายเดือนก่อน +1

    Thanks for the video :) Please make a video about bflat too

  • @derangedftw
    @derangedftw 8 หลายเดือนก่อน +1

    I wish I could create a framework / engine that takes advantage of this and become a Unity competitor. I wouldn't even know where to start and I've been engineering for 14 years in a completely different field of study. I better get on it...

  • @Andrew90046zero
    @Andrew90046zero 8 หลายเดือนก่อน

    I appreciate that you didn't want us to have a stroke from seeing egregious code XD
    (btw, I didn't see the code yet, still watching the video)
    The only thing I am dissapointed by with this video is, not seeing a QR code of the binary exe file :P
    I hope that is indeed possible.

  • @jigneshkusakiya8570
    @jigneshkusakiya8570 8 หลายเดือนก่อน

    Hello Nick,
    Please can you make a video on how to start with DSA in C# or a road map kind of video.
    Thanks

  • @JoelSantosPt
    @JoelSantosPt 8 หลายเดือนก่อน +7

    I would just go with C++ at that point 😅

    • @MaximilienNoal
      @MaximilienNoal 8 หลายเดือนก่อน

      Nah, Rust all the way.

    • @foobar69
      @foobar69 8 หลายเดือนก่อน

      ​@@MaximilienNoalrust is just an uglier way of doing the same thing as cpp.

  • @naveedahmed6868
    @naveedahmed6868 8 หลายเดือนก่อน +1

    Definitely, I would like to know more about bflat 😂

  • @finald1316
    @finald1316 8 หลายเดือนก่อน +5

    B flat for C sharp... I see no pun here.

    • @nius3774
      @nius3774 8 หลายเดือนก่อน +4

      It takes something sharp and commands it to be flat (the opposite of sharp). I guess it could be called RemovEdge or NoEdge, but that's not allowed at Microsoft.

  • @Mikarsoft
    @Mikarsoft 6 หลายเดือนก่อน

    I want to make an IDE based on BFlat where it will have a fully functional nuget package manager and project templates. BFlat 8.0.2 is awsome.

  • @SecondFinale
    @SecondFinale 8 หลายเดือนก่อน

    I'm surprised trimming isn't a bigger priority. Bflat looks really cool.

  • @LoKSET
    @LoKSET 8 หลายเดือนก่อน

    That's like C++ with extra steps at this point 😀

  • @bambosa4952
    @bambosa4952 8 หลายเดือนก่อน +2

    I wonder how allocations work in zerolib if there is no GC, most likely why most things are static. Is there an allocator included in the lib?

    • @tj_r_3679
      @tj_r_3679 8 หลายเดือนก่อน +1

      No in Zerolib there is no GC

  • @iron_spark
    @iron_spark 8 หลายเดือนก่อน

    This is amazing!

  • @khsumate
    @khsumate 8 หลายเดือนก่อน

    cool, please do more vdo for bFlat.
    also the c# self-contain aot .exe with windows gui from both .net and bFlat.
    thanks

  • @ianknowles
    @ianknowles 8 หลายเดือนก่อน +1

    Nick never programmed a dam thing on a Speccy ;)

  • @vandermjr
    @vandermjr 8 หลายเดือนก่อน

    Very good raycast!!!!

  • @ousspero
    @ousspero 8 หลายเดือนก่อน +1

    If this supports WebAssembly, it would be insane.

  • @QwDragon
    @QwDragon 8 หลายเดือนก่อน

    Great!
    But what does antivirus thinks about this app?

  • @FazMize
    @FazMize 8 หลายเดือนก่อน

    What is that fancy terminal ?

  • @rivercitron2000
    @rivercitron2000 8 หลายเดือนก่อน +1

    I was actually waiting for the QR code 😢

  • @Dennis67334
    @Dennis67334 8 หลายเดือนก่อน

    Any reason you are not switching to the new UI?
    Just curios.

  • @SodomEndGomorra
    @SodomEndGomorra 8 หลายเดือนก่อน +1

    Fork bomb in qr? Who test?

    • @marcovonhagen
      @marcovonhagen 8 หลายเดือนก่อน

      I will never ever scan a qr code again 😂

  • @tosunabi1664
    @tosunabi1664 8 หลายเดือนก่อน

    Crazy.

  • @T___Brown
    @T___Brown 8 หลายเดือนก่อน

    Cool stuff but i would rather see what can be done on api's than a game. Same with the new trimmed containers.

  • @viktoralferov2874
    @viktoralferov2874 8 หลายเดือนก่อน

    We call it: Evolution, Mr. Anderson...

  • @cverde1234
    @cverde1234 8 หลายเดือนก่อน

    One day we'll share modern applications on floppy disks

  • @charles_kuperus
    @charles_kuperus 8 หลายเดือนก่อน

    Yes please gives us a video on bflat

  • @KvapuJanjalia
    @KvapuJanjalia 8 หลายเดือนก่อน

    DllImport with asterisk as a DLL path is new to me. What even is that?

  • @aul7643
    @aul7643 8 หลายเดือนก่อน

    damn this is insane

  • @adamwox
    @adamwox 8 หลายเดือนก่อน +2

    And we are still getting the 200GB update to Call of Duty... 🤦‍♂

  • @shahzaibhassan2777
    @shahzaibhassan2777 8 หลายเดือนก่อน

    This is insane

  • @lmao01
    @lmao01 8 หลายเดือนก่อน

    I dont understand why it isnt done by default (i.e. stripping of unused methods) when it literally saves 90% + of size.

  • @one.pouria786
    @one.pouria786 8 หลายเดือนก่อน +1

    A very cool way to develop malware ... 😅

  • @kinsondigital
    @kinsondigital 8 หลายเดือนก่อน

    Bflat? Yes please, give me another.

  • @2710dw
    @2710dw 8 หลายเดือนก่อน

    Such a missed opportunity for bflat to be called Bb.

  • @ks1970in
    @ks1970in 8 หลายเดือนก่อน

    These settings should be default

  • @JamesHarrisonHaribo
    @JamesHarrisonHaribo 8 หลายเดือนก่อน

    I’d love to see the memory usage as well.

  • @thedude6810
    @thedude6810 8 หลายเดือนก่อน

    Size matters, bigger is better.

  • @sergey5996
    @sergey5996 8 หลายเดือนก่อน

    Why

  • @md.jannatulnayem4328
    @md.jannatulnayem4328 8 หลายเดือนก่อน

    Bring us more bflat content 🥹

  • @HimmDawg
    @HimmDawg 8 หลายเดือนก่อน +7

    There's a video from MattKC where he actually put a game into a QR-Code and he also used crinkler. However he could only fit snake into the code. Having a 3d graphics game this small kinda blew me from my chair, not gonna lie.

  • @shioli3927
    @shioli3927 8 หลายเดือนก่อน +2

    The zero std lib sais it does not have a garbage collector? So does that mean your game will just memory leak if it ever allocates anything, at any point. I mean I get it for small CLI tools, garbage collection tends to be useless work, because you can just explode the process afterwards. If your total program runtime is a fraction of a second who cares. Is that the intention? Because, I have no idea how I would even deallocate anything in c# by hand. There might be some unsafe black magic.

  • @Mosern1977
    @Mosern1977 8 หลายเดือนก่อน +4

    Very interesting. Some times you need smaller executables, so these are some very good tricks to know about.

  • @AndrewJonkers
    @AndrewJonkers 8 หลายเดือนก่อน +2

    I started programming way back when hand coding byte sized registers with switches. I have NEVER understood the size bloat that has been with us in the decades since. All we are doing here is returning to what should have been before memory and disk space became so cheap and we did not have to bother doing it right first time. My own view is that a code executable should always be derived from a complete source code that then goes with compiler/linker tooling options right to the metal of the CPU. None of this proprietary library crap.

  • @farzadmf
    @farzadmf 8 หลายเดือนก่อน +5

    I wish they'd named it 'dflat`

    • @nius3774
      @nius3774 8 หลายเดือนก่อน +2

      Yeah, they went for "be flat" (remove sharpness) instead of musical notation correctness.

    • @farzadmf
      @farzadmf 8 หลายเดือนก่อน

      Nice, good to know; that didn't come to my mind

  • @mariocamspam72
    @mariocamspam72 8 หลายเดือนก่อน +3

    If CsWinRT were trimmable, could it perhaps could have been used instead of manual Win32 pinvoking?

  • @ДмитрийДмитриев-р9з
    @ДмитрийДмитриев-р9з 8 หลายเดือนก่อน +1

    I think that we wasting a lot of SSD space to store a lot of dotnet runtime copies

  • @themiwi
    @themiwi 8 หลายเดือนก่อน +1

    Have you tried running the exe through UPX? Usually that's able to squeeze out 50ish%.

  • @JoeLizFamily4
    @JoeLizFamily4 8 หลายเดือนก่อน +2

    Interesting how you can make it so small but practically not too useful for me to go all the way down. I think the first suggestion to build "self-contained" is a good option.

  • @brunettimarco
    @brunettimarco 8 หลายเดือนก่อน +1

    bflat as name is genius

  • @obinnaokafor6252
    @obinnaokafor6252 8 หลายเดือนก่อน +1

    Michael already did that. C# and #dotnet are amazing.

  • @alexclark6777
    @alexclark6777 8 หลายเดือนก่อน +1

    I read through Michal's entire blog a few weeks ago when this popped up on Reddit. I'm fairly certain he lives on an island somewhere with a white cat and a giant fish tank full of sharks (possibly with lasers attached to their heads).

  • @yordantodorov1890
    @yordantodorov1890 8 หลายเดือนก่อน +2

    Man, this stuff is crazy! You are great🎉

    • @stevenj8261
      @stevenj8261 8 หลายเดือนก่อน

      This is Michal creator of bflat which rocks
      podcasts.google.com/feed/aHR0cHM6Ly90aGVkb3RuZXRjb3JlcG9kY2FzdC5saWJzeW4uY29tL3Jzcw/episode/NmI2OWU4NWYtMzcwMS00ZTRmLWI2NGMtZjZmMTI3MjJlZDVk?ep=14

  •  8 หลายเดือนก่อน +1

    All game studios should learn this trick, maybe the games will be again available to share via diskettes instead of the size 160GB :D

    • @igorthelight
      @igorthelight 8 หลายเดือนก่อน +1

      In modern AAA games most if it's size are 4k videos and 4k textures.
      Some repackers let you to not download unnecessary things.
      (I'm still buying games tho, but when I was a student - that was a totally different story... ;-) )

    •  8 หลายเดือนก่อน

      @@igorthelight I know :)

  • @vincentverweij1053
    @vincentverweij1053 8 หลายเดือนก่อน

    Anyone else who thought about a musical scale after watching this... C sharp, b flat, f sharp, where's the rest of the scale. Joking aside, great video Nick!

  • @burtonrodman
    @burtonrodman 8 หลายเดือนก่อน

    i’ve been looking at the possibility of using nanoframework for RP2040… there’s been work to add support but it’s rough going. if we could bring Sdk style project and use a similar stack to this video i think it could solve a lot of issues

  • @modernkennnern
    @modernkennnern 8 หลายเดือนก่อน +1

    This is really cool, and shows the potential future of native aot

  • @alistermunro7090
    @alistermunro7090 8 หลายเดือนก่อน +1

    Nice to see some proper code in C#

  • @457Deniz457
    @457Deniz457 8 หลายเดือนก่อน +1

    3..2..1.. new viruses will come 😅

  • @joost00719
    @joost00719 8 หลายเดือนก่อน

    I'm curious how this improves performance

  • @swordblaster2596
    @swordblaster2596 8 หลายเดือนก่อน

    Fun, but of limited application TBH.

  • @newgap1980
    @newgap1980 8 หลายเดือนก่อน

    Could be nice if this works with Blazor

  • @SajjadArifGul
    @SajjadArifGul 8 หลายเดือนก่อน

    awesome 😮

  • @stepanhakobyan
    @stepanhakobyan 8 หลายเดือนก่อน

    Unity successor may use this.

  • @oscareriksson9414
    @oscareriksson9414 8 หลายเดือนก่อน

    Finally!🎉

  • @urbanelemental3308
    @urbanelemental3308 8 หลายเดือนก่อน

    Show me bflat if there's a chance I'll actually use it

  • @chrisnuk
    @chrisnuk 8 หลายเดือนก่อน

    Excellent, I knew I shouldn't have thrown my floppy disk drive away..

  • @zhh174
    @zhh174 8 หลายเดือนก่อน

    anything on memory usage and performance of bflat?

  • @JustNightmare
    @JustNightmare 8 หลายเดือนก่อน

    Do a video about b flat

  • @daStitches
    @daStitches 8 หลายเดือนก่อน

    This is wild, would definitely like to see more on bflat.

  • @ionutdogaru8533
    @ionutdogaru8533 8 หลายเดือนก่อน

    Best in wasm projects. Thanks !

  • @lordmetzgermeister
    @lordmetzgermeister 8 หลายเดือนก่อน

    The thumbnail is literally what she said

  • @AnnasVirtual
    @AnnasVirtual 8 หลายเดือนก่อน

    that's crazy

  • @LukasPetersen-bm4ep
    @LukasPetersen-bm4ep 8 หลายเดือนก่อน +2