Home
Blog
Recent Posts 4
Updated
Dot Net Perls

This Is My Favorite C# Article

Probably my favorite C# article on this site has been the C# List article. The List generic type is extremely useful: it can help in many programs. And it has been one of the most popular articles as well over the lifetime of Dot Net Perls.

The article has been updated many, many times, but some memories come to mind:

It used to have a dinosaur picture on the top at one point, which made it recognizable—I can't remember why I removed the picture, other than I was just tired of it.
Even earlier, it had some green rectangle images on it to illustrate elements.
It was one of the top articles, and still is, in terms of how many people arrive on it from search engines, although this has dropped significantly.
It has been, and continues to be, one of the longest articles on the site.

Even if it may not be the hottest new thing on the Internet these days, I think the C# List article is still my favorite piece of writing on this site. It has helped many developers figure things out in their own programs over the years.

Revisiting RSS Feeds

Some years ago it seemed like RSS feeds were the future of web publishing. Each site would have an RSS feed, and users would read articles each day from their favorite sites as the RSS feeds were updated.

But something happened. RSS feed support was removed from web browsers, and RSS feed readers were discontinued. It seemed like RSS feeds were just a relic of the past. But with the rise of AI-generated text, I wonder: could RSS feeds that are written by humans become a way to avoid AI-generated text in search engines?

These days, if you want to read AI-generated text, you have many options—it is everywhere. It may be difficult to find human-written text content in the oncoming flood of AI slop.

I added an RSS feed to this site, for the first time in years. I even validated that it is a correctly-formatted XML file. I downloaded a feed reader and it works correctly on the new RSS file—perhaps RSS feeds can make a comeback and provide a way for readers to avoid AI-generated text.

Reasons to Add a Benchmark Command

Usually when a program becomes big and complex enough (and important enough) it has some features that are slow. If left alone, the slowness will often become annoying. One thing I like to do in console programs is provide a hidden benchmark option.

When writing articles, I make many spelling errors so I have a spelling checker. Because of the quantity of text it must process, the spell-checker must be optimized. By providing a benchmark command, which causes the program to repeat the spell-checking many times, I can make sure the speller is kept in good condition.

Here are some benefits of using a hidden benchmark option:

The benchmark code can stay in place, and it can be safely ignored during normal use.
The benchmark is technically a micro-benchmark, but it is run within another program so it has more normal memory use.
When I am bored, I can run the benchmark and see if anything needs fixing.

Programs often last for many years, if they are useful. Even though a hidden benchmark command is still a micro-benchmark, which causes distortions in the results, it is still worth doing as it can highlight any regressions and give some motivation.

This Is My Favorite C# Feature

I have been writing about C# code for many years, and it has been a popular subject among developers. The language has kept becoming larger and more complicated with each release, but one feature from many years ago is still my favorite.

The word LINQ stands for Language Integrated Query. Think of database (SQL) queries, and how you can find (select), sort and filter or even join together results from a database. With LINQ, we can do this inside the C# language itself, on object collections like Lists.

With some syntax additions to the language, we can:

Use "from" to have a query similar to a natural language question.
Use "order by" to sort the results.
Use "select" to specify how we want to have the results arranged.

With queries similar to natural language, we can say "from this list, order items alphabetically and select items with this matching condition." In no other language have I found the same built-in quality of queries as in C#. While I might not love other aspects of C#, LINQ (System.Linq) is my favorite.

C# Language Updates

Over the years the C# language has been updated many times, and each time the syntax seems to become more complex. It has adapted features from newer languages, and it has multiple ways to use a switch statement, access elements in Lists, define methods, and more.

I can see why the language is updated by Microsoft—it would become obsolete otherwise. Developers would want to use more modern languages (like Rust) that have the newer features. But the problem with a language that is updated so many times is that it ends up being unrecognizable.

On each release, C# gains new features but these features were not part of its initial design:

C# has contextual keywords that only act as keywords in some places, to not break older programs.
It has a traditional switch statement, but also a switch expression that returns values (and has different syntax).
It allows us to create and initialize a List in many ways—basically any syntax is supported.

In my experience, most developers do not use many of the new features. Despite this, C# ends up becoming more complicated and difficult to use. If you have to learn so much new language syntax, why not just learn a language that was designed with modern features from the start? The language from .NET 4 makes more sense than what it has turned into in 2025.

Rsync and Static Website

