Hacker Newsnew | past | comments | ask | show | jobs | submit | MStrehovsky's commentslogin

Do you have data backing that up? Per https://github.com/MichalStrehovsky/sizegame:

C#: 945 kB Go: 2174 kB

Both are EXEs you just copy to the machine, no separate runtime needed, talks directly to the OS.


Sadly yes, we have data. We are migrating our C# SDK to Rust in part because customers want a much smaller dependency. And the AoT compiler didn't trimmed as much as we wanted.


(regarding size - there are tools like sizoscope to understand what is taking space, sometimes it’s something silly like rooting a lot of metadata with reflection referencing many assemblies or because of abusing generic virtual members with struct parameters in serialization, obviously if you can use Rust without productivity loss it’s fine, but usually problems like that take an hour or two to solve, or less)

But in either case binary sizes are smaller and more scalable than what Go produces. The assumption that Go is good at compact binaries just does not replicate in reality. Obviously it’s nice to be able not touch it at all and opting into Rust for distributing native SDKs. Go is completely unfit for this as it has even more invasive VM interaction when you use it as dynamically linked library. NativeAOT is “just ok” at this and Go is “way more underwhelming than you think”.


I think we would have preferred continuing with .NET, as no one is Rust expert on the team. But binary size and lack of some SIMD instructions moved the balance to Rust. And then, the PoC had big memory usage improvements, so...


What kind of SIMD instructions were not available? I assume something like AVX512GFNI or SHA x86 intrinsics?

I think if you're in domain of using SIMD, besides base RAM usage of 2-5MB you should not see drastic difference unless you have a lot of allocation traffic. But I guess Rust solved most of this, just wanted to note that specific memory and deployment requirements are usually solvable by changing build and GC settings.


Is AOT compiling your binaries [1] an option for you? The starting size of AOT compiled C# can beat Go in size [2] and from there it really depends on what you do and how you do it. Some simple ASP.NET server with https and routing can comfortably fit under 10 MB and there are compilation options that can help optimize further [3].

[1] https://learn.microsoft.com/dotnet/core/deploying/native-aot... [2] https://github.com/MichalStrehovsky/sizegame?tab=readme-ov-f... [3] https://learn.microsoft.com/dotnet/core/deploying/native-aot...


I looked into it but some libraries I've been using wasn't compatible with AOT. I'll check it again when I have more time. Thanks.


> Fair enough; perhaps it'd be worthwhile to throw a compiler error if both reflection and trimming were attempted.

The tooling already generates warnings for any spot in the program that uses reflection _in a way that cannot be statically analyzed_. Fixing code to make it work with trimming is equivalent to fixing warnings. Here are a couple case studies: https://devblogs.microsoft.com/dotnet/creating-aot-compatibl...


Someone with an iPhone told me the webm video embedded in the article still doesn't work on iPhones in 2024 so here's another link to the video: https://twitter.com/MStrehovsky/status/1742101904250060842


It's a webm, looks like Apple still didn't implement it on iPhones. Here is another version of the video on a website that may work better on iPhones: https://twitter.com/MStrehovsky/status/1742101904250060842


The repo does mention the Pi. I just forgot to talk about the Pi specifically in the article, sorry. https://github.com/MichalStrehovsky/uefimaze


Here's an example [1] of a device driver in C#. It is possible. It is also not recommended.

[1] https://github.com/VollRagm/KernelSharp


I thinking “this is some project probably written years ago and loading the .NET Framework runtime into kernel space” but this is actually using NativeAOT and the latest features/SDK.


ZeroSharp is done by the same person as bflat (me). These ZeroSharp samples get broken all the time because they bend the MSBuild targets that ship with .NET to an extreme. Bflat is a more supportable route and has a couple extra customizations to the compiler specifically for these scenarios.


Some executable file formats have time stamps in them.

bflat follows the platform convention that respects this and writes current date/time in the file header by default.

It is also a platform convention to offer options to set these to something stable (e.g. `/Brepro` on lld-link, or `--deterministic` for bflat) if one wants stable output.


dflat could imply it has something do to with dlang.

bflat triggers a lot of engagement on Twitter and elsewhere because everyone wants to correct it. Couldn't have chosen a better name.


"Double sharps" exist; they could have gone with "B double sharp". (Not saying they _should_ have -- just pointing out the option.)


Also Be-sharper would have been a great pronouciation.


Wouldn't B double sharp just be C? I guess they'd need to call it "B triple sharp", which is just getting silly.


There's no black note between B and C, so B sharp would be the enharmonic of C. B double sharp would be the enharmonic of c#


There's no sharp/flat note between B and C - "B sharp" would be C.


Indeed -- curse you, irregular standard note structure!


mnemonic:

C D E F G A B [C]

is

do re mi fa sol la si [do]

mi (E) and si (B) end with "i" and are the two ones that are half a step away from the next ones.


Only in "fixed do" version though, because we can't make music notation too easy or consistent...


G is just 9-fold-sharp B, really


ultra-pedantically: that's true with the "well tempered" tuning that is used almost universally. But this is really just an approximation, and one that our ears have grown used to.

Mathematically speaking, B# <> C. On a piano or other instrument that quantizes tones, we have little choice but to go with the approximation. But for violinists and others that can choose from a spectrum of tones, it's possible to hit those tones exactly. Of course, when playing with others, the violin still needs to quantize just to be in tune with the others.


Even more pedantically, modern stuff uses equal-temperament, not well-temperament.

Well-temperament still has different intervals depending on key. Even temperament just uses x^n/12 for note n and basis frequency x.


If anyone wants to do down that rabbit hole for 15min, there's Adam Neely's recent video on the topic: https://youtube.com/watch?v=SZftrA-aCa4


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: