Share E-Book

AI-Assisted Coding The Practical Guide for Software Development (Michael Kofler, Bernd Öggl etc.)(Z-Library)

Author

,
,

Rating 3.5 AI initial rating

Log in to rate

Code
Language English

Generative AI is transforming software development. Stay on the cutting edge with this guide to AI pair programming! Learn how to make the most of modern tools like ChatGPT and GitHub Copilot to improve your coding. Automate refactoring, debugging, and other tedious tasks, and use techniques such as prompt engineering and retrieval-augmented generation to get the code you need. Follow practical examples that show how you can program faster, more efficiently, and with fewer errors with the help of AI. In this book, you’ll learn about: a. Hype versus Reality Learn from expert developers to understand the possibilities (and pitfalls) of AI tools. With the help of practical code examples, see how to use AI helpers correctly to their full potential. b. Assistants for All Tasks This guide gives you an up-to-date overview of all aspects of AI-assisted GitHub Copilot autocompletions, project bootstrapping with OpenHands, debugging and refactoring, application development, and more. c. In the Cloud or Local? Use OpenAI’s API to integrate AI models directly into your own scripts and automations—or use local large language models (LLMs) to work independently of cloud services. Highlights 1) Structured programming with AI 2) Debugging 3) Unit testing 4) Refactoring 5) Automatic document creation 6) Database development and design 7) Scripting and administration 8) Local large language models (LLMs) 9) Retrieval-augmented generation (RAG) 10) ChatGPT and GitHub Copilot 11) OpenHands 12) OpenAI API

