Performance improvements in .NET6

I’m pretty psyched about the upcoming .NET6 release. I’ve already touched on ASP.NET 6 Minimal APIs. Continuing on the long-established tradition, the team has also worked hard on the performance side of things. File IO, for example, is seeing impressive gains: For .NET 6, we have made FileStream much faster and more reliable, thanks to an almost entire re-write. For same cases, the async implementation is now a few times faster! »

How to read Windows-1252 encoded files with .NETCore and .NET5+

Another day, another lesson learned: modern .NET does not support the Windows-1252 encoding out of the box. Today my colleague was happily porting a legacy NET4+ app to NET6. As usual, the port was super-easy; it would compile and run just fine, so he was surprised when the app crashed reading a few specific XML files. That’s when I was called in. A closer inspection revealed a pattern: all those crashing files were Windows 1252-encoded (the rest, a vast majority, were UTF-8. »

On GitHub Copilot

Like everyone else on the planet, I’ve been following GitHub Copilot since its launch. It is an impressive achievement and a remarkable milestone for the deep learning industry, that’s for sure. We are obviously at the early stages in deep learning applied to software development, and it is somewhat unsettling to ponder what the future might hold in this field. Like many others, however, I worry about code quality issues and the risk of license infringements1. »

Will .NET 6 Minimal APIs turn heads?

I am pretty excited about the Minimal APIs feature that is coming with .NET 6. Three lines of code will be enough to build a fully functional REST microservice1: var app = WebApplication.Create(args); app.MapGet("/", () => "Hello World!"); await app.RunAsync(); If you’re a seasoned ASP.NET MVC/WebApi developer, the snippet caught your attention because, pre-.NET 6, achieving the same result will have you messing with a lot of extra cruft2. I suspect, however, that this feature is not primarily targeted at existing . »

Custom default values for not existing dictionary items (and a lesson learned)

When dealing with dictionaries, a typical problem is when an operation attempts to retrieve an element using a key that does not exist in the dictionary. In .NET, a KeyNotFoundException is raised, and that’s the desired behaviour in most circumstances. Sometimes, however, you know that your program will frequently try to retrieve keys that do not exist. In such cases, it is more efficient to use the TryGetValue method: This method returns the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter is returned (source) »

On Programming and Writing

My brilliant friend Salvatore Sanfilippo (otherwise known as antirez of Redis fame) has an interesting write-up on his website. How similar is programming to prose writing? After getting his own feet wet with novel writing, he is convinced that the two activities share many common traits. One year ago I paused my programming life and started writing a novel, with the illusion that my new activity was deeply different than the previous one. »

Flask 2.0

Flask 2.0 has just been released. Along with it come many other major satellite releases: Werkzeug 2.0, Jinja 3.0, Click 8.0, ItsDangerous 2.0, and MarkupSafe 2.0. Across all projects, Python 3.6+ is now required, and comprehensive type annotations are supported. At a glance, I’d say that the biggest news is async views in Flask 2. Work has also been done around Werkzeug Request and Response classes to allow for better sync and async in the future (it’s not a public API yet. »

dotnet SmtpClient should not be used

I am very late to the party, but today I learned that the good old dotnet SmptClient is considered obsolete and should not be used. Quoting the documentation: We don’t recommend using the SmtpClient class for new development because SmtpClient doesn’t support many modern protocols. Use MailKit or other libraries instead. (source) Interestingly, Microsoft is recommending a third-party open-source library as an alternative. I hope we’ll see more of that in the future. »

School assignments that count: simulating the COVID outbreak with the C language

Giulia got an exciting assignment from her teacher: Write a C program that simulates (a simplified version of) COVID outbreak spreading across a population of 200 people. When a healthy person comes into contact with a sick person, the healthy person becomes ill, too. After some time, a sick person will recover. A recovered person cannot infect a healthy person nor become sick again after coming in contact with a sick person. »

Get better at programming by learning how things work

When we talk about getting better at programming, we often talk about testing, writing reusable code, design patterns, and readability. All of those things are important. But in this blog post, I want to talk about a different way to get better at programming: learning how the systems you’re using work! This is the main way I approach getting better at programming. Once again, Julia Evans has great sensible advice up on her site. »

Write libraries, not services? Not so fast

Write libraries instead of services is an interesting article I read a while ago. I cannot get it off my head. In an attempt to clear up my mind, I decided to sit down and write about it. I have been writing libraries for a good part of my life. Most of my earlier dev-work resides on thousands of computers in the form of libraries. More recently, I have been writing and deploying remote services. »

Semantic Versioning Will Not Save You

The always brilliant Hynek recently posted Semantic Versioning Will Not Save You. Primarily targeted at consumers of SemVer-versioned packages, it is full of insightful advice. From my perspective as an open-source maintainer, I can tell you that versioning is hard. Judging when a new release is going to break backward compatibility is not as simple as it might seem on the surface, and Hynek does a great job explaining why. Sometimes it is also hard for me to tell if a change in a codebase classifies as a new feature, small improvement, or fix—subtle differences. »

Reverse engineering an obfuscated codebase and fixing it in the process

Today’s mandatory reading is How I cut GTA Online loading times by 70%. As someone who’s been fighting the protection/obfuscation cat & mouse game for twenty+ years, let me tell you one thing. The way this guy reverse-engineered parts of the GTA5 codebase and then proceeded to single-handly triage and fix a long-standing (7+ years) performance issue is simply mindblowing. All he had to work with were heavily obfuscated dlls. This also shows how we, the protectors, are always playing a losing game. »

Musings on Python's Pattern Matching

Pattern Matching is coming to Python, and I am not sure I like it. Don’t get me wrong, I love pattern matching. I use it all the time in F#. I am sure that once it lands in the language, it will be wildly adopted. So what’s the problem with Python’s pattern matching? The community, some core developers included, has expressed several concerns. The Python Steering Council has acknowledged them and is willing to look into improvements should they be proposed. »

What I listen to while programming

What music do you listen to while programming?1 For me, it’s usually jazz, classical, electronic, lots of it, or nothing. There are some specialized websites and podcasts I sometimes recur to, like Music for Programming. Several Spotify playlists I dig a lot, Every Day I’m Nerdin’ being one of them. What can I say? I am musically omnivore. However, I recently discovered something different: the Field Recordings podcast. “A podcast where audio-makers stand silently in fields (or things that could be broadly interpreted as fields). »

When Homebrew breaks your Python virtual environment

Ever had your old, trusty Python virtual environment fail on you? I sure did. Sometimes, when I activate or switch between virtual environments, I get the following error: $ workon eve dyld: Library not loaded: @executable_path/../.Python I never really took the time to look into it. When this happens, because I am in a rush (and because I am a lazy old fart), I shrug it off, recreate the virtual environment on the spot, and get back to work. »

Strong opinions on software development

After six years in the field, Chris has shared his strong opinions on software development practices, languages, and methodologies. I like his attitude. Willingness to continuously put one’s personal views under scrutiny, eventually adapting or even changing them as needed, is not a common trait. Not in our field. While I generally agree with most of his opinions, I feel the urge to comment on a few of them. Typed languages are better when you’re working on a team of people with various experience levels »

The unreasonable effectiveness of simple HTML

We’ve seen other articles pointing the finger at unnecessarily bloated websites. Terence Eden’s On the unreasonable effectiveness of simple HTML deserves mention, I think, for two reasons. First, the delivery is incredibly effective. Second, it is effective because of the storytelling. By enveloping the message into an original short, touching story, he achieves two goals. First, he captures the reader’s attention; second, he makes the experience memorable. Please, go and read it; I’ll wait here. »

On the short, tormented life of Phil Katz

Bless the Internet Archive and its Wayback Machine. With it, we can go back in time and read The short, tormented life of computer genius Phil Katz, an unusually detailed and accurate article published in the April 14, 2000 issue of the Milwaukee Journal Sentinel. When he was found dead April 14, Phil Katz was slumped against a nightstand in a south side hotel, cradling an empty bottle of peppermint schnapps. »

The Obligation of The Programmer

Robert C.Martin, of Clean Code fame, has something to say on the role of we programmers in today’s society. We rule the world. We don’t quite understand this yet. More importantly, the world doesn’t quite understand it yet. Our civilization doesn’t quite realize how dependent it has become on software — on us. He goes as far as suggesting a programmer’s code of conduct of sorts. Food for thought I guess, although I suspect we’re too much of a wild and scattered bunch for something like that to really stick. »