Best of Nick ChapsasApril 2025

  1. 1
    Video
    Avatar of nickchapsasNick Chapsas·1y

    The "in" keyword in C# is Awesome

    The 'in' keyword in C# allows structs to be passed by reference while making them read-only within the method for performance optimization. This avoids costly copying of large structs. However, if the struct isn't marked as readonly, hidden defensive copies may occur, reducing performance benefits. Combining 'in' with 'readonly struct' or read-only members maximizes performance gains.

  2. 2
    Video
    Avatar of nickchapsasNick Chapsas·1y

    The New Extension Members of C# are INSANE

    Nick introduces a new feature in .NET called extension members, which allows developers to add instance and static members to types using the new 'extension' keyword. This feature enhances existing extension methods by enabling extension properties and extending functionality without being limited to static methods. Nick demonstrates how to implement and use these new features through various examples and discusses the potential impact on how developers write C# code.

  3. 3
    Video
    Avatar of nickchapsasNick Chapsas·1y

    Don't use async void in C#

    Async void methods in C# should generally be avoided because they can't be properly awaited, leading to issues with error handling and control flow. The only appropriate use of async void is in event handlers, where tasks are not returned.

  4. 4
    Video
    Avatar of nickchapsasNick Chapsas·1y

    The LINQ trap in .NET

    Understanding the deferred execution in LINQ is crucial as it can cause unexpected data changes in .NET. LINQ methods like where, select, and take build a query rather than executing immediately. This allows adding conditions dynamically, but beware of data changes before execution, as they will reflect in the results. Knowing these rules makes LINQ a powerful tool.

  5. 5
    Video
    Avatar of nickchapsasNick Chapsas·1y

    C# is NOT Java Done Right. Hear me out.

    Nick, a C# developer, reacts to Forest Knight's video claiming C# is Java done right. He discusses the merits and drawbacks of C#, Java, and Kotlin, highlighting features such as memory optimization, properties, exceptions, and async programming. Nick ultimately considers Kotlin as Java done right and emphasizes that despite advancements in languages, job availability remains crucial when choosing a language for development.

  6. 6
    Video
    Avatar of nickchapsasNick Chapsas·1y

    ArrayPool in .NET is insanely fast

    ArrayPool.Shared allows you to rent and reuse arrays to skip garbage collection, perfect for high-performance scenarios like JSON parsing, file I/O, or handling thousands of requests per second. Always return the array to the pool when done, and clear it if it contains sensitive data.

  7. 7
    Video
    Avatar of nickchapsasNick Chapsas·1y

    ref structs in C# are INSANE!

    Ref structs in C# are special kinds of structs that must remain on the stack, making them incredibly fast and safe for high-performance scenarios. They allow for high-speed memory access and manipulation without allocations but come with strict rules such as not being boxable, not usable in async methods, and not storable on the heap.