Optional “Library-Only” Mode for C# #9864
Replies: 1 comment 3 replies
-
|
What change are you suggesting be made to the language itself. It sounds likke you are proposing library changes (and potentially compiler changes) which are outside of the language. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
TL;DR: Introduce an optional “library-only” mode for C#—similar to AOT—to enable lightweight, portable code without runtime overhead. This split between C# (language) and .NET (runtime) would unlock new scenarios for AI, Web (Blazor), and edge environments while preserving the full experience for most users.
C# has matured into a versatile language, but its reliance on a runtime limits adoption in constrained environments (e.g., iPhone/iPad). Introducing an optional “library-only” mode would allow developers to target platforms without runtime overhead while preserving the full experience for most users. With .NET 10 entering extended support and C# 15 on the horizon, now is the ideal time to draw a clearer line between C# (the language) and .NET (the runtime).
The vast majority of C# can be implemented on top of “just a library”; a full runtime is only needed for a handful of features, reflection being the most obvious. C++26 demonstrates that reflection can be achieved at compile-time, and the success of C, C++, and Swift shows that languages without mandatory runtimes remain powerful.
Making this optional—like AOT—mitigates disruption. The compiler would reject runtime-dependent code when “library-only” mode is enabled, while .NET 11 would continue to ship with the full runtime by default. Why now? AI-driven workloads increasingly demand lightweight, portable code for edge devices and specialized environments. A “library-only” C# unlocks new scenarios for AI inference on constrained hardware, embedded systems, and secure environments—without sacrificing the productivity that makes C# so loved by developers.
A minimum viable product (MVP) for C# 15 and .NET 11 could focus on the “big split” itself: introducing the optional library-only mode and enforcing compile-time checks for runtime-dependent features. Future versions of C# could then work to close the feature gap, perhaps by leveraging lessons from C++ and other languages that have successfully implemented compile-time capabilities such as reflection and advanced metaprogramming. This phased approach minimizes disruption while laying the foundation for a more portable, flexible C# ecosystem.
Beta Was this translation helpful? Give feedback.
All reactions