ProgrammingPro #69: Non-Blocking Java Algorithms, AI's New Coding Champion, C# File Download Simplification, and C++ JSON Optimization
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,
High Performance with Java, which discusses non-blocking algorithms that ensure thread safety without using locking mechanisms.
News Highlights: Cosine's Genie overtakes Devin as the top AI coding tool; OpenAI adds Structured Outputs for JSON, easing structured data generation; Ruby on Rails 7.2 debuts with a new JIT compiler and auto-generated containers; and Java introduces null-restricted and nullable types via JSpecify.
My top 5 picks from today’s learning resources:
How to Simplify Multiple File Downloads into Zip File using C# in ASP .NET Core — A simple guide💾
Harness software intelligence to conquer complexity and drive innovation🧠
But there’s more, so dive right in.
Stay Awesome!
Divya Anne Selvaraj
Editor-in-Chief
PS: This month’s survey is live! Do take the oppotunity to give us your feedback on ProgrammingPro, request specific learning resources, and get your one Packt Credit for the month.
PPS: We are working on a special Swift 🦅 issue that will be hitting your inboxes very shortly. Keep your eyes peeled!👀
🗞️News and Analysis🔎
Move over, Devin - Cosine’s Genie takes the AI coding crown: Genie, trained to mimic human software engineers, can autonomously handle various programming challenges across multiple languages. Read to learn about AI-driven tool standings.
OpenAI adds support for Structured Outputs for JSON in its API: The Structured Outputs enforce model outputs to match JSON Schemas provided by developers. Read to learn how this simplifies the generation of structured data.
20 years since open source release, here comes Ruby on Rails 7.2 with JIT compiler and more: The version introduces Yet Another Just-in-Time compiler (YJIT) enabled by default, auto-generated development containers, and more.
Microsoft says .NET Aspire is for any app, but deployment can be complex: This stack for building distributed applications, can enhance monitoring, reliability, and service discovery for any .NET application, but deployment complexities exist.
Null-Restricted and Nullable Types for Java: The release of the JSpecify project and the introduction of Draft JEP 8303099 aims to bring null-restricted and nullable types to Java, allowing developers to mark whether a type can include null values.
pgEdge introduces advanced logical replication features in v24.7: The release also introduces large object support, and improved error handling. Read to learn how these updates improve PostgreSQL's flexibility, control, and efficiency.
OpenTelemetry Adopts Continuous Profiling; Elastic Donates Their Agent: This move allows developers to identify resource-intensive code and improve app runtime behavior. Read to learn how continuous profiling enhances observability.
🎓Tutorials and Learning Resources💡
Python
Monitoring Windows usage in Python - A Step-by-Step Guide: Guides readers through building a simple monitoring tool with the pywin32 and psutil libraries. Read to learn how to create the tool and expand it with additional features.
For more Python resources go to PythonPro
C# and .NET
🎓Tutorial | How to develop Native AOT applications in .NET: Details making the Docotic.Pdf library AOT-compatible, highlighting steps such as finding and fixing AOT issues, using static analysis tools, and addressing runtime errors.
🎓Tutorial | How to Simplify Multiple File Downloads into Zip File using C# in ASP .NET Core — A simple guide: Walks you through creating a project, adding images, and writing a Download method using a MemoryStream and ZipArchive.
🎓Tutorial | Understanding the Command Design Pattern (C#): Through a bank account example, the article demonstrates how to implement the pattern by creating commands for deposit and withdrawal, and using an invoker for transactions.
C and C++
Reflection-based JSON in C++ at Gigabytes per Second: Explores the potential of C++26's upcoming reflection capabilities for handling JSON serialization and deserialization. Read to learn how JSON processing can be optimized.
Profit and Loss Modeling on GPUs with ISO C++ Language Parallelism: Shows how to achieve high-speed computations on GPUs, making the process more efficient compared to traditional methods. Read to learn through practical examples.
🎓Tutorial | C Program to Implement Circular Linked List: Covers the basic operations of insertion, deletion, traversal, and search, providing code examples for each operation. Read to learn through real-world application examples.
Java
AI-driven Java Performance Testing - Balancing Result Quality with Testing Time: Introduces an AI-based framework for improving the accuracy of warm-up phase estimates. Read to learn how AI can enhance performance testing.
🎓Tutorial | Advanced JShell Usage: Discusses advanced usage of JShell, including how to load external libraries, work with JavaFX, and create executable jar files within JShell sessions. Read to learn how to leverage JShell for prototyping.
🎓Tutorial | Run AI-enabled Jakarta EE and MicroProfile applications with LangChain4j and Open Liberty: Provides a guide for setting up and running an application leveraging LangChain4j APIs for AI-powered features in Java apps.
JavaScript and TypeScript
Public CDNs Are Useless and Dangerous: Recommends self-hosting and using a caching reverse-proxy for better performance and control. Read to learn why public CDNs have become problematic and how to improve their web applications.
🎓Tutorial | The secret life of objects: Discusses how JavaScript's object-oriented programming concepts allow for structured and efficient code organization. Read to learn how to apply these concepts to build modular, and maintainable code.
🎓Tutorial | An approach to optimizing TypeScript type checking performance: Discusses methods to quantify the workload of TypeScript's type checker by measuring metrics like type instantiations and wall-time.
Go
Go 1.23 Release Notes: Key changes include integrating the "range-over-func" experiment into the language, preview support for generic type aliases, and the introduction of telemetry for gathering usage statistics. Read to learn more.
Common Go Mistakes: Covers 100 common mistakes in Go programming and how to avoid them, with newly added sections on interface pollution and writing concurrent code that leads to false sharing.
Rust
Rust's Mutex, Atomics and UnsafeCell – Spooky Action at a Distance?: Discusses Rust's handling of concurrency within Rust's strict rules on mutability and aliasing. Read to learn how Rust's concurrency primitives work.
🎓Tutorial | Streaming LLM assistant completions with the OpenAI API and Rust Actix-Web: Details the use of Actix's Arbiter and crossbeam-channel to enable effective streaming while simultaneously processing and storing data.
Swift
🎓Tutorial | Build an embedded application for a microcontroller: Covers installing the necessary tools, setting up the environment, and writing a basic blinky LED program. Read to learn how to set up and deploy using Raspberry Pi Pico.
🎓Tutorial | @Entry macro - Creating custom environment values in SwiftUI: Introduced in Xcode 16 but compatible with iOS 13 and later, the macro allows developers to define environment values, such as themes, more efficiently.
PHP
🎓Tutorial | Leveraging Laravel's built in driver functionality: Guides you through the process of creating custom drivers in Laravel, using a hypothetical scenario where the app needs to pull product and stock information.
SQL
Comparing Different "SQL over HTTP" APIs: Explores various APIs, such as Snowflake SQL REST API, MongoDB Data API, and others, highlighting differences in authentication, result pagination, API design, and sync vs. async operations.
Ruby
💼Case Study | Building GitHub with Ruby and Rails: GitHub has streamlined its Rails and Ruby upgrade process, now upgrading Rails weekly through an automated workflow that pulls the latest version of Rails and tests it across builds.
Kotlin
Kotlin 2.0.0 - A Deep Dive into the Latest Features: Explores the latest features and enhancements in Kotlin 2.0.0 that improve code efficiency, expressiveness, and cross-platform development capabilities.
🌟Best Practices and Advice🚀
AI orchestration - benefits, best practices, and tools: Explains AI orchestration, a strategy to align AI tools and projects with business objectives, enhancing decision intelligence and operational efficiency.
Harness software intelligence to conquer complexity and drive innovation: Discusses how software intelligence can help technology leaders reduce cognitive load on development teams by providing clear, up-to-date architecture insights.
Prepare to Be Unprepared - Investing in Capacity to Adapt to Surprises in Software-Reliant Businesses: Advocates for investing in peer code reviews, cross-team collaboration, and learning from incidents to enhance resilience.
The C̶a̶k̶e̶ User Location is a Lie!!!: Discusses the complexities of implementing location-based features in apps, highlighting the limitations and challenges of various methods like user-reported data, device heuristics, and IP address.
Take the Survey, Get a Packt Credit!
🧠 Expert Insight 📚
Here’s an excerpt from “Chapter 9: Concurrency Strategies and Models” in the book, High Performance with Java by Dr. Edward Lavieri Jr., published in July 2024.
Non-blocking algorithms
…These algorithms help us achieve thread safety without having to use… locking mechanisms…, such as synchronized methods and synchronized blocks. There are three types of non-blocking algorithms – lock-free, wait-free, and obstruction-free. Although their names are self-describing, let’s take a closer look.
Modern CPUs support atomic operations, and Java includes several atomic classes that we can use when implementing non-blocking algorithms.
Atomic operations
These are operations that are executed by modern CPUs as a single, finite step that ensures consistency without the need for locks.
Here is a code snippet that illustrates how to use AtomicInteger:
import java.util.concurrent.atomic.AtomicInteger;
public class Counter {
private AtomicInteger count = new AtomicInteger(0);
public void increment() {
count.incrementAndGet();
}
public int getCount() {
return count.get();
}
}
The following example demonstrates how to implement a non-blocking stack. As you will see, our stack uses atomic references, which ensures thread safety:
import java.util.concurrent.atomic.AtomicReference;
class Node<T> {
final T item;
Node<T> next;
Node(T item) {
this.item = item;
}
}
public class ConcurrentStack<T> {
AtomicReference<Node<T>> top = new AtomicReference<>();
public void push(T item) {
Node<T> newHead = new Node<>(item);
Node<T> oldHead;
do {
oldHead = top.get();
newHead.next = oldHead;
} while (!top.compareAndSet(oldHead, newHead));
}
public T pop() {
Node<T> oldHead;
Node<T> newHead;
do {
oldHead = top.get();
if (oldHead == null) {
return null;
}
newHead = oldHead.next;
} while (!top.compareAndSet(oldHead, newHead));
return oldHead.item;
}
}
We can gain performance advantages when we use non-blocking algorithms, especially when our application deals with high concurrency. The advantages are counterbalanced by code complexity, which can result in errors and code that is more difficult to maintain.
High Performance with Java was published in July 2024. Packt library subscribers can continue reading the entire book for free or you can buy the book here!
🛠️ Useful Tools ⚒️
Dioptra: NIST's open-source tool for assessing AI model trustworthiness, supporting the AI Risk Management Framework with features like reproducibility and interoperability.
openFrameworks: an open-source C++ toolkit designed for creative coding, enabling developers to create interactive graphics, audio, and other multimedia applications.
Multilspy: a Python library that simplifies building language server clients, allowing static code analysis across multiple languages using the Language Server Protocol (LSP).
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 feedback, take the survey, or leave a comment below.