Format PDF
Size 3.1 MB
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
(This page has no text content)
Page 2
Rheinwerk Computing The Rheinwerk Computing series offers new and established professionals comprehen- sive guidance to enrich their skillsets and enhance their career prospects. Our publica- tions are written by the leading experts in their fields. Each book is detailed and hands-on to help readers develop essential, practical skills that they can apply to their daily work. Explore more of the Rheinwerk Computing library! Michael Kofler Scripting: Automation with Bash, PowerShell, and Python 2024, 470 pages, paperback and e-book www.rheinwerk-computing.com/5851 Metin Karatas Developing AI Applications: An Introduction 2024, 402 pages, paperback and e-book www.rheinwerk-computing.com/5899 Philip Ackermann Full Stack Web Development: The Comprehensive Guide 2023, 740 pages, paperback and e-book www.rheinwerk-computing.com/5704 Bernd Öggl, Michael Kofler Git: Project Management for Developers and DevOps Teams 2023, 407 pages, paperback and e-book www.rheinwerk-computing.com/5555 Bernd Öggl, Michael Kofler Docker: Practical Guide for Developers and DevOps Teams 2023, 491 pages, paperback and e-book www.rheinwerk-computing.com/5650 www.rheinwerk-computing.com
Page 3
Michael Kofler, Bernd Öggl, Sebastian Springer AI-Assisted Coding The Practical Guide for Software Development
Page 4
Imprint This e-book is a publication many contributed to, specifically: Editor Megan Fuerst Acquisitions Editor Hareem Shafi German Edition Editor Christoph Meister Translation Winema Language Services, Inc. Copyeditor Julie McNamee Cover Design Graham Geary Photo Credit Midjourney.com; Shutterstock: 1740319322/© Iurii Motov Layout Design Vera Brauner Production E-Book Kelly O’Callaghan Typesetting E-Book SatzPro, Germany We hope that you liked this e-book. Please share your feedback with us and read the Service Pages to find out how to contact us. Library of Congress Cataloging-in-Publication Control Number: 2024057967 ISBN 978-1-4932-2693-1 (print) ISBN 978-1-4932-2694-8 (e-book) ISBN 978-1-4932-2695-5 (print and e-book) 1st edition 2025 1st German edition published 2025 by Rheinwerk Verlag © 2025 by: Rheinwerk Publishing, Inc. 2 Heritage Drive, Suite 305 Quincy, MA 02171 USA info@rheinwerk-publishing.com +1.781.228.5070 Represented in the E.U. by: Rheinwerk Verlag GmbH Rheinwerkallee 4 53227 Bonn Germany service@rheinwerk-verlag.de +49 (0) 228 42150-0
Page 5
(This page has no text content)
Page 6
Contents Preface ....................................................................................................................................................... 17 PART I Coding with AI Support 1 Introduction 25 1.1 Coding via Chat ...................................................................................................................... 25 1.1.1 Password Generator .............................................................................................. 25 1.1.2 Python: Searching and Replacing Dates ......................................................... 26 1.1.3 SQL: Analysis of a Table ........................................................................................ 28 1.1.4 PHP: Bearer Token Authentication ................................................................... 30 1.1.5 Porting a Bash Script for PowerShell ................................................................ 31 1.1.6 Paid ChatGPT Offers .............................................................................................. 33 1.1.7 Anthropic Claude .................................................................................................... 33 1.2 The Art of Prompting ........................................................................................................... 34 1.2.1 Prompt Frameworks ............................................................................................. 37 1.2.2 A Question of Context .......................................................................................... 37 1.2.3 Custom GPTs ............................................................................................................ 39 1.2.4 Comparing Custom GPTs, Fine-Tuning, and Retrieval-Augmented Generation .................................................................... 40 1.3 Code Wizards ........................................................................................................................... 41 1.3.1 Installing GitHub Copilot ..................................................................................... 43 1.3.2 First Steps with Visual Studio Code and GitHub Copilot .......................... 43 1.3.3 Switching between Code Suggestions ............................................................ 44 1.3.4 Tips and Tricks ......................................................................................................... 45 1.3.5 Chat Mode with Additional Keywords ............................................................ 46 1.3.6 Chat Examples ......................................................................................................... 48 1.3.7 Alternatives to the Chat Sidebar ....................................................................... 49 1.3.8 Other Functions ...................................................................................................... 50 1.3.9 Security and Data Protection .............................................................................. 51 1.3.10 Trouble in Remote Mode ..................................................................................... 51 1.4 Chat or Wizard? ...................................................................................................................... 52 1.5 Basic Principles of Large Language Models ............................................................... 53 1.5.1 From the Human Brain to Neural Networks ................................................. 53 1.5.2 Machine Learning through Backpropagation ............................................... 547
Page 7
Contents1.5.3 Large Language Models ........................................................................................ 55 1.5.4 The Transformer Model ........................................................................................ 57 1.5.5 Generative Pretrained Transformer (GPT) .................................................... 58 1.5.6 Training: From Training Material to Language Model ............................... 59 1.5.7 Large Language Model Application: From Prompt to Response ............. 60 1.5.8 The Limits of Linguistic “Intelligence” ............................................................. 62 1.5.9 The Size of the Context Window ....................................................................... 63 1.5.10 The Fill-in-the-Middle Approach ....................................................................... 65 2 Pair Programming 67 2.1 Structuring Code into Functions ..................................................................................... 68 2.1.1 Defining Functions Yourself ............................................................................... 68 2.1.2 Defining Functions and Parameters ................................................................ 69 2.1.3 Detailed Questions about Functions and Parameters ............................... 71 2.1.4 Code Optimization ................................................................................................. 73 2.1.5 Code Reuse ............................................................................................................... 74 2.1.6 Splitting Code across Multiple Files ................................................................. 75 2.2 Example: IBAN Validation ................................................................................................. 76 2.2.1 Start ............................................................................................................................ 77 2.2.2 Checking the IBAN Length ................................................................................... 78 2.2.3 Troubleshooting ..................................................................................................... 78 2.2.4 Test .............................................................................................................................. 79 2.2.5 Removing Spaces from the IBAN ....................................................................... 80 2.2.6 Checksum Test ........................................................................................................ 81 2.2.7 Trouble with the Test Data ................................................................................. 82 2.2.8 Code Optimization ................................................................................................. 83 2.3 Object-Oriented Programming ....................................................................................... 83 2.3.1 Example: User Account Class ............................................................................. 84 2.3.2 Output of the Object ............................................................................................. 86 2.3.3 JSON Export and Constructor ............................................................................. 86 2.3.4 Example: Bank Account ........................................................................................ 87 2.3.5 Example: Sorting Photos Based on EXIF Data ............................................... 89 2.3.6 Example: Dealing with Singletons ................................................................... 90 2.4 Example: Quiz ......................................................................................................................... 91 2.4.1 Class Design ............................................................................................................. 91 2.4.2 Implementing the Question Class .................................................................... 93 2.4.3 A Pool of Questions for Testing ......................................................................... 94 2.4.4 Methods for the Question Class ........................................................................ 948
Page 8
Contents2.4.5 UML Diagram ........................................................................................................... 95 2.4.6 AI Bot or Code Wizard? ......................................................................................... 97 2.5 Example: Solving Sudoku .................................................................................................. 97 2.5.1 Class Setup ............................................................................................................... 97 2.5.2 Detaching Individual Fields in Rows ................................................................ 99 2.5.3 Solving Individual Fields in Columns and in Blocks .................................... 100 2.5.4 Test Code and Issues with the Test Data ....................................................... 101 2.5.5 Brainstorming .......................................................................................................... 101 2.5.6 Storing Solution Candidates per Field ............................................................. 102 2.5.7 Filling in Fields Where Only One Solution Number Is Possible ............... 103 2.5.8 Personal Conclusion .............................................................................................. 104 2.5.9 Alternative Procedure ........................................................................................... 105 2.5.10 Prompting Correctly .............................................................................................. 106 3 Debugging 107 3.1 Web Applications .................................................................................................................. 108 3.1.1 CSS Fixes .................................................................................................................... 108 3.1.2 iCal Download in the Browser ............................................................................ 110 3.1.3 Backend Frontend without a Proxy Server ..................................................... 111 3.1.4 JavaScript Fetch with the Wrong Content Type ........................................... 113 3.1.5 JamGPT ...................................................................................................................... 114 3.2 App Development ................................................................................................................. 116 3.2.1 Flutter and Null Safety Values ........................................................................... 116 3.2.2 Layouts in Flutter .................................................................................................... 117 3.3 Developing on Raspberry Pi .............................................................................................. 119 3.3.1 Step-by-Step Debugging on a Raspberry Pi ................................................... 120 3.3.2 Help for Creating Log Entries .............................................................................. 121 3.4 Visual Studio and Visual Studio Code .......................................................................... 122 3.4.1 Missing Python Modules in VS Code ............................................................... 123 3.4.2 Visual Studio Exception Debugging ................................................................. 123 3.5 Conclusion ................................................................................................................................ 125 4 Refactoring 127 4.1 Introduction to Refactoring .............................................................................................. 127 4.1.1 Objectives of Refactoring ..................................................................................... 1289
Page 9
Contents4.2 Refactoring Using AI Tools ................................................................................................ 128 4.2.1 Recognizing the Need for Refactoring ............................................................ 128 4.3 Best Practices ........................................................................................................................... 141 4.3.1 Only the Internal Structure May Be Changed ............................................... 141 4.3.2 Small-Step Approach ............................................................................................. 141 4.3.3 Test-Driven Refactoring ....................................................................................... 142 4.3.4 Defining Clear Goals .............................................................................................. 142 4.4 Conclusion ................................................................................................................................ 142 5 Testing Software 145 5.1 Generating Test Data ........................................................................................................... 146 5.2 AI-Supported Test Automation ....................................................................................... 149 5.2.1 Creating AI-Supported Unit Tests ..................................................................... 150 5.3 Test-Driven Development with AI ................................................................................. 155 5.3.1 Implementing the First Test ............................................................................... 155 5.3.2 The Second Test ...................................................................................................... 157 5.3.3 The Third Test .......................................................................................................... 158 5.3.4 Generating Test Data ............................................................................................ 160 5.4 Using Dependencies ............................................................................................................. 161 5.5 Optimizing Tests .................................................................................................................... 167 5.5.1 Optimizing Test Code ............................................................................................ 167 5.5.2 Writing Missing Tests ........................................................................................... 171 5.6 End-to-End Tests .................................................................................................................... 174 5.6.1 Generating an End-to-End Test ......................................................................... 175 5.6.2 Creating a Page Object ......................................................................................... 176 5.7 Conclusion ................................................................................................................................ 178 6 Documenting Software 179 6.1 Challenges with Documentation .................................................................................... 180 6.2 Inline Documentation ......................................................................................................... 181 6.2.1 Sample Inline Documentation ........................................................................... 181 6.3 Function and Class Documentation .............................................................................. 184 6.3.1 Benefits and Drawbacks of Function and Class Documentation ........... 18410
Page 10
Contents6.3.2 Sample Function and Class Documentation ................................................. 185 6.4 API Documentation .............................................................................................................. 187 6.4.1 Sample API Documentation ................................................................................ 188 6.5 Outdated Documentation ................................................................................................. 191 6.6 Conclusion ................................................................................................................................ 194 7 Databases 195 7.1 Database Design .................................................................................................................... 195 7.1.1 Example: Database for an Online Store .......................................................... 196 7.1.2 Database Management System Selection ..................................................... 200 7.1.3 Example: Cloud Shopping List ............................................................................ 201 7.1.4 Changing the Database Schema ....................................................................... 203 7.2 SQL Commands ....................................................................................................................... 205 7.2.1 Date Calculation ..................................................................................................... 205 7.2.2 Troubleshooting ..................................................................................................... 206 7.2.3 WordPress Image Search ..................................................................................... 207 7.2.4 Complex Query with Subquery or Self Join ................................................... 209 7.2.5 Formatting an SQL Command ........................................................................... 211 7.3 Administration ........................................................................................................................ 213 7.3.1 PostgreSQL: User Administration ..................................................................... 213 7.3.2 SQL Server: Automated Backup ......................................................................... 214 7.3.3 Determining the Schema of a Database ........................................................ 216 7.3.4 MariaDB Tuning ...................................................................................................... 218 7.4 Client Programming ............................................................................................................. 219 8 Scripting and System Administration 221 8.1 Scripting ..................................................................................................................................... 221 8.1.1 Bash: Loop Over a Text File .................................................................................. 222 8.1.2 PowerShell: Sorting Photos ................................................................................. 222 8.1.3 Python: SQLite Application .................................................................................. 224 8.1.4 Bash Troubleshooting ........................................................................................... 226 8.1.5 Python: Recursive Search for Files .................................................................... 227 8.1.6 Other Prompt Examples ....................................................................................... 22711
Page 11
Contents8.2 Example: Converting a Python Script to PHP Code ................................................ 228 8.2.1 Conclusion ................................................................................................................ 229 8.3 Regular Expressions .............................................................................................................. 230 8.3.1 Searching and Replacing Dates ......................................................................... 231 8.3.2 File Search Using grep ........................................................................................... 232 8.4 System Administration ....................................................................................................... 234 8.4.1 SSH Authentication by Key ................................................................................. 234 8.4.2 Docker Setup ............................................................................................................ 235 8.4.3 Proxy Server .............................................................................................................. 236 8.4.4 Fixing Network Issues in a Virtual Machine with a Web Server ............. 238 8.4.5 Linux Server Setup .................................................................................................. 239 8.4.6 Additional Prompts ................................................................................................ 240 8.5 Example: “wget” Script Plus “tmpfs” Configuration ............................................ 240 8.5.1 Developing a “wget” Script ................................................................................. 241 8.5.2 Linux Server Configuration with “tmpfs” ...................................................... 243 8.5.3 Conclusion ................................................................................................................ 244 8.6 Calling GitHub Copilot and ChatGPT in the Terminal ........................................... 245 8.6.1 GitHub Command-Line Interface (“gh”) ......................................................... 245 8.6.2 Shell-GPT (“sgpt”) ................................................................................................... 246 8.6.3 Using Language Models in the Terminal (“llm”) .......................................... 247 PART II Local Language Models and Advanced AI Tools 9 Executing Language Models Locally 253 9.1 Spoiled for Choice of Large Language Model ............................................................ 254 9.1.1 Which Models Solve Which Problems? ........................................................... 254 9.1.2 Hardware Requirements ...................................................................................... 256 9.1.3 Alternatives to the Local Execution of Models ............................................. 257 9.2 GPT4All ....................................................................................................................................... 259 9.2.1 Installation and Use ............................................................................................... 259 9.2.2 Chat with Your Files ............................................................................................... 261 9.2.3 Conclusion ................................................................................................................ 262 9.3 Ollama ........................................................................................................................................ 262 9.3.1 Benefits of Ollama ................................................................................................. 262 9.3.2 General Structure of Ollama ............................................................................... 26312
Page 12
Contents9.3.3 Local Installation and Execution ....................................................................... 264 9.3.4 Running Ollama in a Docker Container .......................................................... 266 9.4 Open WebUI for Ollama ..................................................................................................... 267 9.4.1 Installing Open WebUI ......................................................................................... 268 9.4.2 Using Custom Documents in Open WebUI ................................................... 270 9.4.3 Custom Workspace Models ................................................................................ 271 9.5 Continue .................................................................................................................................... 275 9.5.1 Installation ................................................................................................................ 275 9.5.2 Usage .......................................................................................................................... 276 9.6 Ollama API ................................................................................................................................ 277 9.6.1 Ollama REST API ...................................................................................................... 278 9.6.2 Libraries for Accessing the Ollama API ............................................................ 280 9.7 Tabby ........................................................................................................................................... 280 9.7.1 Installing the Tabby Server and the Plug-In .................................................. 281 9.7.2 Usage .......................................................................................................................... 281 9.8 Conclusion ................................................................................................................................ 282 10 Automated Code Processing 285 10.1 OpenAI API ................................................................................................................................ 286 10.1.1 Setting Up an API Account .................................................................................. 286 10.1.2 Hello, World! ............................................................................................................ 287 10.1.3 Formulating the Prompt ...................................................................................... 289 10.1.4 Chat System ............................................................................................................. 291 10.1.5 Processing the Response ...................................................................................... 293 10.1.6 Uploading and Downloading Files ................................................................... 294 10.1.7 Uploads for Special Applications ....................................................................... 296 10.1.8 Playground ................................................................................................................ 296 10.2 Ollama API ................................................................................................................................ 297 10.2.1 Manipulating Code ................................................................................................ 298 10.3 Groq API ..................................................................................................................................... 299 10.4 Example: Automated Commenting of Code ............................................................. 301 10.4.1 Real-Life Experience ............................................................................................... 303 10.4.2 Extracting Code from the Response ................................................................. 304 10.4.3 Genuine Errors ......................................................................................................... 305 10.4.4 Trouble with Large Code Files ............................................................................ 306 10.4.5 Translating Existing Comments ........................................................................ 307 10.4.6 Conclusion ................................................................................................................ 30813
Page 13
Contents10.5 Example: From Python 2 to Python 3 ........................................................................... 308 10.5.1 Real-Life Experience ............................................................................................... 309 11 Level 3 Tools: OpenHands and Aider 313 11.1 OpenHands ............................................................................................................................... 314 11.1.1 Installation ................................................................................................................ 316 11.1.2 The Web Interface .................................................................................................. 317 11.2 Using OpenHands .................................................................................................................. 320 11.2.1 Not Too Much at Once! ........................................................................................ 322 11.2.2 Conclusion ................................................................................................................ 323 11.3 Aider ............................................................................................................................................ 323 11.3.1 Installation ................................................................................................................ 324 11.3.2 Start ............................................................................................................................ 325 11.3.3 Aider Commands .................................................................................................... 325 11.3.4 Multiline Prompts .................................................................................................. 327 11.3.5 Coding Rules and Conventions .......................................................................... 327 11.3.6 Aider in the Web Browser .................................................................................... 327 11.4 Using Aider ............................................................................................................................... 328 11.4.1 Example 1: Sorting Photos .................................................................................. 328 11.4.2 Example 2: Web Scraping .................................................................................... 332 11.4.3 Example 3: Implementing Changes in a Large Project .............................. 334 11.4.4 More Prompting Examples and Video Tips ................................................... 335 12 Retrieval-Augmented Generation and Text-to-SQL 337 12.1 RAG Quick Start ...................................................................................................................... 338 12.2 The Viel-Falter (Many Butterflies) Project .................................................................. 341 12.3 Loading Documents .............................................................................................................. 343 12.3.1 SimpleDirectoryReader and SimpleWebPageReader ................................. 344 12.4 Creating an Index .................................................................................................................. 345 12.4.1 The Embedding Model .......................................................................................... 346 12.5 Vector Store Databases ...................................................................................................... 348 12.6 RAG Queries ............................................................................................................................. 351 12.6.1 Source Code .............................................................................................................. 35214
Page 14
Contents12.6.2 Conclusion ................................................................................................................ 355 12.7 Text-to-SQL .............................................................................................................................. 355 12.7.1 Database Export from MongoDB to SQLite ................................................... 356 12.7.2 Text-to-SQL with LlamaIndex ............................................................................. 360 12.7.3 Sample Queries ....................................................................................................... 361 12.7.4 Conclusion ................................................................................................................ 366 13 Risks and Outlook 367 13.1 Issues and Limitations of Using AI Tools ..................................................................... 367 13.1.1 Old, Cumbersome Code ....................................................................................... 368 13.1.2 The Question of Maintainability ....................................................................... 368 13.1.3 Privacy ........................................................................................................................ 368 13.1.4 A New Kind of Dependency ................................................................................ 369 13.1.5 Learning to Program in the Age of AI ............................................................... 370 13.2 Exemplary AI Failure ............................................................................................................ 370 13.2.1 Outdated Information .......................................................................................... 370 13.2.2 Hallucinations ......................................................................................................... 372 13.2.3 Logic Errors ............................................................................................................... 373 13.2.4 Security Issues ......................................................................................................... 375 13.2.5 Less Than Ideal Solutions ..................................................................................... 379 13.3 Ethical Issues ............................................................................................................................ 381 13.3.1 The Origin of AI Knowledge ................................................................................ 381 13.3.2 Jobless IT Experts .................................................................................................... 383 13.3.3 Unlimited Energy Consumption ........................................................................ 383 13.4 Conclusions and Outlook ................................................................................................... 384 13.4.1 Better Results with More Prior Knowledge and Experience .................... 384 13.4.2 Cloud or Local AI? ................................................................................................... 385 13.4.3 Quality Enhancement through Training with AI-Generated Code ........ 386 13.4.4 The Coming Few Years .......................................................................................... 386 13.4.5 Conclusion ................................................................................................................ 387 The Authors ............................................................................................................................................. 389 Index .......................................................................................................................................................... 391 Service Pages ...............................................................................................................................................  I Legal Notes ...................................................................................................................................................  II 15
Page 15
(This page has no text content)
Page 16
Preface You’ve almost certainly already asked ChatGPT or another artificial intelligence (AI) tool a coding question and saw the tool spit out (seemingly) perfect code within sec- onds. This book explores the potential and limitations of AI tools in software development. Let’s start with the positives. We’ll show you that ChatGPT, GitHub Copilot, and others can do more than just generate a few lines of code. You can also use them to create unit tests, search for errors, perform refactoring tasks, develop database schemas, optimize SQL queries, administer servers, and write scripts. But the brave new AI world also has its downsides. Even if the code looks plausible and the accompanying text is elegantly formulated, some AI suggestions are simply wrong due to logic errors, the use of nonexistent functions, or references to variables whose names are actually different. Although the code does work sometimes, it’s inefficient or insecure. AI tools make mistakes—that much can’t be disputed. Used correctly, however, these new tools can also save you a lot of time. That’s what this book is all about. Local Execution of Language Models Companies in particular often have problems entrusting their code base to tools that run in the cloud. Even if AI providers promise not to use your code for the training of future language models in company offers, the question arises as to how far you can trust these promises and whether data protection problems may arise. The easiest way out is to run the language models required for AI tools locally. You can’t download the large language model (LLM) from ChatGPT, but various alternatives are available free of charge that work similarly well. However, the local execution of LLMs consumes a lot of resources, so only powerful notebook computers or PCs are suitable for this. New CPUs with neural processing units (NPUs) promise new possibilities in this respect. However, a real benefit for the local execution of LLMs only arises in combination with suitable software—and there is still a lot to be done. There is one more option: you can set up your own server in your company or in a data center that is available to all employees for AI tasks. In that case, “local” doesn’t refer to your own notebook computer, but to a company-owned computer. In this book, we’ll show you how you can use local language models and even optimize them with your own training material.17Personal Copy for Luis Fernando de Paula, wemeke5983@elygifts.com
Page 17
PrefaceWe’ll also present the GPT4All, Ollama, and Tabby programs to run free LLMs locally. You can then use the local language models in chat mode for coding (e.g., by using the Continue editor plug-in) or via an application programming interface (API) to develop your own AI applications. Coding with AI Support for Advanced Users If you’ve asked ChatGPT for advice on a coding problem or if you’ve followed sugges- tions from GitHub Copilot (or a similar tool), then you know about interactive AI support for coding. But there’s more to it! You can go one step further by using the appropriate libraries: Processing many code files automatically You want to change all comments in 100 files from German to English? You want to migrate a project from Python 2 to Python 3? Instead of interactively processing file by file, couldn't you write a script that automates this task? We’ve tried it out and will share our experiences with you. Level 3 tools Similar to self-driving cars, there are also categories of autonomy for AI coding tools. ChatGPT, Claude, GitHub Copilot, and other tools are assigned to levels 1 and 2 depending on their application (code completion or code creation). However, the first level 3 tools (supervised automation) already exist that go beyond this and inde- pendently generate or modify code files according to your instructions. We experi- mented with OpenHands and Aider, and we were particularly enthusiastic about the Aider concept. Retrieval-augmented generation (RAG) It’s currently impossible for private users or small businesses to train their own lan- guage models. By using RAG, however, you can add your own data to language mod- els. This results in a host of additional application options, including the integration of daily updated data or the automated conversion of text prompts into SQL queries. In this chapter, we focus primarily on the LlamaIndex library. Theoretically, the tools outlined here represent the next development step in the use of AI in coding. In real life, however, our experiences have been mixed. Not everything worked out as we had hoped. AI is already able to perform some of these tasks, but for more complicated requests, patience is still required until these tools become suitable for everyday use.18 © 2025 by Rheinwerk Publishing Inc., Boston (MA)
Page 18
PrefaceAI Makes Mistakes and Hallucinates If you talk to other developers, you’ll hear many anecdotes about the major mistakes AI tools have made recently. There are also many chapters in this book in which we show examples with faulty AI code, incorrect conclusions, or simply invented functions or options. (Invented functions have to do with an unpleasant feature of current language models: If AI can’t give a reliable answer due to insufficient training material, it invents a text that sounds as plausible as possible—that is, AI “hallucinates.”) Depending on how you use AI tools, the error rate varies between rather low (wide- spread programming languages, everyday problems) and quite high (exotic languages, new libraries/APIs, very specific tasks). The biggest problem isn’t that mistakes happen. We all know that people also make mistakes, probably even more often. What is annoy- ing is that AI tools argue even the biggest nonsense politely and at a pretty high linguis- tic level. That’s what makes it so difficult to tell the right answers from the wrong ones. In our view, AI tools will only be truly “intelligent” when they answer: “I don't know" or “I’m not sure about this proposed solution, but it could work like this.” We aren’t that far yet in early 2025, even if there are efforts to show how the answers can be derived. As you can see, we aren’t trying to sell you an AI tool! On the contrary, we point out the issues we’ve encountered in all chapters, especially in Chapter 13. The Three Stages of Using AI While writing this book, we not only worked intensively with AI tools ourselves but also spoke to many other developers. Through this, we’ve recognized a pattern in the use of AI tools in coding. It corresponds fairly closely to the hype cycle, a model coined by consultant Jackie Fenn to describe how new technologies are perceived and used (see Figure 1): Euphoria The first experiments will leave you, like most developers, speechless with enthusi- asm. This “thing” understands your questions, gives answers that make sense, and even explains the code. That’s crazy! Disillusionment Then, the moment arrives when the AI tool of your choice makes its first mistakes. It’s no longer about Hello World functions, but about real, complex code. The AI tool explains the world to you with the utmost confidence, and you realize that the explanations are convincing in terms of language, but completely wrong in terms of content. You might conclude here that AI tools are useless, their use irresponsible, and so on.19Personal Copy for Luis Fernando de Paula, wemeke5983@elygifts.com
Page 19
0 Preface Pragmatic use After a few weeks, you’ll develop a good feeling for when AI results are most likely correct and where you need to make improvements. You’re getting better and better at assessing the limits. What remains is a tool that makes mistakes, but is still a real help within the scope of its capabilities. You question every AI answer and reckon with an error rate of perhaps 10%. But you use what works—and that’s quite a lot. Figure 1 AI Tools Currently in the Stages of the Hype Cycle There’s No Getting around AI Tools Despite all the problems, we’re convinced that AI tools are here to stay. According to one study (https://www.atlassian.com/software/compass/resources/state-of-developer-2024), managers believe that the time-saving factor is huge, while developers who actually use AI tools are much more cautious (and realistic) about the benefits! The extent of the efficiency gain depends heavily on the type of code you develop. But there is always a certain amount of time saved and a higher level of convenience at work. Regardless of whether you see the glass as half full or half empty, coding using AI support increases your efficiency today and will increase it even more tomorrow. Chemist Derek Lowe put it this way in February 2023: I don’t think AI and automation will replace chemists, but rather that the human chemists who use them well will replace the ones who don’t. We’re convinced that this statement, which has often been quoted since, also applies to the IT world. AI therefore won’t replace software developers, at least not in the near future. But developers who use AI tools in a reasonable way will replace their colleagues who do not. Visibility Time Peak of Inflated Expectations Plateau of Productivity Slope of Enlightenment Trough of Disillusionment Technology Trigger20 © 2025 by Rheinwerk Publishing Inc., Boston (MA)
Page 20
There’s No Getting around AI ToolsNow is the right time to get to grips with AI tools! Yes, AI tools will become even better in the coming years, but the potential is already huge. And the knowledge and experi- ence you gain today will help you better understand new AI technologies tomorrow and integrate them more quickly into your day-to-day work. According to the 2024 Developer Survey (https://survey.stackoverflow.co/2024/ai), 63% of all developers already use AI tools. An additional 13% are planning to use them in the near future. We’re clearly at the beginning of a new era in terms of software develop- ment. Despite all the fears associated with such far-reaching changes, we’ve found the use of AI tools in our day-to-day coding work very satisfying. AI tools haven’t done the thinking for us, but they have done a lot of boring typing. The concepts of the software we developed still came from us, but the often-tedious work of implementation has become easier for us. With this in mind, we hope you enjoy reading this book. Be inspired by our examples, and look for ways to integrate AI tools into your day-to-day work in a meaningful way. Take advantage of the opportunities that arise here! Michael Kofler (https://kofler.info) Bernd Öggl (https://webman.at) Sebastian Springer (https://sebastian-springer.com) PS: This book deals exclusively with the use of AI tools for software development and administration. Clearly, the new developments in the AI sector will have a wide- ranging impact on society, both positive and negative. However, this isn’t a topic in this book, nor is the use of AI tools outside of IT. Sample Files There are sample files for a few chapters of this book, which you can download here: www.rheinwerk-computing.com/6058.21Personal Copy for Luis Fernando de Paula, wemeke5983@elygifts.com
The above is a preview of the first 20 pages. Register to read the complete e-book.

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
← Back to List