19,99 €
Boost your coding output and accuracy with artificial intelligence tools
Coding with AI For Dummies introduces you to the many ways that artificial intelligence can make your life as a coder easier. Even if you’re brand new to using AI, this book will show you around the new tools that can produce, examine, and fix code for you. With AI, you can automate processes like code documentation, debugging, updating, and optimization. The time saved thanks to AI lets you focus on the core development tasks that make you even more valuable. Learn the secrets behind coding assistant platforms and get step-by-step instructions on how to implement them to make coding a smoother process. Thanks to AI and this Dummies guide, you’ll be coding faster and better in no time.
This is a great Dummies guide for new and experienced programmers alike. Get started with AI coding and expand your programming toolkit with Coding with AI For Dummies.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 362
Veröffentlichungsjahr: 2024
Cover
Title Page
Copyright
Introduction
About This Book
Foolish Assumptions
Icons Used in This Book
Beyond the Book
Where to Go from Here
Part 1: Techniques and Technologies
Chapter 1: How Coding Benefits from AI
Banishing Boring Tasks
Helping with Syntax
Linting with AI
Using AI as a Tutor
Pairing Up with AI
Chapter 2: Parsing Machine Learning and Deep Learning
Decoding Machine and Deep Learning
Demystifying Natural-Language Processing
Understanding Transformers
Illuminating Generative AI Models
Recognizing AI’s Limitations
Chapter 3: AI Coding Tools
Navigating GitHub Copilot
Exploring Tabnine
Reviewing Replit
Chapter 4: Coding with Chatbots
Improving Your Prompts
Chatting with Copilot
Chatting with ChatGPT
Diving into the OpenAI Platform
Developing a Chatbot with OpenAI
Part 2: Using AI to Write Code
Chapter 5: Progressing from Plan to Prototype
Understanding Project Requirements
Generating Code from an SRS
Blending Manually Written and AI-Generated Code
Tips and Tricks for Code Generation
Chapter 6: Formatting and Improving Your Code
Using AI Tools for Code Formatting
Refactoring with AI
Generating Refactoring Suggestions
Chapter 7: Finding and Eliminating Bugs
Knowing Your Bugs
Preventing Bugs with Linting
Detecting Bugs with AI
Automating Bug Fixes with AI
Chapter 8: Translating and Optimizing Code
Translating Code to Other Languages
Optimizing Your Code with AI
Part 3: Testing, Documenting, and Maintaining Your Code
Chapter 9: Testing Your Code
Writing a Test Plan
Working with a Testing Framework
Test-Driven Development with AI
Chapter 10: Documenting Your Code
Working with Documentation Bots
Generating Code Comments and Annotations
Creating Visual Documentation
Automating API Documentation with AI
Chapter 11: Maintaining Your Code
Knowing the Four Types of Maintenance
Utilizing AI for Code Maintenance
Enhancing Code Quality with AI
Part 4: The Part of Tens
Chapter 12: Ten More Tools to Try
Amazon CodeWhisperer
Sourcegraph Cody
DeepMind AlphaCode
Google Bard
Codeium
Claude
Microsoft IntelliCode
Sourcery
Bugasura
UserWay
Chapter 13: Ten AI Coding Resources
Code.org
's AI Resources
Kaggle
Google's Dataset Search
edX
Edabit
StatQuest
AI4All Open Learning
Gymnasium
fast.ai
Microsoft Learn
Index
About the Author
Connect with Dummies
End User License Agreement
Chapter 2
TABLE 2-1: Token Limits
TABLE 2-2: Parameters in Generative AI Models
Chapter 3
TABLE 3-1: Copilot Keyboard Shortcuts
Chapter 1
FIGURE 1-1: A ChatGPT-generated HTML template.
FIGURE 1-2: Bing refused to generate CRUD.
FIGURE 1-3: Adding context to get a better response.
FIGURE 1-4: Running my Node.js application.
FIGURE 1-5: Viewing the collection's contents in MongoDB.
FIGURE 1-6: Code completion is often helpful.
FIGURE 1-7: Copilot’s suggested phone number validation function.
FIGURE 1-8: GenAI models do better when given context.
FIGURE 1-9: Getting syntax support from Copilot.
FIGURE 1-10: GPT-3 doesn't know about recent additions to JavaScript.
FIGURE 1-11: GPT-4 generates a correct answer when asked about new syntax.
FIGURE 1-12: ChatGPT is usually correct about programming language syntax basic...
FIGURE 1-13: Using Bard as a linter.
FIGURE 1-14: Searching for the Copilot extension.
FIGURE 1-15: Viewing the Copilot menu and multiple suggestion options.
FIGURE 1-16: A somewhat functional trivia game.
Chapter 2
FIGURE 2-1: The relationship between fields in AI.
FIGURE 2-2: Nodes are arranged in layers.
FIGURE 2-3: A color image containing 3,136 pixels requires a 9,408-neuron input...
FIGURE 2-4: Is it a hot dog?
FIGURE 2-5: Many pictures of hot dogs have similar characteristics.
FIGURE 2-6: Early NLP was based on rules.
FIGURE 2-7: An example of an Alice chatbot.
FIGURE 2-8: Visualizing self-attention.
FIGURE 2-9: Tokenizing a prompt.
FIGURE 2-10: Tokens are represented as token IDs.
FIGURE 2-11: GPT-4 gets an addition problem wrong.
FIGURE 2-12: ChatGPT uses 200 words where 2 will do.
Chapter 3
FIGURE 3-1: The Copilot status icon in connected and disconnected mode.
FIGURE 3-2: Click the Accounts icon to grant Copilot access to your GitHub acco...
FIGURE 3-3: The Extension Settings screen for Copilot.
FIGURE 3-4: Getting more suggestions.
FIGURE 3-5: Choosing the IDE where you want to install the Tabnine extension.
FIGURE 3-6: Tabnine Hub.
FIGURE 3-7: Viewing previous “magic moments.”
FIGURE 3-8: The Replit home page.
FIGURE 3-9: Coders can advertise and find gigs through Replit Bounties.
FIGURE 3-10: Get started quickly with a template.
FIGURE 3-11: A template's popularity is often a good indicator of its quality a...
FIGURE 3-12: Viewing more information about a template.
FIGURE 3-13: Your copy of the template in the Replit workspace.
FIGURE 3-14: Viewing the workspace tools panel.
FIGURE 3-15: Rearranging panes.
FIGURE 3-16: The AI tab opens in the right panel.
FIGURE 3-17: Generated HTML and CSS from Replit AI.
FIGURE 3-18: The start of my website for Grapefruit Pulp.
FIGURE 3-19: Replit AI's SVG punk grapefruit.
FIGURE 3-20: Prompting for a JavaScript photo gallery.
FIGURE 3-21: My Replit AI-generated lightbox.
Chapter 4
FIGURE 4-1: Asking ChatGPT to rhyme at 0.7 temperature.
FIGURE 4-2: Asking ChatGPT to get more creative.
FIGURE 4-3: Setting the temperature to 2.0 in ChatGPT.
FIGURE 4-4: What it looks like when the model gets too creative.
FIGURE 4-5: Few-shot programming gives examples and specifies the expected form...
FIGURE 4-6: The Copilot Chat plug-in.
FIGURE 4-7: The slash commands in Copilot.
FIGURE 4-8: Copilot correctly identifies the problem with my code and offers to...
FIGURE 4-9: Signing up for a ChatGPT account.
FIGURE 4-10: The ChatGPT UI.
FIGURE 4-11: Opening the Custom Instructions window.
FIGURE 4-12: The Custom Instruction window.
FIGURE 4-13: Viewing ChatGPT's suggestions for the context custom instructions.
FIGURE 4-14: Example text for the first custom instruction.
FIGURE 4-15: Viewing ChatGPT's suggestions for the output format custom instruc...
FIGURE 4-16: Custom instructions apply to all new chats.
FIGURE 4-17: The OpenAI playground.
FIGURE 4-18: Chat mode in the OpenAI playground.
FIGURE 4-19: The OpenAI Examples page.
FIGURE 4-20: Viewing one of OpenAI’s example prompts.
FIGURE 4-21: The View API Keys link.
FIGURE 4-22: Naming your secret key.
FIGURE 4-23: My first attempt at creating a chatbot with ChatGPT was a failure.
FIGURE 4-24: Testing my fixes.
Chapter 5
FIGURE 5-1: Asking ChatGPT to help write an SRS.
FIGURE 5-2: My answers to ChatGPT's questions.
FIGURE 5-3: A ChatGPT-generated SRS.
FIGURE 5-4: Converting to Markdown makes documents more usable.
FIGURE 5-5: The ChatGPT-generated tic-tac-toe game code.
FIGURE 5-6: A frustratingly difficult game of tic-tac-toe.
FIGURE 5-7: An AI tic-tac-toe bot in the OpenAI playground.
FIGURE 5-8: Node.js code to get the next completion from the OpenAI API.
FIGURE 5-9: Suggestions for testing the API server (left) and for handling API ...
FIGURE 5-10: My AI opponent loses track of its instructions.
FIGURE 5-11: Giving more context to the AI.
FIGURE 5-12: The AI doesn't remember the last command.
FIGURE 5-13: GPT-4 is no good at tic-tac-toe.
Chapter 6
FIGURE 6-1: Installing Prettier.
FIGURE 6-2: Enabling Prettier and automatic formatting.
FIGURE 6-3: A mess of unformatted code containing syntax errors.
FIGURE 6-4: Viewing problems Prettier discovered.
FIGURE 6-5: Asking Copilot to fix your code.
FIGURE 6-6: Copilot suggests fixes.
FIGURE 6-7: Copilot fixed the syntax errors.
FIGURE 6-8: Selecting files to compare.
FIGURE 6-9: The diff panel in VS Code.
FIGURE 6-10: Using Copilot Chat to review code.
FIGURE 6-11: Clearing the previous chat.
FIGURE 6-12: Copilot detected that my code lacks comments.
FIGURE 6-13: Copilot pointed out the inconsistent naming in the program.
FIGURE 6-14: Copilot's suggestion for refactoring the event listeners.
FIGURE 6-15: Copilot's suggestion for fixing the magic number.
FIGURE 6-16: The start of the solution to the global data.
FIGURE 6-17: Copilot seemed to write most of the code correctly.
FIGURE 6-18: Generating tips for making names consistent in the program.
FIGURE 6-19: Copilot Labs failed at its first documentation attempt.
Chapter 7
FIGURE 7-1: Reporting a bug with Jam.
FIGURE 7-2: Creating a bug report and opening a GitHub issue.
FIGURE 7-3: Debugging with Jam.
FIGURE 7-4: JamGPT offers to help you.
FIGURE 7-5: JamGPT suggests possible solutions.
FIGURE 7-6: ESLint reports on errors it found in your code.
FIGURE 7-7: The ESLint VS Code extension.
FIGURE 7-8: The ESLint extension highlights linting errors.
FIGURE 7-9: Some problems were fixable using
--fix
.
FIGURE 7-10: Viewing the Quick Fix link.
FIGURE 7-11: The Quick Fix options.
FIGURE 7-12: Copilot describes the problem and suggests a fix.
FIGURE 7-13: Copilot prompts you to accept or decline a change.
FIGURE 7-14: That's the last time I ask Copilot to fix something.
FIGURE 7-15: The rules property in .eslintrc.
FIGURE 7-16: Viewing the name and default severity of rules.
FIGURE 7-17: Adjusting a rule's severity.
FIGURE 7-18: Chrome’s JavaScript debugger.
FIGURE 7-19: Causing the
calculate_average()
function to raise an error.
FIGURE 7-20: Copilot fixed one issue.
FIGURE 7-21: The Snyk signup page.
FIGURE 7-22: Snyk's import and scan a project page.
FIGURE 7-23: Snyk shows bugs and prioritizes them by severity.
FIGURE 7-24: Snyk offers to open a PR.
FIGURE 7-25: Snyk opens a pull request for its recommended fixes.
FIGURE 7-26: The migration notes for version 9 of jsonwebtoken.
FIGURE 7-27: Snyk analyzes the code you wrote and reports issues.
FIGURE 7-28: A bug was detected in the tic-tac-toe game.
FIGURE 7-29: Snyk provides a potential fix.
Chapter 8
FIGURE 8-1: The JavaScript version of
makeUnorderedList()
running in the browse...
FIGURE 8-2: Testing the translated function.
FIGURE 8-3: Copilot's example code and the predicted result of running it.
FIGURE 8-4: Our first Nim program works great!
FIGURE 8-5: A web app for fetching GitHub repository names.
FIGURE 8-6: Setting up a translation request in OpenAI Playground.
FIGURE 8-7: The GitHub Repository Fetcher mobile app on iOS (left) and Android ...
FIGURE 8-8: Installing the Scalene VS Code extension.
FIGURE 8-9: Scalene's report for testme.py.
FIGURE 8-10: Opening the advanced options to input an API key.
FIGURE 8-11: Scalene's proposed optimization.
FIGURE 8-12: Profiling your optimized code.
Chapter 9
FIGURE 9-1: Copilot identified the functionalities of the tic-tac-toe game.
FIGURE 9-2: Copilot creates a list of test cases.
FIGURE 9-3: Jest responds that it couldn't find any tests.
FIGURE 9-4: Copilot generated tests for the
checkWin()
function.
FIGURE 9-5: Running the tests generated by Copilot.
FIGURE 9-6: The tests Copilot suggests for
checkDraw()
.
FIGURE 9-7: The result of running the tests for both
checkDraw()
and
checkWin()
FIGURE 9-8: A coverage report shows you how much of your code has been tested.
FIGURE 9-9: The test for
clearBoardDiplay()
passed.
FIGURE 9-10: Copilot can't seem to get it right.
FIGURE 9-11: Including a description in the prompt resulted in better tests!
FIGURE 9-12: The new tests failed, as expected.
FIGURE 9-13: With the function fixed, the tests pass.
FIGURE 9-14: As expected, my first tests failed.
FIGURE 9-15: Copilot told me how to get the test to pass.
FIGURE 9-16: Updating the game to pass the refactored test.
FIGURE 9-17: Copilot seems to be confused.
Chapter 10
FIGURE 10-1: Starting the new assistant creation process.
FIGURE 10-2: Starting a documentation assistant session.
FIGURE 10-3: My assistant didn't consult with the code files.
FIGURE 10-4: I'd give my assistant's first README a C+.
FIGURE 10-5: The Mintlify Doc Writer extension page.
FIGURE 10-6: The Mintlify Doc Writer panel.
FIGURE 10-7: Mintlify adds a code comment.
FIGURE 10-8: Each function of Underscore includes comments.
FIGURE 10-9: Generating a comment for Underscore (in the code window on the rig...
FIGURE 10-10: GPT-4 failed at annotating my screenshot.
FIGURE 10-11: The list of smart templates.
FIGURE 10-12: How to make an apple pie.
FIGURE 10-13: A first draft requirements diagram.
FIGURE 10-14: What happened here?
FIGURE 10-15: A close-up of several requirements in the diagram.
FIGURE 10-16: A Copilot-generated OAS file.
FIGURE 10-17: The ReadMe home page.
FIGURE 10-18: The Quickstart page with the OAS upload button.
FIGURE 10-19: The file upload screen in the Describe Your API window.
FIGURE 10-20: The Next Steps window.
FIGURE 10-21: The Get All Posts endpoint documentation.
FIGURE 10-22: Accessing your GPTs.
FIGURE 10-23: Filling out the form to configure a GPT.
FIGURE 10-24: Completing the GPT configuration.
FIGURE 10-25: The Chatbot accurately explained how to use the /user/signup endp...
Chapter 11
FIGURE 11-1: How much time developers spend doing each type of maintenance.
FIGURE 11-2: Code Climate's pricing page.
FIGURE 11-3: Join an organization or add a repository.
FIGURE 11-4: Code Climate has finished its initial report.
FIGURE 11-5: Code Climate's report on Soliloquy.
FIGURE 11-6: Code Climate's maintainability checks.
FIGURE 11-7: Code Climate says my repository has nine issues.
FIGURE 11-8: SignupPage.js is too long.
FIGURE 11-9: Clicking the ticket icon.
FIGURE 11-10: Code Climate creates a new issue.
FIGURE 11-11: Copilot has the right idea but goes down the wrong path.
FIGURE 11-12: Soliloquy is getting more maintainable!
FIGURE 11-13: Template code doesn't count, imho.
FIGURE 11-14: Copilot suggests creating an
InputField
component.
FIGURE 11-15: It feels good to be debt-free.
Chapter 12
FIGURE 12-1: Speak softly to CodeWhisperer.
FIGURE 12-2: Coding with Cody.
FIGURE 12-3: Solve puzzles with AlphaCode.
FIGURE 12-4: Make Bard sing your tune.
FIGURE 12-5: Craft code with Codeium.
FIGURE 12-6: Chat with Claude.
FIGURE 12-7: Tailor solutions with Microsoft IntelliCode.
FIGURE 12-8: Cast spells with Sourcery.
FIGURE 12-9: Squash bugs with Bugasura.
FIGURE 12-10: Unravel accessibility with UserWay.
Chapter 13
FIGURE 13-1: Dive into AI with
Code.org
's AI resources.
FIGURE 13-2: Compete intelligently with Kaggle.
FIGURE 13-3: Discover treasures with Google's Dataset Search.
FIGURE 13-4: Learn limitlessly with edX.
FIGURE 13-5: Solve puzzles with Edabit.
FIGURE 13-6: Demystify data with StatQuest.
FIGURE 13-7: Explore frontiers with AI4All Open Learning.
FIGURE 13-8: Exercise intelligence at Gymnasium.
FIGURE 13-9: Navigate neural networks with fast.ai.
FIGURE 13-10: Get certified with Microsoft Learn.
Cover
Table of Contents
Title Page
Copyright
Begin Reading
Index
About the Author
i
ii
1
2
3
4
5
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
299
300
301
302
303
304
305
306
307
308
309
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
Coding with AI For Dummies®
Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com
Copyright © 2024 by John Wiley & Sons, Inc., Hoboken, New Jersey
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE PUBLISHER AND AUTHORS HAVE USED THEIR BEST EFFORTS IN PREPARING THIS WORK, THEY MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES, WRITTEN SALES MATERIALS OR PROMOTIONAL STATEMENTS FOR THIS WORK. THE FACT THAT AN ORGANIZATION, WEBSITE, OR PRODUCT IS REFERRED TO IN THIS WORK AS A CITATION AND/OR POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE PUBLISHER AND AUTHORS ENDORSE THE INFORMATION OR SERVICES THE ORGANIZATION, WEBSITE, OR PRODUCT MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING PROFESSIONAL SERVICES. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR YOUR SITUATION. YOU SHOULD CONSULT WITH A SPECIALIST WHERE APPROPRIATE. FURTHER, READERS SHOULD BE AWARE THAT WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. NEITHER THE PUBLISHER NOR AUTHORS SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES.
For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit https://hub.wiley.com/community/support/dummies.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.
Library of Congress Control Number: 2024931771
ISBN: 978-1-394-24913-8 (pbk); 978-1-394-24915-2 (ebk); 978-1-394-24914-5 (ebk)
I started writing this book almost a year after OpenAI launched ChatGPT. That launch and the subsequent releases of generative AI tools by Microsoft, Google, Facebook, and others have begun to change how we think about creating content. At the same time, we're facing important questions about what the future of work will look like — especially for those of us whose job primarily involves the things that tools such as ChatGPT are pretty good at.
My own feelings about generative AI are mixed. On one hand, I worry that the skills in writing and programming that I've spent more than half my life working on will no longer be useful. On the other hand, I see that AI has the potential to take on some of the most boring and least rewarding work I do, saving me time and effort that I can devote to the more creative parts of writing and programming.
I also worry that when I do write things using old-fashioned methods (aka “I think of them and write them”), people will assume that I used AI. This happened with a book I wrote last year on a relatively current topic. People who didn't bother to read the book commented that “it was probably written by AI.” As a result of this experience, I announced that I'd livestream the process of writing my next book. I had no idea at the time that my next book would be about AI. So, here I am, writing a book about coding with AI while live-streaming my writing processes in an attempt to prove to future readers that the book wasn't generated by AI. If you have any doubt that I wrote this book the old-fashioned way, or if you have a few hundred hours to spare, you can see the entire book being written by going to https://bit.ly/codingwithai.
Even though I refuse to use AI to write my books, and I'm generally against other people using AI to write books, I feel differently about using AI tools to generate computer code. The history of computer programming has been about people inventing better tools that make coding easier. When I worked at Software Development Magazine in the 1990s, the technical editor was Roger Smith. One day, while we were talking about a new programming tool, Roger told me that he believed that in the future we'd be able to use natural language to write software. I was skeptical. Almost 30 years later, it turns out that Roger was right.
The pace of change in AI is fast. Technologies and tools that are new and interesting this month will be replaced by better ones next month. Because I write about technology and programming, there's always the risk that something I write today will be outdated when the book is released. However, even though AI and AI software development tools will certainly have improved, the techniques I write about here will be just as applicable — unless, of course, AI has made the profession of software developer obsolete and everyone who used to be a software developer now gets paid to hang out on the beach (or whatever your idea of relaxation and fun is).
Whether you embrace this new era of AI-assisted coding or resist it, there's no denying that it's here. In this book, I show you how these tools work and how you can use them to not only make writing code easier and faster but to help you write better code.
I hope you enjoy reading this book and that you find it useful. If you have any questions or comments, please reach out to me at [email protected].
When it comes to coding with generative AI, we're all dummies at this point. Whether you're a new programmer or a veteran, this book will teach you what you need to know to benefit from the new tools that are rapidly becoming available.
I cover these topics:
Understanding foundational principles of machine learning (ML), deep learning (DL), and generative AI (GenAI)
Working with AI responsibly, safely, and ethically
Using some of the latest tools for coding with AI
Using AI to help with
Automating monotonous coding tasks
Learning new skills
Improving your code
Testing your code
Documenting your code
Maintaining your code
As you go through the book, keep the following in mind:
You can read the book from beginning to end, but feel free to skip around if you like. If a topic interests you, start there. You can always return to previous chapters, if necessary.
At some point, you will get stuck, and something you try will not work as intended. Do not fear! There are many resources to help you, including support forums, others on the internet, AI chatbots, and me! You can contact me via email at
or through my website (
https://www.chrisminnick.com
). Additionally, you can sign up for my Substack (
https://chrisminnick.substack.com
) to receive occasional updates from me about AI, programming, and learning.
Code in the book appears in a monospaced font like this:
<h1>Hi there!</h1>.
Some web addresses break across two lines of text. If you’re reading this book in print and want to visit one of these web pages, simply key in the web address exactly as it’s noted in the text, pretending as though the line break doesn’t exist. If you’re reading this as an e-book, you have it easy — just click the web address to be taken directly to the web page.
I do not make many assumptions about you, the reader, but I do make a few.
I assume you have some experience or familiarity with programming in a computer language. It doesn't matter which language you code in, just that you know what programming is and you've done it before. If you're new to computer programming, many excellent books and tutorials are available that can give you the background you need for this book in a few days. I recommend Coding All-in-One For Dummies, 2nd Edition (written by me and an awesome team of other coding experts), which contains an introduction to all the languages and techniques you use in this book. In particular, read the chapters about Python and JavaScript.
Most of the examples in this book are JavaScript code, because that's the programming language I know the best. However, this is not a JavaScript-specific book and the techniques and tools I use to help write or improve my JavaScript code work with any language. The code examples are generally simple enough to be understood without a specific knowledge of JavaScript.
I assume you have a computer running a modern web browser. You will do most of the exercises in this book by using web-based resources. Although it may be possible to complete these exercises using a smartphone or tablet, I don't recommend it.
I assume you have access to an internet connection. Because the language models we'll be working with are far too large to install on your computer, an internet connection will be essential to completing the hands-on element.
I assume you can download and install free software to your computer. Oftentimes, the computer you use at work will have restrictions on what can be installed by the user. Using your own computer to develop and run the applications in this book should work without a problem.
Here are the icons used in the book to flag text that should be given extra attention or can be skipped.
This icon flags useful information or explains a shortcut to help you understand a concept.
This icon explains technical details about the concept being explained. The details might be informative or interesting but are not essential to your understanding of the concept.
Try not to forget the material marked with this icon. It signals an important concept or process that you should keep in mind.
Watch out! This icon flags common mistakes and problems that can be avoided if you heed the warning.
A lot of extra content that you won’t find in this book is available at www.dummies.com. Go online to find the following:
The source code for the examples in this book:
Go to
www.dummies.com/go/codingwithaifd
. The source code is organized by chapter. The best way to work with a chapter is to download all the source code for it at one time.
The cheat sheet:
Go to
www.dummies.com
and, in the search field, typing
Coding with AI for Dummies
. You'll find helpful prompting tips for coding with AI, a list of dangers when using AI-generated code, and a tongue-in-cheek look at what AI coding assistants can't do.
Updates:
AI is changing rapidly, and I don't expect it to stop doing so after this book is published, so the commands and syntax that work today may not work tomorrow. You can find any updates or corrections by visiting
www.dummies.com/go/codingwithaifd
or
https://github.com/chrisminnick/coding-with-ai
.
As you embark on your journey of learning to code with AI, keep an open mind but also a large dose of skepticism and patience. In spite of how impressive the current generation of GenAI tools is (and they're surely much better by the time you read this), we're still in the infancy of this stuff.
If you want to get a basic understanding of AI-assisted coding, go to Chapter 1. If you want to find out more about how these tools work and about machine learning in general, read Chapter 2. If you want to learn about some of the tools that are available today for coding with AI, see Chapters 3 and 4. If you want to get right into experimenting with the combination of coding and AI, skip to Chapter 5.
Congratulations on taking your first step towards AI-assisted coding, and thank you for trusting me as your guide.
Part 1
IN THIS PART …
Discover how AI-enhanced tools can help make you a better and more efficient programmer.
Dig into the fundamental concepts behind machine learning and deep learning.
Explore AI pair programming tools.
Converse with the latest generative models to assist with coding tasks.