3 ms·
> C# is the language with the best degree of control over allocation among all GC-based languages. It's the best, but if I can't say: "never heap allocate unde
by 15155 2y ago
> C# is the language with the best degree of control over allocation among all GC-based languages.
It's the best, but if I can't say: "never heap allocate under any circumstances," it's a problem.
- neonsunset 2y agoYou can :) It just requires going out of your way a bit. It effectively works as C with better type system and generics (C++ lite if you will), that can be either JIT or AOT compiled (statically linked too). For example https://github.com/bflattened/bflat https://github.com/bflattened/bflat has a target flavour that does not support GC at all. I'm not saying it's an optimal choice for embedded, only pointing out that you can write allocation-free code with confidence. Patterns that allocate are known - predominantly boxing and closures. You can easily avoid both, you can also declare your structs as 'ref struct' which completely prohibits placing them on the heap, either as a box or as a part of heap-allocated memory inside some other object/struct.