Skip to article frontmatterSkip to article content

Abstract

The proliferation of powerful Large Language Models (LLMs) and other generative techniques has initiated a fundamental transformation in programming and software engineering in general. The emergence of the Generative AI (GenAI) made possible by these LLMs has transformed programming from the act of instructing computers through explicit rules to teaching them to simulate intelligence through examples. The confluence of open-source tools for running LLMs locally and the development of small and highly efficient LLMs which do not require special hardware has profoundly democratized Generative AI itself, enabling developers to be more productive overall throughout the Software Development Lifecycle (SDLC). In essence, the combination of efficient open-source models, seamless tooling and easily accessible hardware has made GenAI a programmable resource for every developer, rather than a precious utility only available to large tech corporations.

This monograph provides a comprehensive and example-driven introduction to generative AI in terms of practical software engineering. It walks readers through core concepts of language models, including: prompt engineering, retrieval-augmented generation (RAG), agent architectures, and code generation - all while grounding each topic in executable Python examples and real development workflows. We will interactively analyze the foundational mechanisms enabling high-quality code generation, automated refactoring, and AI-driven testing. Key topics discussed will also include the architecture of code-specific LLMs, the mechanics of RAG for contextual grounding, and the design of agentic planning models for complex tasks.

This material places a strong emphasis on hands-on learning, and is designed for students & software engineers who want to build mental models of GenAI behavior and understand how to effectively integrate GenAI into their development processes. By making GenAI concrete and programmable, this executable monograph aims to lower the barrier to entry for anyone wanting to augment their programming productivity with GenAI.

Keywords:AIGenerativeProgramming

This book offers a hands-on introduction to software engineering with generative AI, combining formal foundations with executable code, practical design patterns and best practices.

A Note on Software Versions

I show the Python version — and versions of the major Python packages — used to build this executable book.

from platform import python_version
print(python_version())
3.13.7

This book uses Ollama and its Python API. Ollama is an open source tool that simplifies managing and running LLMs locally, like on a PC or local server, for example.

!uv pip show ollama
Name: ollama
Version: 0.6.0
Location: /Users/chikeabuah/Desktop/programming-genai/.venv/lib/python3.13/site-packages
Requires: httpx, pydantic
Required-by:

The structure and executable nature of this book is enabled by the Jupyter ecosystem.

!jupyter --version
Selected Jupyter core packages...
IPython          : 9.6.0
ipykernel        : 7.1.0
ipywidgets       : 8.1.7
jupyter_client   : 8.6.3
jupyter_core     : 5.9.1
jupyter_server   : 2.17.0
jupyterlab       : 4.4.10
nbclient         : 0.10.2
nbconvert        : 7.16.6
nbformat         : 5.10.4
notebook         : 7.4.7
qtconsole        : not installed
traitlets        : 5.14.3

This book is typset using Jupyter Book 2.0 which is currently in alpha release.

!jupyter book --version
v2.0.0-b3
!jupyter kernel --version
8.6.3

I recommend the Microsoft Visual Studio Code editor for interacting with Jupyter Notebooks. It is free to use, and was used in the writing of this book.

!code --version 
1.105.1
7d842fb85a0275a4a8e4d7e040d2625abbf7f084
arm64