Contents

293 Articles
13 Comments

Search

2 weeks Ago

You’re probably doing code reviews incorrectly

Published by marco on

The article Processes and rules make code review less intimidating by Stefan Judis writes,

 Code reviews are, by nature, intimidating. Sometimes even brutal. If you’ve been in the game for long enough, you probably experienced the following: you worked hard on a feature, you’re proud of yourself and open the PR to be praised and land your changes, and then… it rains comments, suggestions and nitpicks. And if it’s really bad, you’re forced to take multiple feedback and clean-up rounds. It sucks.”

Oh, wow.
... [More]

C# vs. TypeScript type-narrowing and coercion

Published by marco on

I was working with a colleague to get the properties that have a particular attribute. The original formulation returned the properties then got the attributes again, plucking the first one off of the list and asserting that it exists to convince the compiler that everything’s OK. We know it exists because otherwise we wouldn’t have returned the property—but the computer doesn’t know that.

Ok, it works but it’s not efficient or elegant. Is there some way to build this so we allocate... [More]

CSS Typography is really good now!

Published by marco on

I not unexpectedly very much enjoyed this somewhat-rambling 59-minute course on controlling font features from CSS. It’s really quite amazing and wonderful what you can do declaratively these days.

CSS Typography Crash Course by Kevin Powell (YouTube)

To begin, Roel Nieskens takes a long look at variable fonts, which can be manipulated via both standard CSS properties, like font-weight, as well as using font-variation-settings, all of which can be animated. Variable fonts support a much more granular range of values for font-weight than... [More]

Delimiting multiple CSS classes

Published by marco on

 While investigating Charts.css, I learned that you can throw unrecognized special characters like square brackets or pipes into CSS class references and its just fine. So you can use them to separate longer lists of classes. For more information, see Cube CSS: grouping by Andy Bell (Piccalilli).

So, you can write:

<article 
class="[ card ] [ section box ] [ bg-base color-primary ]">
</article>

or

<article class="card | section box | bg-base color-primary">
…
</article>

and it works just fine, while being more... [More]

More Stephen Toub: Array Pools

Published by marco on

In this otherwise excellent video, I found myself very much wishing that Toub had written at least a single test for the ArrayPool implementation that he built in this video. Still, check out the selected citation below to get a feeling for how they consider performance implications—there are no easy answers, there is only testing and benchmarking.

Deep .NET: Let's Build Our Own ArrayPool with Stephen Toub and Scott Hanselman by dotnet (YouTube)

At 34:45,

Hanselmann: For folks that may not know what NUMA is: so NUMA is this non-uniform memory access that the computer knows that, like,... [More]”

CSS Magician Roman Komarov plays with sibling-count and sibling-index

Published by marco on

The article Possible Future CSS: Tree-Counting Functions and Random Values by Roman Komarov (Kizu.Dev) is another mathematical master class in using CSS variables and calculations to get at values like “sibling count” and “sibling index”, two values that are in a future proposal for CSS Values and Units Module Level 5 (w3C).

The final demo looks like this, with randomly laid out items squared up into equal columns and rows where possible, all done with only CSS.

 Stacking and squaring up grid items

Here’s a taste of the code for getting a random value in CSS,

... [More]

IAsyncEnumerable for and by dummies

Published by marco on

This isn’t a terrible video on IAsyncEnumerable but it’s also not nearly as high-level and fast-paced as I’m come to expect from the .NET Deep Dive series, which is no-muss/no-fuss with Stephen Toub. Those are much better than this one but, if you’re not grokking what IAsyncEnumerable is good for from the documentation or examples, maybe this one-hour video will help. If you’re lucky, it will make you feel better about your own skills as a programmer.

On .NET Live: Supercharge .NET with IAsyncEnumerables: Efficient Data Streams by dotnet / Chase Aucoin (YouTube)

Maybe I’m just super-smart but I can’t... [More]

A quick look at .NET Aspire

Published by marco on

