https://xkcd.com/1312/

A lesson from open source software

I've always tried to contribute to open source software whenever I've seen the opportunity, but becoming a maintainer of an open source library gave me some completely new perspectives.

I've used Emacs for almost a decade, and I used Vim before that. Maybe the fact that vi key bindings are just another package in Emacs, called Evil, was one of the reasons I switched to Emacs. I like modal editing, but I don't use Evil. Instead, I use God mode with Emacs key bindings.

At some point, I discovered Doom Emacs, which packed a lot of functionality that interested me compared to other Emacs distributions.

Continue reading →

Can extension methods solve the expression problem?

Let's explore how extension methods in C# can solve the expression problem. For an introduction to the expression problem, take a look at my first post in this series. Extension methods are essentially used to define operations over a given type without modifying the original definition of the type.

First, we define IExpr as a marker interface and implement it in the Const and Add types. The implementation of Const and Add here is identical to that in the previous post.

public interface IExpr { }

public class Const : IExpr
{
    public double Value { get; }

    public Const(double value) =>
        Value = value;
}

public class Add : IExpr
{
    public IExpr Left { get; }
    public IExpr Right { get; }

    public Add(IExpr left, IExpr right) =>
        (Left, Right) = (left, right);
}
Continue reading →

Can partial classes solve the expression problem?

Programmers are always defining types and operations to use these types. It's the essence of developing features in working software. The expression problem[1] asks how easy it is to define types and operations in a given programming language or paradigm, and is stated as follows:

"The goal is to define a datatype by cases, where one can add new cases to the datatype and new functions over the datatype, without recompiling existing code, and while retaining static type safety (e.g., no casts)."

Continue reading →

LINQ Is Not Quick

Let me just say that I am not particularly a fan of either microbenchmarks or premature optimization. I also feel that LINQ extensions are a fine addition to the .NET standard library. The LINQ query syntax is also an integral part of the C# and F# languages.

That being said, there's an interesting and revealing tale to be told about the performance of LINQ to Objects.

Continue reading →