ProgrammingPro #59: Splatting in PowerShell, BoxLang's JVM Innovation, Python AI Course, and .NET Retro Gaming
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, Mastering PowerShell Scripting - Fifth Edition, which starts the discussion on how to effectively use splatting in PowerShell to improve script efficiency, readability, and overall command management.
News Highlights: BoxLang launches a new JVM language to revitalize dynamic capabilities; Deno enhances private NPM registry support and performance; JetBrains stabilizes Compose Multiplatform with smoother transitions; and Next.js 15 supports React 19 and disables default caching.
My top 5 picks from today’s learning resources:
HarvardX - CS50's Introduction to Artificial Intelligence with Python🤖
Implementing MVCC and major SQL transaction isolation levels🗄️
But there’s more, so dive right in.
Stay Awesome!
Divya Anne Selvaraj
Editor-in-Chief
PS: Thank you to everyone who participated in last month's survey and shared your thoughts on using LLMs for code understanding. We will discuss the topic briefly in this issue. This month, our survey asks for your suggestions to enhance Copilots for coding efficiency in the context of this paper. Share your opinions, your feedback on ProgrammingPro, and earn your one Packt credit for the month. Take the survey!
🗞️News and Analysis🔎
BoxLang - A Revolution Led by Rebels – An Interview with Luis Majano, CEO of Ortus Solutions: The new JVM language aims to modernize dynamic language capabilities on the JVM, addressing long-standing industry stagnation. Read to learn about the innovative features of BoxLang.
Deno adds support for private NPM registries: This release also boasts significant performance improvements, such as V8 pointer compression for reduced memory usage and faster module loading. Read for more.
JetBrains stabilizes Compose Multiplatform resources API: The update introduces an experimental navigation library akin to Jetpack Compose Navigation, enabling more intuitive screen transitions. Read to learn about more enhancements.
Next.js 15 Release Candidate supports React 19, disables caching by default after developer feedback: The version also introduces a new API next/after for post-response code execution. Read to learn how the enhancements can optimize your development workflows.
Safe AI development - Integrating explainability and monitoring from the start: Anthropic's introduction of Claude 3 Sonnet marks a significant shift towards safer AI practices. Read for insights into Anthropic’s research and approach.
Quarkus Java framework adds dev extensions for observability: Quarkus 3.11, simplifies the integration of observability tools like Grafana, Jaeger, OTel, and VictoriaMetrics into development environments. Read to learn more.
Introducing the RIG Model - the Puzzle of Designing Guaranteed Data-Consistent Microservice Systems: This article presents a system where transactions are categorized as Reversible, Irreversible, or Guaranteed. Read to gain insights into effectively using compensating transactions to maintain integrity.
🎓Tutorials and Learning Resources💡
Python
👩🏫Free Course | HarvardX - CS50's Introduction to Artificial Intelligence with Python: This 7-week, self-paced introductory course explores the foundational concepts and algorithms used in technologies such as game engines and machine translation. Read to learn more.
📖Open Access Book | Think Python, 3rd edition: This book is an introductory guide to Python programming, presented in an interactive format using Jupyter notebooks to help beginners and those who have struggled with programming learn effectively. Read to dive in.
For more Python resources go to PythonPro
C# and .NET
🎥Running .NET on the NES | BRK252: This video featuring Jonathan Peppers, an engineer for dotNet on Android and dotNet Maui, presents an intriguing project about running dotNet on the Nintendo Entertainment System (NES). Watch to explore the technical process of converting .NET code to 6502 assembly.
Building .NET apps for Linux from any operating system: This article dispels the myth that .NET cannot build UIs for Linux, highlighting that .NET has supported Linux since .NET Core 1.0 in 2016. Read to learn how to build .NET UIs for Linux using various IDEs.
TryParse in C# - Level Up Your Code With This Incredible Feature: This article showcases TryParse’s ability to safely convert strings to various data types without throwing exceptions. Read to enhance your code's reliability and flexibility.
C and C++
Circle C++ with Memory safety: This article proposes creatimg Safe C++, a superset of C++ with a rigorously safe subset using borrow checking for lifetime safety, and enhanced type safety mechanisms to prevent undefined behaviors. Read for insights into the potential of Safe C++.
An Extensive Benchmark of C and C++ Hash Tables: This benchmark suite compares the performance of C and C++ hash tables under various conditions, focusing also on lesser-studied C tables. Read to learn about the performance characteristics of different hash tables in C and C++.
A graphical depiction of the steps in building a C++ executable, with XAML and packaging: This article explains how XAML interfaces and packaging are integrated into the build process. Read for an easy to understand explanation.
Java
🎓Tutorial | Java inheritance vs. composition - How to choose: This article explains the fundamental ways to establish relationships between Java classes. Read for practical advice on choosing the appropriate method for your classes.
🎓Tutorial | Inheritance in Java, Part 1 - The extends keyword: This tutorial discusses how to derive a child class from a parent class and invoke parent class constructors. Read to distinguish between single and multiple inheritance and more.
🎓Tutorial | Inheritance in Java, Part 2 - Object and its methods: This part of the tutorial focuses on the root of the class hierarchy in Java. Read to learn how to use Java inheritance more effectively in programming.
JavaScript and TypeScript
🎓Tutorial | Data storage for front-end JavaScript: In-browser data storage options for front-end JavaScript span from simple variables to more advanced mechanisms like localStorage. Read to learn about all the various techniques.
Promises From The Ground Up: This article covers the necessity of understanding Promises for effective JavaScript programming, given their central role in handling asynchronous operations in modern web development. Read to be able to write clean, maintainable code.
🎓Tutorial | Live types in a TypeScript monorepo: This article explores methods to make TypeScript code in monorepos react instantly to changes, enhancing productivity without requiring rebuilds. Read to ensure efficient development cycles and reduced build dependency.
Go
Sentinel errors and errors.Is() slow your code down by 500%: This article benchmarks various error handling strategies, discovering significant performance differences. Read to learn how to evaluate and optimize error handling in Go.
🎓Tutorial | Reading Google Sheets from a Go program: This post explores how to read data from Google Sheets using Go, focusing on methods like service accounts and OAuth for authentication. Read to learn step-by-step methods to authenticate and read data from Google Sheets.
Rust
No. we didn’t miss adding in Rust resources in this time. We are making a special Rust issue for you, based on popular demand which you will receive in your inboxes tomorrow! Keep you eyes peeled 🦀👀🦀 and add us to your safe senders list!
PHP
FrankenPHP and Caddy - Double performance, claims Caddy creator but only some apps benefit: The PHP application server built on the Caddy web server built on the Caddy web server, also claims to reduce workload for developers and DevOps. Read for insights into specific performance improvements expected.
SQL
🎓Tutorial | Implementing MVCC and major SQL transaction isolation levels: This post demonstrates building a simple database in 400 lines of code that supports five SQL transaction isolation levels using Multi-Version Concurrency Control (MVCC) and Optimistic Concurrency Control (OCC). Read to enhance your ability to handle concurrency in database systems effectively.
Ruby
A Comprehensive Guide to Elixir vs Ruby: This article details Ruby’s and Elixir’s histories, advantages, and key differences. Read to make informed decisions about which programming language best suits your project needs.
Swift
🎓Tutorial | Swift Package Manager framework creation in Xcode: This article describers the steps from initialization in the terminal or Xcode to enhancing the Package.swift file, managing dependencies, and bundling resources. Read to learn how to efficiently create and manage your Swift packages with SPM.
Kotlin
AI-Friendly Programming Languages - the Kotlin Story: To ensure Kotlin remains competitive in AI-driven development, JetBrains has introduced the Kotlin ML Pack, comprising tools, data, and models to enhance Kotlin's representation in ML. Read to learn more.
🤖How LLMs Enhance IDEs for Faster and Smarter Development💻
In a recent paper titled "Using an LLM to Help With Code Understanding," researchers from Carnegie Mellon University explored the potential of LLMs like OpenAI's GPT-3.5-turbo to enhance code comprehension within IDEs. They introduced an IDE plugin called GILT, designed to simplify and improve the process of understanding complex codebases directly in the coding environment.
Key Findings
Enhanced Task Completion: GILT significantly aids in task completion, with developers completing programming tasks more efficiently compared to using traditional web searches.
Contextualized Assistance: The plugin provides real-time explanations and details about specific code segments, API calls, and domain-specific terms without requiring explicit prompts from the user.
Differential Impact: The effectiveness of GILT varies between students and professionals, indicating that prior experience influences how well developers can leverage the tool.
User Study Insights: A user study with 32 participants highlighted that GILT could outperform web searches in aiding developers, especially in task-oriented scenarios within an IDE.
What This Means
The integration of LLMs into IDEs like GILT represents a transformative shift towards more intelligent programming environments. By providing contextualized, on-the-spot assistance, GILT minimizes the disruption caused by context switching and searching for external resources. This capability is particularly valuable in complex development projects where quick access to accurate information can significantly enhance productivity and reduce the time to market.
Examining the Details
The study primarily revolves around the implementation and evaluation of the GILT plugin. The tool was rigorously tested in a controlled user study involving 32 participants, chosen to represent a mix of students and professional developers. The methodology focused on comparing task completion efficiency and accuracy between two conditions: one using the GILT plugin and the other relying on traditional web searches for code understanding. The study was designed to assess not just task completion rates but also the quality of interaction between the developers and the tool, including how intuitively the participants could leverage the LLM-enhanced functionalities within their coding workflow.
What you said
We had asked you “What is your opinion on the rising trend of using LLMs to help with code understanding?” Here is what some of you said:
Anonymous: “I think it is a great tool but in my experience sometimes it makes bad decisions if you don't explain the problem you are trying to solve (properly)”
Anonymous: “It can be helpful and fasten program development. There is a risk of using it without regard. There is also the risk in the future that such tools can replace human programmers and it could be disruptive.”
Talib Morgan: (LLMs have) “certainly made me more efficient. I'm a big fan and look forward to even greater productivity as the technology matures.”
Anonymous: “I see it happening to my students: they think the LLM "understands" their code and trust its generated output, which is often just garbage.”
Gordon Margulieux: “The quality of the output is a function of the quality of the input (requirements). I don't think that AI/LLM increases the understanding of the code in general. If used carefully they can be used safely.”
Anonymous: “I have been using ChatGPT for pair programming for a while and I am pretty happy with it. (It) really helps (one) get started.”
Your responses highlight mixed feelings about using LLMs for code understanding: while you praise them for boosting efficiency you also recognize potential reliability issues, particularly with poorly defined problems. The consensus suggests careful management of LLM use to ensure they enhance rather than replace human expertise.
Thank you all. We will send one additional Packt credit to each of these six respondents for sharing their valuable thoughts with us in our very first interactive monthly survey. Do join the conversation in this month’s survey.
Take the Survey, Get a Packt credit!
🧠 Expert Insight 📚
Here’s an excerpt from “Chapter 1:
Introduction to PowerShell” in the book, Mastering PowerShell Scripting - Fifth Edition By Chris Dent.
Introduction to splatting
Splatting is a way of defining the parameters of a command before calling it. This is an important and often underrated technique that the PowerShell team added to PowerShell 2.
Splatting is often used to solve three potential problems in a script:
Long lines caused by commands that need many parameters
Conditional use of parameters
Repetition of parameters across several commands
Individual parameters are written in a hashtable (@{}), and then the @ symbol is used to tell PowerShell that the content of the hashtable should be read as parameters.
This example supplies the Name parameter for the Get-Process command, and is normally written as Get-Process -Name explorer:
$getProcess = @{
Name = 'explorer'
}
Get-Process @getProcess
In this example, getProcess is used as the name of the variable for the hashtable. The name is arbitrary; any variable name can be used.
Splatting can be used with cmdlets, functions, and scripts. Splatting can be used when the call operator is present, for example:
$getProcess = @{
Name = 'explorer'
}
& 'Get-Process' @getProcess
The ability to use splatting with the call operator is useful if the command name itself is held in a variable.
The uses of splatting are explored in the following sections.
Splatting to avoid long lines
The benefit of splatting is most obvious when working with commands that expect a larger number of parameters.
This first example uses the module ScheduledTasks to create a basic task that runs once a day at midnight:
$taskAction = New-ScheduledTaskAction -Execute pwsh.exe -Argument 'Write-Host "hello world"'
$taskTrigger = New-ScheduledTaskTrigger -Daily -At '00:00:00'
Register-ScheduledTask -TaskName 'TaskName' -Action $taskAction -Trigger $taskTrigger -RunLevel 'Limited' -Description 'This line is too long to read'
Each of the commands is spread out over multiple lines; it is hard to see where one ends and the next begins.
Commands can also be spread out using a backtick, the escape character in PowerShell, as shown here:
$taskAction = New-ScheduledTaskAction `
-Execute pwsh.exe `
-Argument 'Write-Host "hello world"'
$taskTrigger = New-ScheduledTaskTrigger `
-Daily `
-At '00:00:00'
Register-ScheduledTask `
-TaskName 'TaskName' `
-Action $taskAction `
-Trigger $taskTrigger `
-RunLevel 'Limited' `
-Description 'This line is too long to read'
This approach is relatively common, but it is fragile. It is easy to miss a backtick from the end-of-line, or to accidentally add a space after a backtick character. Both break continuation and the command executes but with an incomplete set of parameters; afterward, an error may be displayed, or a prompt may be shown, depending on the parameter (or parameters) it missed.
This problem is shown in the following screenshot, where a space character has been accidentally included after a backtick following the Daily switch parameter:
Figure 1.6: Space after the escape character
Splatting provides a neater, generally easier-to-read, and more robust alternative. The following example shows one possible way to tackle these commands when using splatting:
$newTaskAction = @{
Execute = 'pwsh.exe'
Argument = 'Write-Host "hello world"'
}
$newTaskTrigger = @{
Daily = $true
At = '00:00:00'
}
$registerTask = @{
TaskName = 'TaskName'
Action = New-ScheduledTaskAction @newTaskAction
Trigger = New-ScheduledTaskTrigger @newTaskTrigger
RunLevel = 'Limited'
Description = 'Splatting is easy to read'
}
Register-ScheduledTask @registerTask
Switch parameters may be treated as if they are Boolean when splatting.
The Daily parameter that was defined in the previous example is a switch parameter.
The same approach applies to Confirm, Force, WhatIf, Verbose, and so on.
Mastering PowerShell Scripting - Fifth Edition By Chris Dent was published in May 2024. You can continue reading the entire first chapter for free and buy the book here! Packt library subscribers can continue reading the entire book for free here.
🛠️ Useful Tools ⚒️
Apache Pinot: an open-source OLAP analytics platform developed at LinkedIn, designed for real-time, web-scale analytics, featuring low-latency queries and support for massive data volumes and concurrent queries.
KQIR: a query engine for Apache Kvrocks that enables both SQL and RediSearch queries, enhancing the database's versatility by integrating complex query capabilities while preserving high performance.
PlayBooks: automated investigative notebooks for engineers, integrating commands and data queries within observability stacks to accelerate preliminary investigations in production environments.
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, or leave a comment below.