.NET Aspire is a newly introduced tool for building distributed solutions that run just as easily locally as they do in the cloud. This video explains how this is a boon for integration testing.

End-to-end integration testing with .NET Aspire by dotnet / Aaron Powell (YouTube)

The concept is very nice and seems to greatly simplify building integration tests. Kudos and thanks for the introduction.

 Still, my hair was standing on end with some of the “fast and loose” programming in this video, though. I know that people will argue that you have to take a direct path to get... [More]

Don’t return await unless you have to

Published by marco on

I finally got around to verifying that the defining dependent async methods like the following one is wasteful.

public async Task<bool> N()
{
   return await M();
}

 A less-contrived example looks like this:

using System.Threading.Tasks;
public class C {
    public Task<bool> M() 
    {
        return Task.FromResult(false);
    }
    
    public async Task<bool> N() 
    {
        return await M();
    }
    
    public async void RunIt()
    {
        var result = await N();
    }
}

This... [More]

Manim: a bespoke animation editor and engine

Published by marco on

 Manim − linear transformation in 3dThis is a fun video that demonstrates an API, runtime, and IDE called Manim that lets you interactively build 3-D animations. It’s like a game-engine editor[1] in which you build your scenes by calling APIs in Python. There’s an interactive Python terminal, a rendering area, and a text editor.

It’s quite nicely done and he’s put it to good use over the years, building hundreds, if not thousands, of videos with it.

How I animate 3Blue1Brown | A Manim demo with Ben Sparks by 3Blue1Brown (YouTube)

The API is quite high-level and robust but it’s so clear how limited the Python... [More]

3 months Ago

C# 13 improvements

Published by marco on

The final document of What’s new in C# 13 (Microsoft Learn) is available. There are no major changes for most end users; the changes listed are interested for library and framework developers—especially those interested in writing highly performant code, e.g., Microsoft in its BCL and ASP.NET.

  1. Completely unsurprisingly, the params keyword now also applies to IEnumerable<T> (as well as many descendants) as well as Span<T> and ReadOnlySpan<T>.
  2. There’s now an official Lock object that, when used instead of the... [More]

Wrapping text the hard way

Published by marco on

The work journal 2024-03-27T16:03:51 conversation: 01ht0afgwryks5fepkvvm0kn28 by Simon Willison (GitHub) describes the author’s process of using AI prompting to write a console text-wrapping algorithm.

 He prompted with “JavaScript that takes a big string of text and word wraps it at the specified width, adding newlines where necessary.” The answers meandered around a solution space that seemed over-engineered and not particularly fruitful—the answers all used regular expressions, which seems kind of like overkill, when... [More]

Tactics for automated testing

Published by marco on

The article Prefer test-doubles over mocking frameworks by Steve Dunn writes,

This is testing implementation and not behaviour. Your SUT called something and there is likely an observable side-effect of that. Test the side-effect and not that a particular method was called. If the code is refactored (e.g. you change the implementation but not the behaviour), then your test that checked that a method was called will likely break, but your test that tested the behaviour should remain unchanged and should... [More]”

4 months Ago

Upgrading to nullability in C#

