ProgrammingPro #79: AI-Driven Product Recommendations, Rust 1.82 Adds Cargo info Subcommand, and 25% JDK Size Reduction Proposal
Welcome to this week’s edition of ProgrammingPro!
In today’s Expert Insight, we bring you an excerpt from the recently published book, AI Strategies for Web Development, which demonstrates how to create an AI-driven product recommendation system for e-commerce using TensorFlow and Keras.
News Highlights: Rust 1.82 adds cargo info
and lifetime improvements; Java proposal targets 25% JDK size reduction; OpenAI releases Swarm for multi-agent AI; and Microsoft previews .NET AI integration libraries.
My top 5 picks from today’s learning resources:
Optimizing Wellhub Autocomplete Service Latency: a Multi-Region Architecture🌍
Navigating unexpected license changes in open source software🛡️
But there’s more, so dive right in.
Stay Awesome!
Divya Anne Selvaraj
Editor-in-Chief
PS: The October survey is still live. Do take the opportunity to leave us your feedback, request a learning resource, and earn your one Packt credit for this month.
🗞️News and Analysis🔎
Rust 1.82 brings Cargo info subcommand: The long-requested
cargo info
subcommand provides detailed information about packages in the Cargo registry. Additional updates include improvements in lifetime parameter handling.Java proposal would shrink JDK by 25%: The proposal aims to enable the
jlink
tool to create custom runtime images without using JMOD files to improve efficiency in cloud environments.OpenAI Releases Swarm, an Experimental Open-Source Framework for Multi-Agent Orchestration: The framework allows for more scalable, customizable, and complex AI systems by breaking tasks into subtasks.
Microsoft Releases Preview of AI Integration Libraries for .NET: Microsoft.Extensions.AI.Abstractions and Microsoft.Extensions.AI provide unified API abstractions for integrating AI services and middleware.
Noxia: Emerging Dark Web Hosting Provider Targets Python, Node.js, Go, and Rust Ecosystems: Noxia facilitates malicious campaigns by hosting malware and providing infrastructure for activities like phishing.
Java News Roundup: WildFly 34, Stream Gatherers, Oracle CPU, Quarkiverse Release Process: Also includes updates on Spring Framework, Micrometer, Project Reactor, Apache TomEE, JobRunr, and Gradle.
Microsoft 365 Copilot allows users to create their own autonomous agents: The agents can automate tasks and business processes, with new agents being introduced for Dynamics 365 across sales, finance, and more.
🎓Tutorials and Learning Resources💡
Python
Comprehensive Python Cheatsheet: An extensive resource covering a wide array of Python topics, including syntax, data structures, and advanced concepts.
For more Python resources, go to PythonPro
C# and .NET
How fast can you parse a CSV file in C#?: Explores different methods and libraries for parsing CSV files in C#, comparing their performance and showing how a low-level approach can significantly improve processing speed.
🎓Tutorial | Build native WebAssembly components with .NET and C#—and deploy on wasmCloud: Explains the current tooling landscape with tools like componentize-dotnet and the process of utilizing WIT interfaces.
🎓Tutorial | .NET gRPC: Developing High-Performance and Scalable Services (Sample Project): A guide for building a sample client-server application, including setting up the project and configuring Protocol Buffers.
C and C++
🎓Tutorial | Triaging clang C++ frontend bugs: Covers best practices and how to identify bug types, use tools for bug reduction, and handle undefined behavior, diagnostics, and implementation differences.
💼Case Study | Developing a Beautiful and Performant Block Editor in Qt C++ and QML: Details the process explaining its architecture, performance optimizations, and challenges in creating advanced features.
🎓Tutorial | How the ls *.c Command Can Save Your Life as a Developer: Explains how
ls *.c
can significantly boost your productivity by quickly listing only the C source files in a directory, making file management easier.
Java
🎥A Sneak Peek at StableValue and SegmentMapper in Java: Introduces two Java features, Stable Value and Segment Mapper, both designed to improve performance and flexibility.
WasmGC and the future of front-end Java development: Covers how WasmGC, enables languages like Java to run efficiently on the front end, potentially transforming web development.
Navigate Early Development | Simplify Data Storage: Discusses the importance of delaying the selection of a database solution and introduces Filelize, a simple file-based data storage library for Java, Android, and Kotlin
JavaScript and TypeScript
Should JavaScript be split into two languages? New Google-driven proposal divides opinion: The proposal aims to improve security, performance, and stability by limiting complexity in JavaScript engines.
🎓Tutorial | Using Protocol Buffers in JavaScript: Efficient Binary Format: Explains how to use Protobuf for efficient binary data serialization, covering its benefits like compactness, speed, and schema-based data integrity.
💼Case Study | How to Build a Query Engine with Automata, TypeScript and Apache Arrow: Describes the development of Sequence Operations Language (SOL), created to address the limitations of SQL.
Go
Go Exceptions for the Unconvinced: Explains how Go's panic/recover mechanism functions similarly to exceptions in other languages and ignoring this can lead to practical issues, such as leaving data in a corrupted state.
What's in an (Alias) Name?": Introduces generic alias types in Go and explains their importance for incremental refactoring of large codebases.
Rust
🎓Tutorial | Async Rust in Three Parts: Guides you through the process of working with futures, tasks, and async I/O along with practical code examples.
🎓Tutorial | When should I use String vs &str?: Offers four levels of advice, starting with using
String
everywhere, gradually refining to using&str
for function parameters and when returning substrings, and avoiding&str
in structs.
Swift
Native Cross-Platform Apps: Introduces Aparoksha, a cross-platform UI framework for Swift that leverages native frameworks like GNOME's libadwaita and WinUI 3.
Vapor and Swift Testing: Running tests in parallel: Explores running parallel tests in Swift for Vapor-based applications and handling the challenge of database reliance.
PHP
Monitoring PHP Performance and Diagnosing Bottlenecks: Covers performance monitoring tools like Datadog, New Relic, and profiling tools such as Xdebug and Blackfire and key performance metrics such as CPU usage.
SQL
🎓Tutorial | Introducing the prompt() Function: Use the Power of LLMs with SQL!: Discusses common patterns that cause poor SQL query performance and offers solutions to issues including undersorting.
Ruby
Class methods are Ruby’s useEffect: Draws a parallel between React’s
useEffect
and Ruby’s class methods, referring to both as "escape hatches" from their respective paradigms that should be used sparingly.
Kotlin
🎓Tutorial | How To Create a Parallax Movie Pager In Jetpack Compose: Shows you how to utilize offset calculations, image scaling, translation, and Bitmap implementation for enhanced UI effects.
🌟Best Practices and Advice🚀
Adaptive Responses to Resiliently Handle Hard Problems in Software Operations: Highlights five key traits of adaptive expertise: recognizing changes, revising mental models, replanning, reconfiguring resources, and reviewing performance for learning.
Taking Advantage of Cell-Based Architectures to Build Resilient and Fault-Tolerant Systems: Focuses on monitoring, tracing, and logging to identify bottlenecks, detect issues early, and optimize performance.
Optimizing Wellhub Autocomplete Service Latency: a Multi-Region Architecture: Outlines how Wellhub optimized its Go-based service by leveraging AWS Global Accelerator and S3 Cross-Region Replication.
Navigating unexpected license changes in open source software: Recommends that organizations maintain a software bill of materials (SBOM) and dedicated teams to manage OSS compliance and security.
🧠Expert Insight📚
Here’s an excerpt from “Chapter 6: Design Intelligence – Creating User-Centric Experiences with AI" in the book, AI Strategies for Web Development, by Anderson Soares Furtado Oliveira, published in September 2024.
Example of AI Movie Recommendation Chatbot
In this example, we will create an AI-driven dynamic content personalization system for an e-commerce website. The system will use TensorFlow and Keras to analyze user behavior and personalize product recommendations based on
their shopping history. We will use the Retailrocket recommender system dataset to store user data and product information.
The workflow of the example is as follows:
Collect user data from the Retailrocket recommender system dataset.
Train a TensorFlow model to analyze user behavior and predict product preferences.
Use Keras to create a personalized product recommendation system based on the TensorFlow model.
Implement the recommendation system on the e-commerce website.
However, it also has some disadvantages:
Speed limitations: UART is generally slower compared to SPI and I2C, making it less suitable for high-speed data transfer
Limited distance: Susceptibility to noise over long distances can limit the range of reliable communication
Point-to-point only: UART is designed for direct, point-to-point communication, which can be a limitation if multiple devices need to communicate
Data Description
Retailrocket recommender system dataset is a dataset of user behavior from an e-commerce website, including clicks, purchases, and views. The dataset contains 1,407,580 users and 2,756,101 behavior events, including 2,664,312 views, 69,332 cart additions, and 22,457 purchases. You can access the dataset at: https://www.kaggle.com/datasets/retailrocket/ecommerce-dataset
Next, we will learn how to manipulate and analyze this data using Python.
Python Code Step by Step
In this section, we will outline a series of coding steps essential for manipulating and understanding the dataset effectively. Each step will build upon the last, guiding you through the use of various Python libraries to harness the power of this data for building an intelligent recommender system.
We import the necessary libraries for the example, including TensorFlow, Keras, and Pandas.
import tensorflow as tf
from tensorflow import keras
import pandas as pd
We load the Retailrocket recommender system dataset into a Pandas DataFrame.
events_df = pd.read_csv(
"/kaggle/input/ecommerce-dataset/events.csv"
)
We group the data by visitor ID and aggregate the item IDs into a list for each visitor.
user_data = events_df.groupby('visitorid').agg(
{'itemid': lambda x: list(x)}
)
We create a sequential model with two hidden layers and an output layer. We compile the model with the Adam optimizer and sparse categorical cross-entropy loss function. We then fit the model to the user data.
model = keras.Sequential([
keras.layers.Dense(64, activation='relu'),
keras.layers.Dense(64, activation='relu'),
keras.layers.Dense(len(user_data), activation='softmax')
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(user_data, user_data, epochs=10)
We define a function that takes a user ID as input and returns a list of recommended products based on the user’s shopping history.
def recommend_products(user_id):
user_data = user_data[user_id]
predictions = model.predict(user_data)
recommended_products = []
for i in range(len(predictions)):
if predictions[i] > 0.5:
recommended_products.append(products[i])
return recommended_products
Now, we implement the recommendation system on the e-commerce website.
The result of this example is an AI-driven dynamic content personalization system for an e-commerce website that provides personalized product recommendations based on user behavior.
In this example, we discussed techniques for implementing AI-driven dynamic content personalization in e-commerce applications. We also introduced tools like TensorFlow and Keras for incorporating AI into e-commerce environments. By following the above project, you can create a personalized product recommendation system for your e-commerce website and provide a unique shopping experience for each user.
Note
This is a simplified example and may not work directly without some modifications depending on your development environment. Adjust it as needed.
AI Strategies for Web Development was published in September 2024. Packt library subscribers can continue reading the entire book for free or you can buy the book here!
Get the eBook for $30.99 $20.99
🛠️Useful Tools⚒️
finch: an open-source AWS tool for simplifying container development using containerd and nerdctl across platforms.
superhtml: An open-source language server offering real-time HTML5 syntax validation, autocorrect, and reformatting for LSP-compatible editors.
Srcbook: An open-source TypeScript platform that uses AI to create, edit, and run web apps and backends with interactive notebooks and live previews.
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.
If your company is interested in reaching an audience of developers, software engineers, and tech decision makers, you may want to advertise with us.