.NET
C# and .NET - Past, Present, Future
February 13th, 2002
Linux is a cancer that attaches itself in an intellectual property sense to everything it touches.
Google?
Facebook?
Meta?
Image source: https://de.wikipedia.org/wiki/Newton_(PDA)#/media/Datei:Apple_Newton.jpg
Hyper-V?
κυβερνήτης?
Containers?
Servers...
Image Sources: https://commons.wikimedia.org/wiki/File:Computer_server_rack.jpg
https://www.flickr.com/photos/pascalmaramis/8916250698
...like Tamagotchis
A little bit
of history...
A little bit of history...
- .NET Framework at its beginnings
- Windows only
- Closed source
- Mono appeared
- Separate implementation
- Open-source, cross platform
- .NET Core
- Lean, modern .NET
- Open-source, cross platform
- Grew bigger over time
- Back to one .NET
.NET Standard
One
.NET
.NET Unification Vision
Cloud Readiness
- Protocols and APIs
- Packaging and Runtimes
- Efficiency
- Startup Performance
- Productivity
Protocols and APIs
Yet Additional JSON APIs??
- Support for streaming through IAsyncEnumerable 🔗
- Significant performance improvement in some scenarios
- JSON Writeable DOM API 🔗
- For scenarios in which POCOs are not an option
- Data structures not known at runtime
- Potential for perf optimization
- Deserialize only a subtree of large JSON in POCOs
- Manipulate a subtree without deserializing everything into POCOs
- For scenarios in which POCOs are not an option
Demo
Time!
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UseHttpsRedirection();
app.MapGet("/ping", () => "pong");
app.Run();
C#
const express = require('express')
const app = express()
app.get('/', (req, res) => {
res.send('Hi!')
})
app.listen(3000, () =>
console.log('Server ready'))
😁👍
Node.js
Web API
Language supports framework enhancements
using System;
// In the past, we had to use explicit type for lambdas:
Func<int> f = () => 42;
// Lambdas will have a "natural type" that is compatible with var:
var f2 = () => 42;
// We will be able to call lambdas directly:
Console.WriteLine((() => 42)());
Lambda Improvements
Demo
Time!
Create new minimal Web API
Packaging and Runtimes
Demo
Time!
Efficiency and Performance
https://www.techempower.com/benchmarks/#section=data-r20&hw=cl&test=composite
Performance and efficiency is important
for Microsoft and the .NET community
ReadyToRun File Format
- Goal: Binary file format for better startup performance
- Form of ahead of time compilation (AOT)
- Not full native AOT
- "Run anywhere" code ranging from full JIT to full AOT (flexible)
- Re-JITted after start for better steady-state performance
- Drawbacks
- Larger file sizes
- Specific for target architecture (e.g. Win x64)
- Publish as ReadyToRun 🔗
- In .NET 6: Crossgen2 replaces Crossgen
- CLI (dotnet publish ... -p:PublishReadyToRun=true)
- .csproj (<PublishReadyToRun>true</PublishReadyToRun>)
Demo
Time!
Publish trimmed R2R
Memory Management
- Span<T>, Memory<T>
- Unified programming model over different storage types
- Memory pools (System.Buffers)
- Reduce pressure on GC leads to better performance
Demo
Time!
Startup Performance
https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview
What's a Code Generator?
- Runs during compilation
- Inspects your program (using Roslyn)
- Produces additional files that are compiled together with your app
Why Code Generators?
- Currently:
- Runtime reflection, e.g. ASP.NET Core DI (impacts performance)
- Change IL after compilation ("IL weaving")
- MSBuild tasks
- In the future:
- Analyse code at compile time and generate code
- Similar to Google's Wire DI framework (Go)
- .NET examples: JSON Serialization (new in .NET 6), Logging Source Generation (new in .NET 6), ASP.NET Core Razor (new in .NET 6), MvvmGen (community)
- Less reflection leads to...
- ...better performance
- ...smaller apps because AoT compiler (linker) can remove unused parts of your code
- Analyse code at compile time and generate code
Demo
Time!
Does the language even matter?
Feature-Rich Language
- Express intention clearly and concisely
- Code is easy to maintain (read, understand, write)
Ensure high developer productivity
Demo
Time!
billion-dollar mistake.
I call it the
It was the invention of the null reference in 1965.
Tony Hoare
Demo
Time!
Nullable References
https://inf.news/en/fitness/6d35995b75d4c418e8ab2b172f2f3d83.html
.NET
C# and .NET - Past, Present, Future
C# and .NET - Past, Present, Future
By Rainer Stropek
C# and .NET - Past, Present, Future
- 672