ProgrammingPro #62: Java's Project Leyden Accelerates Performance, SquirrelFS for Rust Stability, and Polyfill.io Alert
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,
Odoo Development Cookbook - Fifth Edition, which demonstrates how to use the Python debugger (pdb) to manually trace and debug method execution in Odoo.
News Highlights: Java's Project Leyden boosts startup and performance; TypeScript 5.5 adds advanced type predicates and Set method support; Concerns grow over AI testing reliability; and Urgent warning to remove Polyfill.io due to malicious scripts.
My top 5 picks from today’s learning resources:
🐿️SquirrelFS - using the Rust compiler to check file-system crash consistency
Forrester shares its top 10 emerging technology trends for 2024📈
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!
🗞️News and Analysis🔎
Java’s Project Leyden arrives in early-access build: The release is designed to boost Java's startup time, peak performance, and overall efficiency. Read to learn about its features for faster application launches.
TypeScript 5.5 is now generally available: The version enhances Microsoft's JavaScript variant with inferred type predicates, regular expression syntax checking, and ECMAScript Set method support. Read to learn about all the new features.
ASP.NET Core 9 Preview 5 - Static Web Optimization, Blazor Additions, New Project Template and More: Updates also include the optimization of static web asset delivery via the new MapStaticAssets API. Read to learn more.
Spring Ecosystem Releases Focus on Spring Boot, Spring Security and Spring Modulith: Key improvements include enhanced static web asset delivery in Spring Boot and better reconnection strategies in Blazor Server. Read for more.
Atlassian Announces Compass, a Developer Experience Platform: The platform is designed to improve software architecture performance. Read to learn how it streamlines development processes.
Can you trust AI to test AI-generated code?: While AI coding assistants like GitHub's Copilot have become mainstream, the real challenge lies in trusting these tools for generating and testing code. Read for further insights.
If you're using Polyfill.io code on your site – like 100,000+ are – remove it immediately: Initially intended to enhance browser compatibility, the domain now distributes malicious scripts. Read to learn about the importance of security measures when integrating third-party scripts into websites.
🎓Tutorials and Learning Resources💡
Python
Why Python Is So Slow (And What Is Being Done About It): Highlights innovative solutions from PyCon 2024 aimed at enhancing Python’s speed. Read to learn about technologies being developed to accelerate performance.
Testing with Python (part 7): ...until you make it: Covers tools like mimesis for fake data, freezegun for manipulating system time, and pyfakefs for simulating file systems. Read to learn how to automate and simplify testing.
For more Python resources go to PythonPro
C# and .NET
🎓Tutorial | When to use an abstract class vs. interface in C#: Understanding when to use each is crucial for designing extensible and loosely coupled applications. Read to enhance your ability to design software architectures.
Validating gigabytes of Unicode strings per second… in C#?: Discusses a library for validating and transcoding Unicode strings in C#. Read to learn how it significantly outperforms the standard .NET library.
🎓Tutorial | Using Phi-3 & C# with ONNX for text and vision samples: Shows how to enable advanced AI tasks such as text processing and image analysis in C#. Read to learn how to implement and leverage AI capabilities in .NET applications.
C and C++
🎓Tutorial | Your Own Constant Folder in C/C++: Discusses the challenges and solutions for using the sqrtps intrinsic in C/C++ with the clang compiler. Read to learn advanced techniques for managing compiler optimizations and intrinsics.
Secure Coding Practices in C++: Addresses crucial security concerns such as buffer overflows, memory leaks, and race conditions, due to C++’s low-level memory access. Read to learn how to avoid common security pitfalls in C++.
Padding and Greedy Alignment: Explains the concepts of padding and greedy alignment in C++ programming to optimize memory usage and performance. Read to learn how to strategically manage memory alignment in C++.
Java
🎓Tutorial | Stream gatherers - A new way to manipulate Java streams: Java 22 introduces customizable stream operators in java.util.stream.Gatherers to enhance stream manipulation. Read to learn how to utilize the feature.
🎓Tutorial | How to use assertions in Java: Explains how to use Java assertions to validate program correctness by checking assumptions directly in the code. Read to learn how to preemptively catch logical errors during development.
🎓Tutorial | HTMX for Java with Spring Boot and Thymeleaf: Demonstrates how to build a simple Todo application. Read to learn how to create interactive web applications efficiently, enhancing user experience with minimal JavaScript.
JavaScript and TypeScript
New JavaScript Set methods: These methods, available in most major browsers as of Firefox 127, include intersection(), union(), difference(), and more. Read to learn how to use these methods to enhance your projects.
The many faces of undefined in JavaScript: Explores the complexities of representing undefined or unknown values in JavaScript, detailing various cases where these values appear. Read to learn how to manage these values.
The Making of a TypeScript Feature - Inferring Type Predicates: Describes a TypeScript contributor's journey in implementing type predicate inference for TypeScript 5.5. Read for a deep dive into the development process.
Go
Three Ways To Think About Channels: Provides a comprehensive guide to understanding Golang channels, emphasizing their nature as locked, buffered queues. Read to learn how to implement and optimize channels in Go.
Rust's concurrency model vs Go's concurrency model - stackless vs stackfull coroutines: Discusses the unique advantages and complexities of Rust's and Go's concurrency models. Read for insight into their impact on performance and more.
Rust
🎧The key to a happy Rust/C++ relationship: Discusses the integration of Rust into Meta's development environment. Read to gain insights into the strategies for successfully integrating Rust with C++ in a large-scale, established codebase.
SquirrelFS - using the Rust compiler to check file-system crash consistency: Introduces a new file system built on Rust’s typestate pattern to ensure crash consistency via compile-time checks. Read to learn about the innovative use of Rust's compile-time capabilities to achieve both safety and performance.
PHP
Create a DateTime from a Timestamp With this New Method Coming to PHP 8.4: Introduces createFromTimestamp()which simplifies the creation of DateTime objects from Unix timestamps. Read to discover more about the method.
SQL
How SQL Vector Databases Boost RAG Performance: Explains how the integration of vector databases enhances the performance of RAG systems. Read to learn how to enable efficient data retrieval and processing in AI applications.
Ruby
Execute commands by sending JSON? Learn how unsafe deserialization vulnerabilities work in Ruby projects: Details how such vulnerabilities work, using an example. Read to learn how to detect these vulnerabilities.
Swift
Why Swift's type checker is so slow: Swift's compiler can be slow due to its bi-directional Hindley-Milner type checker. Read to learn how to mitigate these issues by breaking down expressions and using diagnostic tools.
Kotlin
Effectively Using Kotlin Flow in Android App Development: Kotlin Flow, integral to Kotlin Coroutines, enhances Android app development by managing asynchronous data streams. Read to learn how to integrate it seamlessly with existing app architectures.
🌟Best Practices and Advice🚀
Forrester shares its top 10 emerging technology trends for 2024: Key trends include sophisticated AI agents performing complex tasks, TuringBots accelerating software development, edge intelligence enhancing device autonomy, and extended reality evolving UIs. Read for more relevant insights.
Using Greenops to Improve Your Operational Efficiency and Save the Planet: “the IT sector alone is responsible for 1.4% of carbon emissions worldwide." Read for insights into a practical pathway to environmental responsibility in your work.
1,000+ business leaders collaborate to create Enterprise GenAI Governance Framework: Spearheaded by Boomi, Connor Group, and academics, this framework adapts to various company sizes and objectives. Read to discover practical strategies for integrating AI securely.
Take the Survey, Get a Packt Credit!
🧠 Expert Insight 📚
Here’s an excerpt from “Chapter 7: Debugging Modules” in the book, Odoo Development Cookbook - Fifth Edition by Husen Daudi, Jay Vora, Parth Gajjar, Alexandre Fayolle, Holger Brunn, and Daniel Reis.
Using the Python debugger to trace method execution
Sometimes, application logs are not enough to figure out what is going wrong. Fortunately, we also have the Python
debugger. This recipe shows us how to insert a breakpoint in a method and trace the execution by hand.
Getting ready
We will …use the export_stock_level() method.
How to do it...
To trace the execution of export_stock_level() with pdb, perform the following steps:
Edit the code of the method, and insert the line highlighted here:
def export_stock_level(self, stock_location):
import pdb; pdb.set_trace()
products = self.with_context( location=stock_location.id ).search([])
fname = join(EXPORTS_DIR, 'stock_level.txt')
try:
with open(fname, 'w') as fobj:
for prod in products.filtered('qty_available'):
fobj.write('%s\t%f\n' % (prod.name, prod.qty_available))
except IOError:
raise exceptions.UserError('unable to save file')
Run the method. We will use the Odoo shell…
$ ./odoo-bin shell -c project.cfg --log-level=error
[...]
>>> product = env['product.product']
>>> location_stock = env.ref('stock.stock_location_stock')
>>> product.export_stock_level(location_stock)
> /home/cookbook/stock_level/models.py(18)export_stock_level()
-> products = self.with_context(
(Pdb)
At the (Pdb) prompt, issue the args command (the shortcut for which is a) to get the values of the arguments that were passed to the method:
(Pdb) a
self = product.product()
stock_location = stock.location(14,)
Enter the list command to check where in the code you are standing:
(Pdb) list
13 @api.model
14 def export_stock_level(self, stock_location):
15 _logger.info('export stock level for %s',
16 stock_location.name)
17 import pdb; pdb.set_trace()
18 -> products = self.with_context(
19 location=stock_location.id).search([])
20 products = products.filtered('qty_available')
21 _logger.debug('%d products in the location',
22 len(products))
23 fname = join(EXPORTS_DIR, 'stock_level.txt')
(Pdb)
Enter the next command three times to walk through the first lines of the method. You may also use n, which is a shortcut:
(Pdb) next
> /home/cookbook/stock_level/models.py(19)export_stock_level()
-> location=stock_location.id).search([])
(Pdb) n
> /home/cookbook/stock_level/models.py(20)export_stock_level()
-> products = products.filtered('qty_available')
(Pdb) n
> /home/cookbook/stock_level/models.py(21)export_stock_level()
-> _logger.debug('%d products in the location',
(Pdb) n
> /home/cookbook/stock_level/models.py(22)export_stock_level()
-> len(products))
(Pdb) n
> /home/cookbook/stock_level/models.py(23)export_stock_level()
-> fname = join(EXPORTS_DIR, 'stock_level.txt')
(Pdb) n
> /home/cookbook/stock_level/models.py(24)export_stock_level()
-> try:
Use the p command to display the values of the products and fname variables:
(Pdb) p products
product.product(32, 14, 17, 19, 21, 22, 23, 29, 34, 33, 26, 27, 42)
(Pdb) p fname
'/srv/exports/stock_level.txt'
Change the value of fname to point to the /tmp directory:
(Pdb) !fname = '/tmp/stock_level.txt'
Use the return (shortcut: r) command to execute the current function:
(Pdb) return
--Return--
> /home/cookbook/stock_level/models.py(26)export_stock_level()->None
-> for product in products:
Use the cont (shortcut: c) command to resume the execution of the program:
(Pdb) c
>>>
The Odoo Development Cookbook - Fifth Edition was published in May 2024. Packt library subscribers can continue reading the entire book for free. You can buy the book here!
🛠️ Useful Tools ⚒️
LibreChat: an advanced AI chat platform combining models like OpenAI's ChatGPT and Google Vertex AI, offering multimodal chat, editable conversations, and broad AI service support in a customizable, multilingual UI.
triplit: an open-source, full-stack database that syncs data in real-time between servers and browsers, featuring real-time updates, local caching, offline mode, and collaborative capabilities through CRDTs.
ControlFlow: an open souce Python framework designed for building agentic AI workflows, enabling developers to define and manage task-centric processes for AI agents, ensuring controlled and transparent operations.
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.