Published by marco on

 The Talk − Bringing C# nullability into existing code by Maarten Balliauw is a 66-slide deck that I summarize as follows:

  • The C# nullability feature is for build- and design-time. It does not enforce anything at runtime. That means that you still have to check parameters for null.
  • The C# nullability feature is available to solutions working with .NET Framework and .NET.
  • For .NET Framework, you have to explicitly set the <LanguageVersion> to 8.0 (however, there are a bunch of cons associated with doing this, as... [More]

5 months Ago

Ignoring files with .gitignore

Published by marco on

Introduction

This article defines concepts like repository and working tree and then discusses how you can use .gitignore files to determine the files and folders that Git considers during operations.

Concepts

 From a command line, you can run git init in any folder to make any folder a Git repository. Doing so creates a .git folder with a database and configuration files for the local repository. Git considers any folder that contains a .git folder with these configuration and database files... [More]

7 months Ago

Building RegEx from scratch with Stephen Toub

Published by marco on

This is another excellent 1-hour tour of another complex corner of .NET. Toub describes and shows how the source-generated RegEx engine works.

Deep Dive into RegEx with Stephen Toub by dotnet / Scott Hanselmann (YouTube)

  • The generated source is human-readable and debuggable.
  • It is well-commented.
  • It updates in real-time as you change the expression.
  • It includes XML documentation that describes the regular expression in plain English.
  • They rewrote the compiler in .NET 7 to not only better support source generators, but also to be able to emit not only IL, but source... [More]

Building async/await from scratch with Stephen Toub

Published by marco on

This is another video from Stephen Toub that is just chock/full of useful information.

Writing async/await from scratch in C# with Stephen Toub by dotnet (YouTube)

At 27:30, they start to discuss about the nomenclature of Task and how it differs from an Action. It’s funny that neither of them mentioned that tasks in .NET are called promises pretty much everywhere else (JavaScript, Java, etc.). Some libraries also use the word future. For more information, see Futures and promises (Wikipedia).

As he’s building everything, it is really astonishing to note that Hanselmann has to... [More]

Building LINQ from scratch with Stephen Toub

Published by marco on

This is a great interview with the master of performance-optimization in .NET Stephen Toub. If you’re relatively well-versed in C#, .NET, and Linq, then you can just jump to the second video (linked below). I actually watched the second one first. I didn’t feel like I’d missed anything.

Deep Dive on LINQ with Stephen Toub by dotnet (YouTube)

Stephen Toub’s the guy who writes the 100+-page release notes on performance. See the following links.

It’s 2024. How’s it going, JavaScript?

Published by marco on

This video is from a great channel, which published a lot of great videos a while back. They covered pretty much everything already, but circled back to JavaScript for 2024.

Interview with Senior JS Developer 2024 by Programmers are also human (YouTube)

Some choice quotes from the video.

“We push on save.”
“2024 is the year of the serverlesslessness.”
“They say that every year, but this year they’re out of VC funding.”
“Don’t write this down, next week all of this is gonna change.”

This guy just keeps knocking it out of the park. Pretty much everything he mentioned... [More]

8 months Ago

Avoid primary constructors in C# (for now)

Published by marco on

tl;dr: avoid C# 12's primary constructors for classes except for very small, simple classes, in which case you should consider using a record instead.

The following video discusses the downsides of the current implementation of primary constructors:

The C# 12 Feature You Shouldn’t Use, Yet by Nick Chapsas (YouTube)

To sum up:

  • Primary constructors don’t have a readonly backing field; you can still assign to it within the type.
  • You can’t control the visibility of the generated property or backing field.
  • You can’t throw exceptions, except in a... [More]

9 months Ago

Fighting with Fowler on Continuous Integration

Published by marco on

 The article Continuous Integration by Martin Fowler makes many interesting points. It is a compendium of know-how about CI by one of the industry heavyweights, who’s been using it for a long time.

While I found a lot of what he had to say interesting, I did wonder how applicable CI is for the kinds of teams that I know and work with. He makes several statements toward that end that pretty severely limit the applicability of what he calls “true CI” for many, if not most, teams.

I think he should have started... [More]

10 months Ago

Web Interop 2024

Published by marco on

The article The web just gets better with Interop 2024 by Jen Simmons (Webkit Blog) writes,

 The Interop project aims to improve interoperability by encouraging browser engine teams to look deeper into specific focus areas. Now, for a third year, Apple, Bocoup, Google, Igalia, Microsoft, and Mozilla pooled our collective expertise and selected a specific subset of automated tests for 2024.

“Some of the technologies chosen have been around for a long time. Other areas are brand new. By selecting some of the highest priority... [More]

11 months Ago

SourceLink and external sources

Published by marco on

I published a very similar version of the following article in the DevOps Wiki at Uster Technologies AG. Since nearly all of that post is general knowledge that I would have been happy to find before I started my investigations, I’m sharing it here.

Overview

When we think about navigating or debugging our code, we usually focus on the code we’ve written ourselves—local sources in our file system. IDEs have classically focused on being able to debug and navigate this code.

More and more,... [More]

Learning how to use GenAI as a programming tool

Published by marco on

 The article Exploring Generative AI by Birgitta Böckeler (MartinFowler.com) is chock-full of helpful tips from eight newsletters totaling 25 pages that she wrote throughout 2023. I include some of my own thoughts, but most of this article consists of citations.

A lot of my analysis and notes boils down to: you need to know what you’re doing to use these tools. They can help you build things that you don’t understand, but it’s not for medium- or long-term solutions. I’ve written a lot more about the need for expertise in How... [More]

1 year Ago

AOT, JIT, and PGO in .NET

Published by marco on

The latest video by Nick Chapsas has a more-than-usually clickbait-y headline. The “big” problem that NativeAOT has, is that it’s 4% slower during runtime than the JIT-compiled version.

NativeAOT in .NET 8 Has One Big Problem by Nick Chapsas (YouTube)

That doesn’t seem like such a big problem to me, when the point of AOT is to improve cold-start times for applications launched on-demand. For that use-case, AOT shines. It’s over 4x faster on startup than the JIT-compiled version. It’s incredibly impressive that JIT-compilation takes less than 1/10 of a... [More]

How to replace “warnings as errors” in your process

Published by marco on

A build started started failing after a commit. However, the errors had nothing to do with the changes in the commit. A little investigation revealed that the cloud agent had started using a newer version of the build tool that included an expanded set of default warnings. These warnings started appearing first on CI because developers hadn’t had the chance to update their tools yet.

The “warnings as errors” setting turned what would have been a build with a few extra warnings into a failing... [More]

PRs suck. Stop trying to fix them.

Published by marco on

I read through the article Your GitHub pull request workflow is slowing everyone down (Graphite.Dev) with great interest because I, too, am not thrilled about how PRs work. While I agree with the problems Graphite see with PRs, I think they miss other problems—and I don’t like their solution very much.

PRs are, apparently, HUGE

“The single most important bottleneck is PR size − large PRs can make code reviews frustrating and ineffective. The average PR on GitHub has 900+ lines of code changes. For speed... [More]”

“Developer experience” is rarely a requirement

Published by marco on

The article Some notes on Local-First Development by Kyle Matthews (Bricolage) focuses on a very good trend in app development, but focuses a bit too much on what he calls DX, or developer experience.

“I see “local-first” as shifting reads and writes to an embedded database in each client via“sync engines” that facilitate data exchange between clients and servers. […] The benefits are multiple:”
  • Simplified state management for developers.
  • Built-in support for real-time sync, offline usage, and multiplayer... [More]

Handling long-running projects

Published by marco on

This is a brilliant interview, in that Oren Eini just talks for about 40 minutes, answering pretty much just one or two questions.

Oren Eini on Building Projects that Endure by Technology and Friends (YouTube)

At one point (I forget where), he says,

“I don’t like unit tests.”

Agreed. I likelove automated tests. They’re indispensable. But I think unit tests are only useful when you want to focus on a failing integration test. David rightly points out that they’re really good for pinpointing where a problem actually happens, but Eini says that they also “hinder change”... [More]

Architecture is about intent

Published by marco on

The following video is a talk by Robert Martin “Uncle Bob”, one of the graybeards worth listening to. This video from 2011 is wide-ranging and contains a lot of brilliant advice. It’s stuff that we’ve known for a long time now, but every generation of programmers needs to re-learn these things about every 5-10 years. You usually can’t stop people from just reinventing the wheel because who wants to watch videos of or read blog posts written by old dudes, ammirite?

Ruby Midwest 2011 − Keynote: Architecture the Lost Years by Robert Martin by Robert C. Martin in 2011 (YouTube)

At 10:00, he talks about... [More]