ProgrammingPro #60: C++ Rises in Tiobe Against All Odds, Mistral launches Codestral AI, Database Mapping, and GitHub's Arm64 runners
Bite-sized actionable content, practical tutorials, and resources for programmers
Welcome to this week’s edition of ProgrammingPro!
In today’s Expert Insight, we bring you an excerpt from the recently published book, Pragmatic Microservices with C# and Azure, which discusses how to map database models using EF Core, focusing on serialization, property mapping, and the use of parameterized constructors.
News Highlights: C++ climbs to second in the Tiobe index despite security advisories; Mistral launches AI code generator Codestral; Docker survey reveals developers' need for better security tools; and GitHub introduces cost-efficient Arm64 runners.
My top 5 picks from today’s learning resources:
But there’s more, so dive right in.
Stay Awesome!
Divya Anne Selvaraj
Editor-in-Chief
PS: Do share your opinions, your feedback on ProgrammingPro, and earn your one Packt credit for the month. Take the survey!
Are you a tech enthusiast, engineer, developer, or IT professional?
We at Packt want to hear from YOU!
We want to learn how technical professionals engage with learning resources and how reading habits are evolving in the era of AI and digital transformation.
Your feedback will help us shape better educational tools and resources for you. The survey is also a great opportunity for you to reflect on your professional learning journey.
🗞️News and Analysis🔎
C++ language rises in Tiobe popularity index: Despite a White House advisory warning against the use of C++ due to memory safety concerns, C++ has risen to second place in the Tiobe index of programming language popularity, with Python leading and C dropping to third. Read for a peek into more language trends.
Django dev survey shows growing use of HTMX, Tailwind CSS, background workers: A survey of 4,000 Django developers conducted by the Django Foundation and JetBrains has revealed increasing adoption of HTMX, Tailwind CSS, and GitHub Actions among Django users. Read for more insights.
Mistral Introduces AI Code Generation Model Codestral: Supporting over 80 languages, Codestral excels in generating code snippets, completing functions, and more, with a 32k context length for detailed solutions. Read to learn more.
Developers are daunted by security tasks, finds Docker survey, and want better tools: The survey, part of Docker's 2024 State of Application Development Report, highlights a shift towards developers addressing security earlier in the development cycle. Read to gain more insights.
GitHub adds Arm64 runners to Actions at last, another advance for Arm: These runners are 37% cheaper than their x64 counterparts and consume 30-40% less power. Read for insights into the strategic shift towards embracing Arm64 architecture in cloud services and development environments.
TypeScript adds support for ECMAScript’s Set methods: This release candidate version also introduces leniencies in regular expression syntax checking, inferred type predicates, and optimizations that quicken build times. Read for more.
Microsoft adds WinUI support to MSTest: Version 3.4 adds support for WinUI in .NET applications and enhances Roslyn-based code analyzers with new rules for best practices. Read to learn about all the enhancements.
🎓Tutorials and Learning Resources💡
Python
50 coding laws that would make you a decent programmer: Outlines a comprehensive set of best practices designed to enhance the skills and methodologies of Python programmers. Read to learn about key programming principles that promote writing more maintainable, readable, and efficient code.
The Elements of Python Style: Offers guidance on writing clean and maintainable Python code, going beyond syntax to discuss paradigms, organization, and architecture. Read to learn about advanced style considerations.
For more Python resources go to PythonPro
C# and .NET
6 security best practices for ASP.NET Core: Best practices discussed include HTTPS enforcement, anti-CSRF measures, and preventing XSS and SQL injection attacks. Read to learn how to safeguard web applications against security threats.
Go-style “alongside” testing in C# and .Net Core: Explains how to configure your C# projects to incorporate tests directly alongside production code. Read to learn how to optimize the development process without affecting release builds.
Lateral Movement with the .NET Profiler: Explains how the method can be used to inject and execute code. Read to learn about advanced .NET Profiler capabilities for red team operations, including code injection and persistence methods.
C and C++
🎓Tutorial | Building, Shipping and Debugging a C++ WebAssembly App: Describes compiling C++ code with Emscripten, linking it with a frontend via Webpack, and the necessary configurations for deploying both as one cohesive app. Read to learn how to develop an app for enhanced computational capabilities.
C++ programmer's guide to undefined behavior - part 1 of 11: Targeted at experienced C++ programmers, this article explores the intricacies and dangers of
undefined behavior. Read for guidance on detection and prevention.
Building and testing C extensions for SQLite with ChatGPT Code Interpreter: Shows how to leverage the interpreter to write, compile, and test the extension entirely within its environment. Read to discover an efficient workflow for integrating complex functions into SQLite.
Java
🎓Tutorial | Evaluate Java expressions with operators: Covers the use of operators to create expressions, highlighting operator types like additive, bitwise, and logical. Read to understand operator precedence and type conversions.
Does Java pass by reference or pass by value?: Java uses pass-by-value for all parameters, including object references. Read to learn the technicalities of Java's pass-by-value system, particularly how it affects mutable and immutable objects.
Optimizing Spring Boot Config Management with ConfigMaps - Environment Variables or Volume Mounts: Highlights the benefits of ConfigMaps in managing application settings outside of container images without needing to rebuild or redeploy applications. Read to learn effective strategies for managing Spring Boot application configurations.
JavaScript and TypeScript
💼Case Study | Balancing Old Tricks with New Feats - AI-Powered Conversion From Enzyme to React Testing Library at Slack: The company has transitioned over 15,000 frontend tests from Enzyme to React Testing Library due to the lack of Enzyme support for React 18. Read to learn about this massive undertaking.
How a Single Vulnerability Can Bring Down the JavaScript Ecosystem: Discusses a significant vulnerability discovered in the npm registry, illustrating the susceptibility of the JavaScript ecosystem to a cache poisoning attack. Read to learn more.
How to Check Which JavaScript Runtime is Running Your Code: Recommends the use of navigator.userAgent for reliable identification. Read to recognize less reliable methods that may lead to inaccuracies.
Go
Putting Go's Context package into context: Provides a detailed look at how the context package functions internally. Read to learn how to use contexts effectively for managing deadlines, cancellations, and values across Go applications.
Error Flows in Go: Critiques common practices and suggests providing context for errors to enhance debugging and application reliability. Read to learn how to enhance error messages by focusing on the actions preceding errors.
Rust
Effective substring in Rust: Explores various methods of implementing a substring function in Rust, addressing the absence of a built-in substring() method. Read to be able to select the most efficient method for your application.
Making robots plan faster with SIMD and Rust: Discusses enhancing robot motion, focusing on improving collision-checking speed. Read to learn how to leverage SIMD optimizations and advanced data structures.
PHP
Nasty bug with very simple exploit hits PHP just in time for the weekend: A critical PHP vulnerability, identified as CVE-2024-4577, allows trivial remote code execution on Windows devices due to an oversight in handling Unicode to ASCII conversion, specifically exploiting the "Best Fit" feature in Windows. Read for more.
SQL
🎓Tutorial | Pagination for database objects: Discusses efficient pagination techniques for fetching database objects through an API. Read to learn how to overcome the performance limitations of traditional methods.
Ruby
Async Ruby on Rails: Introduces two key principles: deferring tasks that can be delayed (like using deliver_later for emails) and keeping the system active by concurrently processing tasks like HTTP requests or database queries. Read to learn how to ensure faster response times.
Swift
🎓Tutorial | Getting Started with the Static Linux SDK: Outlines how to use the Static Linux SDK with Swift to create fully statically linked executables for Linux, addressing compatibility and dependency issues across different distributions. Read to recognize the differences between static and dynamic linking and more.
Kotlin
Typealiases in Kotlin Explained: Delves into the strategic application of typealiases in Kotlin to improve code readability and maintainability. Read to learn about the pitfalls of misuse that can lead to confusion.
🌟Best Practices and Advice🚀
Q&A: Getting past the hype of AI development tools: In an SD Times interview, Phillip Carter of Honeycomb discusses the nuanced impact of AI development tools on programming. Read to learn how to critically assess AI tools before choosing to integrate them into your workflow.
11 surprising ways developers are using Wasm: The format is revolutionizing how developers work across various applications, from enhancing old video games to facilitating data analysis directly in the browser. Read for insights into Wasm’s potential to handle complex tasks traditionally reserved for native applications.
Software Development Best Practices to Follow in 2024: This guide emphasizes adopting methodologies like Agile, utilizing version control systems, and conducting continuous testing to create high-quality software efficiently. Read to learn more.
An Overview of Data Pipeline Architecture: This architecture facilitates data flow from various sources through stages like ingestion, transformation, and storage, maintaining data integrity and accessibility. Read to learn how the architecture promotes efficiency and strategic decision-making in data-driven environments.
Take the Survey, Get a Packt credit!
🧠 Expert Insight 📚
Here’s an excerpt from “Chapter 3: Writing Data to Relational and NoSQL Databases” in the book, Pragmatic Microservices with C# and Azure by Christian Nagel.
Exploring models for database mapping
When creating services, different models can be used for the database, the functionality, and the APIs. The database layer might have different requirements than the other layers. When creating a monolithic application, this usually is the
case, but it also means that while maintaining the application and adding a field, all the different layers need to be touched and updated. When creating microservices with smaller scopes, there’s a good chance to use the same model with the database, the functionality of the application, and the APIs. This not only reduces maintenance costs but also improves performance in that not every layer creates new instances and copies the values around.
With the sample application, the Game and Move types with their generic counterparts created in the previous chapter are not that simple, but it’s possible to use them directly with EF Core.
Let’s look at the models and what must be mapped for the database, starting with the Game type:
Codebreaker.GameAPIs.Models/Game.cs
public class Game(
Guid id,
string gameType,
string playerName,
DateTime startTime,
int numberCodes,
int maxMoves)
{
public Guid Id { get; private set; } = id;
public string GameType { get; private set; } = gameType;
public string PlayerName { get; private set; } = playerName;
public DateTime StartTime { get; private set; } = startTime;
// code removed for brevity
public required IDictionary<string, IEnumerable<string>> FieldValues
{ get; init; }
public required string[] Codes { get; init; }
public ICollection<Move> Moves { get; } = new List<Move>();
public override string ToString() => $"{Id}:{GameType} -
{StartTime}";
}
The Game class contains properties of type Guid, string, DateTime, TimeSpan, int, and bool. All these properties can easily be mapped to database columns. Just the size of the string needs to be configured. With SQL Server, the convention to map a string is nvarchar(max). This can be reduced in size. What’s more interesting is the constructor.
The class doesn’t define a parameterless constructor. While some tools require a parameterless constructor, both JSON serialization as well as EF Core nowadays don’t need one. EF Core supports constructors with parameters as long as the constructors map to simple properties – which is the case with the Game class. EF Core mapping supports properties with get and set accessors. If there’s just a get accessor available, the mapping will fail. A way around this is to use private fields. EF Core supports explicit mapping to fields. Another option is to use private set accessors – which are used with the Game class.
Some other interesting members are available with the Game class: the FieldValues property is of type IDictionary<string, IEnumerable<string>>. The field values define the possible options the user can choose from. All games of one game type usually have the same field values, but this can change over time. We shouldn’t expect these values to always stay the same. The application might change the colors or shapes to choose from over time. So, we can’t just ignore the property to be stored – this should be stored with the game. As for this type, a default mapping is not available, so we need to add a conversion.
The Codes property is of type string array. EF Core 8.0 supports built-in mapping of collections of primitive types; that is, a list of arrays, integers, strings, and more. With the built-in functionality, the collection is stored in the JSON format in a string table. This fits the purpose. The Codes property contains a list of a solution. With the color-based game types, this is a list of up to five colors; with the shape game type, one string of the collection consists of a shape and a color with a delimiter. Using a version older than EF Core 8, a custom conversion would be required. With EF Core 8, this will map with the default functionality.
The Moves property is typically a relation with relational databases. Using SQL Server, we will use the Moves table to store every move. It would be possible to store moves with a JSON column, but we’ll use a separate table and query for moves if needed. Using a NoSQL database, it’s a natural way to store moves within the game.
Let’s look into the Move type:
Codebreaker.GameAPIs.Models/Move.cs
public class Move(Guid id, int moveNumber)
{
public Guid Id { get; private set; } = id;
public int MoveNumber { get; private set; } = moveNumber;
public required string[] GuessPegs { get; init; }
public required string[] KeyPegs { get; init; }
public override string ToString() => $"{MoveNumber}. " +
$"{string.Join('#',GuessPegs)} : " +
$"{string.Join('#', KeyPegs)}";
}
With the Move class, GuessPegs (the guess of the player for the move) and KeyPegs (the result from the analyzer) can be serialized similarly to the Codes property from the Game type. What’s more interesting here is what’s not here. That is, the absence of a foreign key property like GameId or a direct Game property to establish a relationship between the Move and Game types. While using the Move type so far, this relationship was not required. With EF Core, it’s also not required to add this relationship to the model. EF Core supports a feature named shadow properties. These properties are not part of the model but are stored within the database and can be accessed while using the EF Core context.
Let’s summarize what needs to be done to map the Game and Move types with EF Core:
For simple string properties, the size of the database string needs to be defined with SQL Server.
The FieldValues property of type IDictionary<string, IEnumerable<string>> needs a value converter.
The Moves property maps a collection to the Move type. With a relational database, Move objects should be stored in a separate Moves table. Because the Move type doesn’t define a primary key, shadow properties are needed.
Using Azure Cosmos DB, the moves should be stored in the game JSON document.
Note
EF Core supports mapping via conventions, annotations, and the fluent API. Conventions are provider-specific. For example, a .NET string mapping to nvarchar(max) is a convention. Using nullability, a non-nullable property maps to a required database column, while a nullable property is not required. Conventions are overridden using annotations. Annotations are attributes such as [StringLength(20)], which not only can be used to validate user input but also to specify the column to be nvarchar(20). Using the fluent API, annotations can be overridden. The fluent API offers most options and overrides all the other settings.
Pragmatic Microservices with C# and Azure by Christian Nagel was published in May 2024. You can buy the book here! Packt library subscribers can continue reading the entire book for free here.
🛠️ Useful Tools ⚒️
OpenAI .NET library: an official library created by OpenAI, offering full support for the OpenAI API, including the latest GPT-4o model, and facilitating easier integration with .NET and Azure OpenAI environments.
Restate: an open-source system that offers workflows-as-code with durable execution, providing SDKs in JavaScript, Java, and Kotlin, and a robust, self-contained runtime built in Rust/Tokio.
Genschool: a new educational platform that provides hands-on learning in prompt engineering, offering interactive, real-world scenarios for professionals to develop practical skills.
That’s all for today.
We have an entire range of newsletters with focused content for tech pros. Subscribe to the ones you find the most useful here. Complete ProgrammingPro archives can be found here. Complete PythonPro archives are here.
If your company is interested in reaching an audience of developers, software engineers, and tech decision makers, you may want to advertise with us.
If you have any comments or feedback, take the survey, leave a comment below.



