3 ms·
You might just be looking at the language from a syntax perspective. However the two are very different in the way that you compile and run them. In C# the code
by alblue 11y ago
You might just be looking at the language from a syntax perspective. However the two are very different in the way that you compile and run them. In C# the code is translated into a custom bytecode (IR) and then the CLR is used to execute that and manage the memory through GC.
In Swift's case it compiles down to native processor code instructions and can have optimisations applied ahead of time. This allows the app to run faster than a VM+JIT would do and therefore longer batter management. The overhead of the runtime is a lot lower since memory is ref counted and doesn't need to run GC periodically.
- jnericks 11y agoYou are correct but part of the work being done to get .NET native working is the aot compilation. https://blog.rendle.io/what-ive-learned-about-dotnet-native/ https://blog.rendle.io/what-ive-learned-about-dotnet-native/
- pjmlp 11y agoC# has always had support to AOT to native code since the early days via ngen. The only issue was that more effort was spent in the JIT compiler and ngen requires dynamic linking. C# is compiled to native code on Windows Phone since version 8. The C# extensions for Singularity (Sing#) and Midori (System C#) generate static binaries. Work which served as starting point to MDIL on WP 8.x and .NET Native. The new .NET Native compiler even exposes SIMD. Mono also supports AOT compilation since a long time. As always language != implementation.
- deleted 11y ago[deleted]
- ianlevesque 11y ago.Net Core can compile AOT as well, and Xamarin already does that on iOS with its Mono runtime too.
- bitmapbrother 11y agoART also compiles down to native code. As for performance comparisons - last time I checked the benchmarks for Java were still faster than Swift.