Net 9.0 LINQ Performance Improvements

Overall view of LINQ

  • Widely praised as one of .NET’s standout features; many miss it when working in other ecosystems.
  • Two main faces:
    • Method syntax (list.Where(...).Select(...)) – said to be 99% of real-world usage.
    • Query syntax (from x in ... select ...) – seen as niche, sometimes more expressive for complex queries.
  • Key benefits: consistent API across in‑memory collections, databases, and other data sources; strong typing; good standard library design.

Comparisons to other languages

  • Similar functional combinators exist in Java (Streams), Kotlin, Python (itertools), etc., but:
    • Extensibility via C# extension methods and expression trees is seen as uniquely strong.
    • Java streams lack easy custom operators; “Gatherers” are mentioned as a partial remedy.
  • LINQ-to‑SQL / expression-tree-based querying (EF, custom providers) considered hard to match ergonomically in Java, Go, Python, Ruby.
  • Dynamic languages can do more with macros/ASTs, but usually via libraries, not core features.

Expression trees, IQueryable, and ORMs

  • Big conceptual divide:
    • IEnumerable<T> LINQ = in‑memory functional pipelines.
    • IQueryable<T> LINQ = AST capture for translation to SQL or other backends.
  • Implementing a custom IQueryable provider is non-trivial; many use Entity Framework or lightweight ORMs instead.
  • Some argue SQL translation is a “misfeature” causing subtle runtime failures; propose separating DB models from POCOs more strictly.

Power vs. pitfalls

  • Footguns cited:
    • Misunderstanding laziness and when queries execute.
    • Ignoring algorithmic complexity of long chains.
    • Misusing operators like Single() vs First()/FirstOrDefault().
  • Others reply these are learnable, and LINQ code is testable if DB access is separated.

.NET 9 LINQ performance improvements

  • Thread references large official perf writeup; LINQ gains big wins via:
    • ReadOnlySpan-based paths and vectorized implementations.
    • Short-circuit optimizations (OrderBy(...).First()Min(...), etc.).
  • Debate whether 100x–1000x speedups represent “bug fixes” or natural evolution as new runtime facilities (spans, better JIT, ref types) appear.

Broader ecosystem, tooling, and docs

  • .NET/Visual Studio tooling (debugger, edit‑and‑continue, IntelliTrace) are praised as industry-leading.
  • Complaints:
    • Microsoft docs/tutorials seen as verbose, marketing-driven, and poor for first-time learners.
    • NuGet ecosystem lacks centralized, high-quality, uniform docs; XML comments/docfx/Sandcastle considered clunky.

F#, FP, and language evolution

  • LINQ heavily influenced by functional programming; some suggest trying F# for an even better experience.
  • F# viewed as a “playground” for features later adopted by C# (e.g., functional idioms).
  • Desire for first-class discriminated unions and units of measure in C#; interim libraries (e.g., DU-like helpers, functional libraries) used today.
  • Debate over adopting F# directly vs. layering FP libraries on C#, with organizational conservatism cited as a barrier.