





















































Snyk is thrilled to announce DevSecCon 2024, Developing AI Trust Oct 8-9, a FREE virtual summit designed for DevOps, developer and security pros of all levels. Join Roman Lavrik from Deloitte, among many others, and learn some presciptive DevSecOps methods for AI-powered development.
Hi ,
Welcome to this week’s edition of ProgrammingPro!
In today’sExpert Insight, we bring you an excerpt from the recently published book, Generative AI-Powered Assistant for Developers, which demonstrates how Amazon Q Developer assists in generating C++ code (The book also covers Python, Java, SQL, and more) for complex tasks like developing an operating system kernel.
News Highlights: Swift 6 adds strict concurrency checking, C++ interoperability, and Embedded Swift; 60% of open source maintainers are unpaid, says 2024 report; C++ Alliance proposes a Safe Standard Library for memory safety; and RustConf reaffirms Rust's role in the Linux kernel.
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: Thismonth’ssurvey is still live. Do take the opportunity to tell us what you think of ProgrammingPro, request learning resources, and earn your one Packt Credit for this month.
Still struggling to achieve work-life balance and manage your time efficiently?
Join this 3 hour Intensive Workshop on AI & ChatGPT tools (usually $399) but FREE for the first 100 people.
Print book discounts end on the 22nd of September 2024.
ls
command in Unix-like operating systems, detailing how to replicate its various functionalities in C, such as listing all files (including hidden ones), and more.finally
blocks.void
type in TypeScript, explaining its primary use for function return types, its restrictions on variable assignments, and more.go test
command, outlining the evolution of testing methodologies for command-line tools, from shell scripts to Go-based testing frameworks.Here’s an excerpt from “Chapter 5: Boost Coding Efficiency for C and C++ with Auto-Code Generation” in the book, Generative AI-Powered Assistant for Developers by Behram Irani and Rahul Sonawane, published in August 2024.
Now let’s move to the sample use case to show the power of Amazon Q Developer’s ability to recommend code. To illustrate, I am going to use the VS Code script editor window with single
andmulti-line prompts.
Let’s say that we want to write a C++ program to develop a new operating system kernel, which can control system resources and has the ability to handle complex memory management tasks. The kernel must interact with hardware, manage processes, and ensure stability across differenthardware architectures.
Let’s use the multi-line prompt technique to achieve the precedinguse case.
Prompt:
/* Write an end to end executable C++ script
to develop a new operating system kernel, that can control over system resources and ability to handle complex memory management tasks. The kernel must interact with hardware, manage processes, and ensure stability across different hardware architectures.
*/
Figure 5.11 – Writing a C++ program with Amazon Q Developer
The preceding screenshot shows partial code suggested by Amazon Q Developer. You can observe that end-to-end code demonstrates several fundamental and advanced concepts in C++ programming, including OOP, classes, vectors, functions, error handling,and more.
Now let’s use an interactive inline prompt with the chain-of-thought technique to enhance the code. As you can see, theloadProcess()
function does not have exception handling, so let’s instruct it to add an exception handle for the null process with the single-lineprompt technique:
Prompt :
/* add exception handling for loadProcess */
Figure 5.12 – Prompt – C++ program sample snapshot
As shown in the screenshot, based on our prompt, Amazon Q Developer added anullptr
condition to check the process load exception. If it encounters a null pointer, then the code gracefully exits with aError: process is
null
message.
Generative AI-Powered Assistant for Developerswas published in August 2024. Packt library subscribers can continue reading the entire book for free or you can buy the bookhere!
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 usefulhere.
If your company is interested in reaching an audience of developers, software engineers, and tech decision makers, you may want toadvertise with us.