Suppose you are making a website and want to have a static site generator. This is great for performance, but it means you need a way to deploy the files to a remote server. Rsync, a command-line tool, is ideal for this.

Over the years I have used various graphical FTP programs to deploy a statically-generated website, but rsync is faster and more reliable (and also free). Basically with rsync, one types in "rsync" and then the "from" directory (the local folder) and the "to" directory (the remote folder on a server).

With command-line flags it can support SSH so that it can perform a secure update of the website. Then, once the files are deployed, the remote web server (like Caddy or NGINX) will automatically serve the new files. While the exact usage of rsync is out of the scope of this post, it is available in WSL (Windows Subsystem for Linux) and macOS.

Caddy Web Server

A lot of the times when I try out new software I am disappointed. It is hard to configure, it is too slow, or it is not an improvement over what I had before. But when I tested the Caddy web server, written in Go, I was pleasantly surprised.

Caddy is not exactly new software, as it has been around for a few years. With help from the official Caddy documentation, I was up and running on a test server within half an hour. I switched the live website to Caddy and there were no problems.

Caddy has some big advantages over other software like NGINX:

It supports HTTP3 by default, which gives a nice performance boost to site visitors.
It automatically gets an SSL certificate for the site—this eases the maintenance burden of running a modern web site.
It has other features, like built-in Zstd support, which can make a website faster and easier to develop.

I had an issue with the site, but it turned out to be a Linux server misconfiguration problem. I needed to enable swap pages so the server would not run out of memory. Caddy was never at fault, and it performed admirably given the broken system it was running on.

Sharing More Code

Probably my favorite thing about programming is making a program better. It is a process of constant improvement. Getting a new program to work for the first time is exciting, but perhaps even more fun is sharing more code within a program.

Recently I had two features in a program, and they both had the same basic concept behind them—generate output files from source files. I realized that the two features could share a lot of the underlying infrastructure. Code reuse has many benefits in programming:

It reduces program size.
It uses more well-tested code that already exists (as from a framework like .NET or a crate in Rust).
It has a lower maintenance burden, as the existing code is already being maintained.

As for my program, by rewriting one feature to use existing code from another, I reduced code size from 1000 to 300 lines of Rust code. Having to maintain code is not necessarily a bad thing, but having less to maintain is easier.

WebP Images

The images on Dot Net Perls have been part of its success over the years. Images bring light and color to otherwise boring blocks of text. Unfortunately images require many times more bytes than text. With JPEG, PNG, and WebP we can compress these images.

I have found WebP to deliver a good compression ratio, good visual output, and to be easy to use a developer. In a Rust program, encoding to WebP can be done with some popular crates. The encoding happens entirely within the same process, and is very fast.

WebP has several advantages over other image formats like JPEG:

It has better compression ratios, meaning smaller file sizes.
Most programs that display WebP images are using the same exact code, resulting in fewer compatibility problems.
It can be used by developers as a library with minimal complications.

A problem with WebP is that its library is written in not written in a safe programming language. If it was written in Rust (or something similar) we would have fewer security problems. But overall, WebP has been beneficial to web sites that use it.

Zed Editor

Every programmer uses some kind of text editor. This means the editor can make a big difference to the experience of programming—it can make it easier or more frustrating. Over the past several months I have tested the Zed editor, a new Rust-based editor that uses the GPU for rendering performance.

Zed starts up quickly, and it supports the features I need to write code. When scrolling through files, its rendering performance (which is run on the GPU) is apparent. When compared to Visual Studio Code, Zed is notably faster for these tasks.

It has many features that help make a programmer's life easier:

It supports code auto-completion and displays compilation errors.
It has a nice assortment of built-in themes that can be chosen from a menu.
Probably most important, it has excellent all-around performance.

Overall, I have enjoyed using Zed editor. I sometimes dream of a world where all software is written in Rust (or a similar language) and has graphics acceleration. Even with just a text editor, Zed's improvements to typical software are evident. I imagine we will hear more about this program as it becomes more widely-known.

More
Dot Net Perls is a collection of pages with code examples, which are updated to stay current. Programming is an art, and it can be learned from examples.
Donate to this site to help offset the costs of running the server. Sites like this will cease to exist if there is no financial support for them.
Sam Allen is passionate about computer languages, and he maintains 100% of the material available on this website. He hopes it makes the world a nicer place.
An RSS feed is available for this blog.
Home
Changes
© 2007-2025 Sam Allen