3 days Ago
Angular 19 sounds … complicated?
Published by marco on
Some of the features described in the video below sound pretty interesting but they also sounds super-complicated, with deferred-loading, hydration, signals, and event/replay all combined with decisions about whether something loads on the client or the server or whether it’s initially built on the server but then enhanced on the client and then run independently from the server, …
I understand that a lot of this technology is for optimizing large web sites, but It’s honestly questionable... [More]
Using calc-size
in CSS
Published by marco on
The following video shows not only when and how to use calc-size()
, it also mixes in advice on generating timing functions for animations, sprinkles CSS variables throughout, and even uses overflow: clip
combined with an absolutely positioned element to reveal more content without disturbing the layout.
The syntax for calc-size()
is, as Kevin says, “weird”; you have to pass two parameters: the first is the name of the logical size you’d like to use, while the second parameter is a formula that... [More]
How to apply EF migrations
Published by marco on
The picture and title are, as usual, clickbait-y, because apparently people don’t click on videos that sound educational unless you promise them ground-breaking learnings. Still, I don’t hate the player; I hate the game. But it’s the world we have.
The video is quite informative and is 90% not the guy pictured. Instead, it’s another guy called Gui Ferrera, who is quite competent.
He starts by explaining how to deploy migrations in production—you don’t just run them, as you would in... [More]
3 weeks Ago
Are you doing the Advent of Code?
Published by marco on
No. No, I’m not.
I was briefly considering it because two good programmer friends[1] of mine asked me, and it seemed like it might be kind of fun to compare our solutions.
But … 24 days, man.
I’ve got other things to do. Like, a lot of other things to do.
I am not in any way bored or looking for things to do.
I’m not even lacking in programming projects that I could be working on.
I’m teaching a JavaScript class right now, for which I’m constantly refining the examples and project code,... [More]
Real quick on MVVM
Published by marco on
A little while back, someone wrote I can’t wrap my head around MVVM (Reddit), asking for help. I answered with a short example, reproduced below.
tl;dr: Use the MVVM Toolkit and try JetBrains ReSharper or Rider for more IDE assistance for binding and fixing up views.[1]
The concept is that:
- the (M)odel describes your data in the shape you want to store it, process it, etc.
- a (V)iew describes the elements of the UI.
- a (V)iew(M)odel mediates between these two “shapes”.
Why do we need this? Why not... [More]
Writing elegant code
Published by marco on
I watched this video analyzing a chunk of code, in the hopes of refactoring it.
The original code is the laughably overblown example below.
public List<int> ProcessData(List<int> data)
{
if (data != null)
{
if (data.Count > 0)
{
var processedData = new List<int>();
foreach (var d in data)
{
processedData.Add(d * 2);
}
return processedData;
}
else
{
return new List<int>();
}
}
else
{
return null;
}
}
Nick... [More]
2 months 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.
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.
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.
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.
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.
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
This 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.
The API is quite high-level and robust but it’s so clear how limited the Python... [More]
4 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.
- Completely unsurprisingly, the
params
keyword now also applies toIEnumerable<T>
(as well as many descendants) as well asSpan<T>
andReadOnlySpan<T>
. - 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]
5 months Ago
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]”
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>
to8.0
(however, there are a bunch of cons associated with doing this, as... [More]
6 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]
8 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.
- 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.
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.
Stephen Toub’s the guy who writes the 100+-page release notes on performance. See the following links.
- Performance Improvements in .NET 5 (46 pages)
- Performance Improvements in .NET 6 (109 pages)
- Performance... [More]
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.
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]
9 months Ago
Avoid primary constructors in C# (for now)
Published by marco on
record
instead.The following video discusses the downsides of the current implementation of primary constructors:
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]
10 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]
11 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]”
1 year 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]