14 ms·
.NET 8 Standalone 50% Smaller On Linux
- tomaszs 3y ago[flagged]
- ochronus 3y agoI wish people stopped using Medium for writing, it's a horrible reader experience.
- prynhart 3y agoI know right... I clicked through (after logging in) only to get "The author made this story available to Medium members only."
- tomaszs 3y agoYou can use the main link if you don't like Medium. It directs you to release notes. Visiting my article is absolutely optional: https://tomaszs2.medium.com/net-8-standalone-net-apps-now-50-smaller-on-linux-861fde887415 https://tomaszs2.medium.com/net-8-standalone-net-apps-now-50...
- mcny 3y agoI second the request to not use medium. There are tons of better options. Neocities, bear blog, mataroa blog, and so on. There is no reason to suffer with medium and all the nagging.
- tomaszs 3y ago[flagged]
- tomaszs 3y agoYou don't have to visit my article, the main release note is linked in the main topic. My article is available here: https://tomaszs2.medium.com/net-8-standalone-net-apps-now-50-smaller-on-linux-861fde887415 https://tomaszs2.medium.com/net-8-standalone-net-apps-now-50...
- fabian2k 3y agoThis is for native AOT binaries, not for the typical case. Though this release and the previous ones did contain improvements for trimming binaries, which is what you need to use to make non-AOT binaries smaller.
- silisili 3y agoCurious - why isn't it the typical case? .NET runtimes on Linux itself are rare enough, I figured AOT on Linux would be about the only use case, especially in containerized environments.
- fabian2k 3y ago.NET uses a lot of reflection, and you need to replace that with other mechanisms for AOT. And for modern .NET (previously named .NET Core, the version that also runs on Linux) you can package the runtime with the binary. You can even create single-file executables there, though those are still not AOT. The main advantage of AOT is startup time, and that didn't use to matter much for the kind of applications .NET was used for. It matters more now with serverless stuff like AWS Lambda.
- unusualmonkey 3y agoI wouldn't be surprised if reflection usage starts diminishing, with source generators solving a number of use-cases while maintaining AOT.
- fabian2k 3y agoI think that is likely, though the current source generators are often a bit cumbersome to use. Though that is why they're adding interceptors, which while it is a bit of a controversial feature is kinda necessary to implement source generators without having an annoying API.
- ziml77 3y ago
- 0xcoffee 3y agoThey also added a TimeProvider to help with testing time objects. Maybe one day we will also get an FileSystemProvider.. TimeProviderFake: https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.time.testing.faketimeprovider?view=dotnet-plat-ext-8.0&viewFallbackFrom=net-8.0 https://learn.microsoft.com/en-us/dotnet/api/microsoft.exten... ReleaseNotes: https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-8#time-abstraction https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotn...
- leosanchez 3y ago> Maybe one day we will also get an FileSystemProvider. Until then you can use System.IO.Abstraction[1] if you aren't already :) [1] https://github.com/TestableIO/System.IO.Abstractions https://github.com/TestableIO/System.IO.Abstractions
- majora2007 3y agoThis is what I use, but damn, does it make coding a bit annoying having to have an instance of the filesystem rather than using static classes like Path.
- NicoJuicy 3y agoThah. Made a "stupid" joke about this ( naming). > If you lack time to finish something, use the TimeProvider. It provides time.
- rafaelmn 3y agoThis is a result of their focus on better serverless support. Having done that recently these are really welcome improvements along with AOT stuff for EF.
- andrewstuart 3y agoWho is using .NET on Linux? I'm interested to hear success stories. Sounds like a a great way to build and deploy applications.
- actionfromafar 3y agoMostly web stuff, ASP.NET and such.
- devjab 3y agoWe do, in the few things we haven’t yet migrated away from C#. I’m curious as to why you wouldn’t, it’s much cheaper than deploying on windows since you’ll likely need a license for that. We use it for a range of things. Mostly related to the legacy software of when our developers were mostly C# developers. Which isn’t how things are now, as C# has often stood in the way of our ability to deliver business value at a rapid pace while keeping maintainable systems. Not so much the languages fault as how Microsoft manages a lot of the libraries. Like how the model builder for EF and OData (both official Microsoft libraries) don’t work together and how you need to extend basically any standard library to do any real work with them. So while it’s actually a decent language, if a bit verbose, and .NET is sort of solid these days, we honestly have very few success stories with it. Some of our AD (now Entra ID I guess) integration operates on it while we slowly migrate it to Powershell (which is .Net but runs in Azure Automation). Some of our APIs run with it. We have a few azure function apps (in containers and isolated) which are being migrated to other techs, and non-function apps. So it’s not like it’s not “working” for us, it’s just that it works a lot less great than its alternatives, even despite a it’s huge leap forward in recent years. Honestly it feels like Microsoft mostly keeps C# around because it sells licenses to medium sized stagnating companies, considering how “half-finished” a lot of the libraries are and how poorly so many of them function together.
- all2 3y agoWhat language and frameworks has your business shifted into? How has that better fit the goals of speed of development and maintainability?
- NicoJuicy 3y agoAnyone knows other alternatives for Azure Functions, but for DIY hosting? ( eg. OpenFaas - https://www.openfaas.com/ https://www.openfaas.com/ )
- redhale 3y agoYes: Azure Functions on K8s. [0] > The Azure Functions service is made up of two key components: a runtime and a scale controller. ... The Azure Functions runtime can run anywhere. ... The scale controller monitors the rate of events that are targeting your function, and proactively scales the number of instances running your app. > Kubernetes-based Functions provides the Functions runtime in a Docker container with event-driven scaling through KEDA. ... Using Functions containers with KEDA makes it possible to replicate serverless function capabilities in any Kubernetes cluster. [0] https://learn.microsoft.com/en-us/azure/azure-functions/functions-kubernetes-keda https://learn.microsoft.com/en-us/azure/azure-functions/func...
- NicoJuicy 3y agoOk. Thanks! A bit overkill to use k8s for my use-case, but didn't knew it was possible for AF.
- deleted 3y ago[deleted]
- viraptor 3y agoI've just tried to move an existing project to this and VS complained that the SDK doesn't support this version, even though I can create new projects with .net8. (preview SDKs are enabled) Is that some real limitation, or is VS being weird here? There's https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.upgradeassistant https://marketplace.visualstudio.com/items?itemName=ms-dotne... out there, but I haven't tried it yet.
- nevf1 3y agoHi, you need to make sure you're using "Visual Studio 2022 Preview", not just Visual Studio. Even with "Use Preview SDK's" enabled in the VS2022 tools and options, it will not work unless you have the preview version of Visual Studio installed. You can still create .Net8 projects in Visual Studio, but to build and run them, you will need to do it from the command line (i.e. 'dotnet run').
- viraptor 3y ago(facepalm) every time I assume that maybe I'm doing something wrong rather than VS being the weird one in the room, they have to prove me wrong...
- pansa2 3y ago2MB for a standalone “Hello World” binary in C# is a similar size to one in Go. Do both languages produce similar-sized binaries for larger projects as well? If so, would C# be a good choice for writing cross-platform command-line applications? It seems that C# can produce easily-distributable binaries, while also hitting a sweet-spot in language design - not super complex like C++ or Rust, and also not overly simplistic like C or Go.
- criddell 3y agoAside from syntax preferences, why and when would one choose Go over C#?
- FieryTransition 3y agoBecause it was made to run on Linux from the start. I remember being excited to work with .net core on Linux, then discovering that most of the system libraries for network programming and related were either not implemented or badly working, but you would only find out if dug deep into low level stuff. After that, I swore of using it seeing how much the hype for cross platform didn't match reality. Hopefully they fixed it, but seeing as there are other choices of languages, it wasn't so bad.
- sylens 3y agoI have not begun really using Go in earnest yet, but at least in the cloud engineering world it seems to be the language of choice (along with Python) due to the ease of using its concurrency capabilities
- pansa2 3y agoWhen Go first came out, it was better than C# in terms of support for concurrency, stand-alone binaries, and cross-platform. It seems that C# has done a lot of catching up since then, though.
- zerr 3y agoYou don't. Production ready statically compiled native C# is a death sentence for Golang :)
- solarkraft 3y agoWhat the .NET team does on the technical side is almost universally wonderful. They've (ironically?) been a bit more successful than the Java folks at establishing multiple serious languages of different kinds running on and interoperating via the same runtime. But it's still a Microsoft project and their sword keeps looming over its head. There have been some heavy-handed anti-developer choices in the past and one can safely assume that that has been their EEE-genes kicking in and it will probably not get better, but worse, the more they build up a community they feel they have (or should have) control over. Wouldn't want to dive into that pool. .NET is only as good as the parts Microsoft doesn't have too much control over and that doesn't even include the VSCode extension (or VSCode itself - Use VSCodium and you'll see).
- lemper 3y agomakes me remember about that meme where it depicts microsoft as an org with many divisions pointing guns at each other. devdiv is the good guys while sales dept. is the hated one.
- neonsunset 3y agoHave you looked at Google recently or Oracle for the entirety of its history?
- Clamchop 3y ago> They've (ironically?) been a bit more successful than the Java folks at establishing multiple serious languages of different kinds running on and interoperating via the same runtime. Can you explain more? I'm less familiar with the .net side of things.
- eddythompson80 3y agonot OP, but I'd guess they are referring to F# and C# interoperability. It's trivial to call into each other from within the same project. I'm not as familiar with this on the JVM side myself. How easy/common is it to have multi-language projects? Because in .NET it's very common to have C# interface to F# projects and vice versa with minimal work.
- fwsgonzo 3y agoIs static linking supported now? It's the one blocker for me to use C# in weird places. I'm good at hacking the underlying environment to make it work, but dynamic loading is not on the table.
- neonsunset 3y agoIt is - https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/interop#linking https://learn.microsoft.com/en-us/dotnet/core/deploying/nati.... You can even do the reverse and statically link NativeAOT-built libraries into existing projects written in "unmanaged" languages (though that naturally limits you to C interop).
- tomaszs 3y agoYou can find summary of the release in my article: https://tomaszs2.medium.com/net-8-standalone-net-apps-now-50-smaller-on-linux-861fde887415 https://tomaszs2.medium.com/net-8-standalone-net-apps-now-50...
- KacharKhan 3y agoEverything dotnet is doing for cross-platform is great and better than alternatives --- except one HUGE issue: There is no official GUI on Linux. Linux's exclusion from MAUI (while 25% of world's developers' primary dev machine is a Linux system according to Stack overflow survery) creates a huge hurdle for those developing on Linux to build any cross platform GUI app with dotnet. If I , as a developer developing a windows/mac/mobile app with official dotnet, am using Linux for development , I cannot create a GUI app. Hey dotnet folks! -- let me put a god damn button on the screen! Sincerely A Linux dev [Don't get at me with Avalonia/Uno etc. I am talking about "official" GUI. A graphical user interface is not a specialized domain, or some niche to be left for others to fill. It is a core element of a user facing app. ]
- rstat1 3y agoThere's no "official GUI" (w/e that means) on Linux for anything though, so it makes sense. Avalonia exists, and from the looks of it is better than all the crap MS has put out over the years (even on Windows, don't get me started on WPF shutters) so not using it because its not "official" is silly.
- KacharKhan 3y agoI never said I don't use or don't want to use Avalonia. The issue is not the quality of Avalonia/Uno. They are wonderful. The issue is not availability of third-party toolkits -- they are there. The core issue is being psychologically assured that the first party is interested in supporting my platform with its programming languages and libraries. If MS can support Mac, ios, and Android -- what exactly prevented it from supporting Linux ?? This conspicuous lack of support in the presence of support for other non-MS platforms is the most bothersome bit. And supporting Linux can't be too expensive either. If Avalonia and Uno being open source with no backing of a huge corporation can do it in their stride -- then Microsoft sure as hell can do it. Again , this time economically --- why exactly is MS supporting Mac, ios, and Android -- not Linux ???. I hope you see my point. The absence of MS support is not bothersome technologically. It is problematic attitude wise. If they are fine with not doing GUI on linux (while doing it on all the other platforms) --- what other features/enhancements they will be willing to hold back from Linux ??