Today is the last day of April which is also turned out to be a Friday, and, what is always nice to have before weekend? – something to read! 😊 So, here is a new issue of .NET R&D Digest, just for that!
This issue contains bits of computer science, operating systems, security, performance, diagnostics, CSS, .NET and interesting tools to explore.
Enjoy and have a great weekend!
- Artificial Intelligence—The Revolution Hasn’t Happened Yet (by Michael I. Jordan)
Artificial Intelligence is a popular topic which pops up in different areas of our life. But what does AI really mean? Is it about imitating human intelligence or it is about algorithms and statistics? In this paper Michael I. Jordan reasons about what is really understood by the umbrella term “AI”, how it is related to machine learning or imitation of human senses (vision, pattern recognition) and what all of this really means for society? A breakthrough or a beginning of a new engineering discipline?
- Why mmap is faster than system calls (by Alexandra Fedorova)
Reading the title you may guess that this post is about Linux and you will be right. However, .NET is not about only Windows, so it is time to start learning something about Linux too 🙂 In this post Alexandra Fedorova explains and demonstrates why usage of mmap to read and manipulate file data can be significantly faster than using system calls. Besides the experimental results and detailed explanation, the post also includes a theory, which is applicable for both Windows and Linux, about how system calls are implemented in operating systems.
P.S. There is an API in .NET – MemoryMappedFile which seems to use mmap underneath 🙂
- Blinking LEDs with Raspberry Pi (by Rich Lander)
When it comes to controlling hardware it is natural to think that control code has to be written in C/C++ language. However, things change and currently it is possible to control your hardware using .NET and C#. In this post Rich Lander shares his experience in using .NET to control LEDs with Raspberry Pi platform. The post is very detailed and includes breadboard schemas, links to hardware components (and where to buy them), links to code samples (and dotnet/iot repository which by itself contains 101 IoT tutorials), pictures and videos of the achieved results.
- Why Exceptions should be Exceptional (by Matt Warren)
Exceptions are an essential part of .NET. However, from time to time I still see discussions where throwing an exception is compared to returning a status code (in favor of the later of course). But does throwing an exception is really so slow? In this post (from 2016! But some things don’t change with time) Matt Warren performs a series of benchmark to measure the cost of throwing an exception and retrieving exception information from it. The post also contains various links where you can read more about how exceptions are handled, processed and what is especially useful when they should and shouldn’t be thrown.
- Managed Memory Dump Analyzers (by Mark Downie)
Application diagnostics requires certain skills and knowledge, which can take years to acquire. However, as it happens all the time in history (which repeats itself) common applications issues are… common and in theory, their detection can be automated. This is exactly what Mark Downie describes in this post. He introduces a new set of .NET Memory Analyzers designed specifically to identify (currently, just a few) common application issues right from a memory dump (without WinDbg). This set of analyzers is just a beginning and in futures there is a chance there will be much more of them, ready to solve most common problems in minutes rather than hours.
- C# 9 top-level programs and target-typed expressions (by Tom Deseyn)
Language features are designed to simplify things, remove unnecessary boilerplate and to provide developers a way to express application logic in a more elegant way. However, with each release number of features grows and it becomes difficult to use all the latest and greatest, because well, it takes time to adopt. In this series Tom Deseyn walks through features introduced in C# 9 and describes what they do and how you might use them, a good way to revise what you already know or learn something new. Besides having a series about C# 9 last year Tom also wrote a series about C# 8 which is also worth checking.
- How to Post a File to an Azure Function in 3 Minutes (by Bryan Soltis)
How simple is to write a code that accepts a file? This doesn’t sound hard and if you give yourself a few minutes you will come up with a few ways of doing it. But what if you have to do it… quickly? 🙂 In this post Bryan Soltis demonstrates how you can write an Azure Function which accepts the file in less than three minutes! A nice example of how you can leverage Cloud, SDK and modern frameworks to quickly accomplish a task.
- Viewing app configuration using Oakton’s Describe command and Spectre.Console and Viewing overwritten configuration values in ASP.NET Core (by Andrew Lock)
Knowing application configuration is an important feature. In case of web applications, it is common to have a protected endpoint which can print it. But what if we don’t want to have an endpoint and still want a simple way to view it? In this post Andrew Lock demonstrates how using Oakton and Spectre.console you can extend your .NET application to react on additional commands (from command line) and print beautiful configuration tree (with or without) overridden values and source.
- Minimalistic C# APIs with FeatherHttp (by Tobias Fenster)
How small ASP.NET Core application can be? And I am not talking about binaries size but about lines of code. With introduction of top-level programs we already saw how small apps can be. However in this post Tobias Fenster demonstrates how, using FeatherHTTP framework you can write an ASP.NET Core app in eleven lines of code 🙂 Besides the impressive demonstration, the post also includes links to resources you can use to give FeatherHTTP a try.
- Say Hello To CSS Container Queries (by Ahmad Shadeed)
Responsive UI relies on a knowledge of device viewport size. Using it we can adjusts how a page will look like on a device. However, when it comes to components, not pages. It is hard to write a component which can correctly adjust itself because… well it has now knowledge about its container, only assumptions. In this post Ahmad Shadeed describes a new container queries feature (still experimental but accessible in Chrome) which allows us to write CSS based on the container’s size rather viewport’s size. Beside the theory post also includes examples to demonstrate what will become possible when this feature becomes general available.
- Performance analysis and tuning on modern CPUs (by Denis Bakhvalov)
Performance analysis is hard. From one side it is because we as developers (especially as .NET developers) are taught to abstract from underlying hardware leaving it to JIT. However, when it comes to performance – you can’t abstract from the hardware completely. That is why it is important to understand at least basics of how hardware works. But understanding of the hardware isn’t the only obstacle which makes performance analysis hard – it is also hard because there is no guide of what to do in particular situation. That is why it is important to know how you can approach performance problems and find why causes them. In this free eBook Denis Bakhvalov describes approaches of how to analyze application performance (ex. Roofline, TMA – Top-down Microarchitecture Analysis); software and hardware instruments and mechanisms (ex. LBR – Last Branch Record, PEBS – Processor Event-Based Sampling, PT – Processor Traces); core CPU elements, how they work and how they affect code execution (ex. Caches, TLB – Translation Look-aside Buffer) and so on and so forth. All of the above is described in both single-threaded and multi-threaded context. Beside the information itself the book is full of code samples, measurement results, illustrations and links to books and papers where you can read more, or study mentioned topics in more details. This book is a very good starting point for developers who want to understand more about application performance, and it is also can be used as a handbook to know what you can try to investigate performance issues.
- LiveReloadServer – A Generic Static Web Server with Live Reload based on .NET (by Rick Strahl)
Static web sites are great. They are simple and require almost no compute resources (and there save money on hosting). However, despite they are “static”, sometimes there is need for simple and small dynamics, which isn’t easy to achieve without special tooling. In this post Rick Strahl introduce a LiveReloadServer tool, which is a small local Web Server that you can start in any folder to provide simple and quick HTTP access to HTML, CSS, JS, Razor Pages (without code behind) and Markdown (with live reload i.e. when you change a source, the page is automatically refreshed). The tool is distributed in both binary and dotnet-tool form, so it is easy to install and use.
- Up for grabs
Did you ever had a though about contributing to open-source project? I bet many of us have. However, when it comes to action it can be hard to find issues or even repositories where you can help without spending a lifetime studying the code. Here is where “Up for grabs” comes into play. It is a platform where you can easily find repositories with issues marked as “up for grabs” or “help wanted” (issues which shouldn’t exceed a few nights of work) and contribute!
Watch and Learn
- Introduction to Vault (by Armon Dadgar)
Please, don’t be confused by the video title. Despite that this video is indeed about HashiCorp Vault it also about secret management. In this video Armon Dadgar describes the reasons what is a secret, what does it mean to manage secrets and why secret management is important in general. It is a nice introduction to the secret management topic and as a bonus – you will learn a bit about how Vault’s design 🙂
- .NET Memory Quiz (by Konrad Kokosa)
How well do you understand memory management in .NET? This isn’t a simple question and it is hard to give a singular answer to it just because memory management is a huge topic. However, there is a way to test yourself – I introduce you a .NET memory quiz by Konrad Kokosa a famous author of Pro .NET Memory Management book. Have fun and share your results!