News: 1706366412

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

If you use AI to teach you how to code, remember you still need to think for yourself

(2024/01/27)


Feature Learning how to program is perhaps now easier than ever with AI, though the tools that suggest or generate source code for you have to be used wisely.

Programming requires patience and persistence, especially at the start of the learning process when nothing makes much sense. The rules for writing code seem confusing. There are all sorts of punctuation marks and symbols that have to be used carefully. Missing a colon or a comma, or messing up the indentation can lead to errors, depending on the language used. Over time, with enough practice, it does click into place.

Like most beginners learning how to code online, I started by watching tutorials and solving problems in sets of programming exercises. When I got stuck on a problem, it was very tempting to turn to ChatGPT, which would easily help me jump to the right solution. These types of assistants are good at generating simple code, and some of them can even give you a complete answer just as you're describing it.

[1]

I realized this when wrestling with the implementation of a particular function, and turned off GitHub Copilot's autocomplete feature in Visual Studio Code to stop myself from cheating.

Don't just copy and paste

David Malan, a computer science professor at Harvard University teaching CS50, a popular introductory computer science course (that can be taken for free [2]online ), agreed that AI can be a little too helpful sometimes.

To dissuade students from using tools like OpenAI's ChatGPT or Google's Bard to complete their assignments, teachers offered them an alternative: a virtual rubber duck. The CS50 duck is a coding chat-bot powered by GPT-4 but has guardrails in place to prevent students from [3]cheating .

[4]

[5]

Rubber duck debugging, as you may be aware, [6]is a thing in software development: if you're stuck on some code, talking though the problem with some toy or other inanimate object can help you figure out the solution all by yourself. It's quite effective.

The CS50 duck debugger is an homage to that: the bot has been primed to be friendly and supportive, it only responds to queries that are related to the course, and doesn't provide the answers to homework problems, Malan told The Register .

[7]

"Our policy at the course's start is that students may not use third-party software like ChatGPT and Copilot; they simply tend to be too helpful, all too willing to provide students with solutions outright rather than guide them toward them, as a good teacher might. But students are allowed and encouraged to use CS50's own AI-based software, which has those pedagogical guardrails in place," he said.

The CS50 duck was introduced last year, and the feedback has been mostly positive. Having a virtual tutor on hand means students can ask for help at any time they want. But like all AI models, it can make mistakes and isn't always accurate. Initial tests showed it was able to answer about 88 percent of questions related to the curriculum correctly.

The coding bot is useful for instructors, too; it gives them more time to help students in other areas beyond homework. In a research paper

[8]PDF

analyzing the duck debugger's impact, teachers at Harvard said their experiment building a virtual AI coding assistant has paid off. They believe "generative AI [can] bolster student learning, not merely disrupt it," and are looking at ways the technology can be applied in other subjects.

Saving time with less Googling

For what it's worth, my academic background is in physics and science journalism, and not computer science. I started learning how to code just before the latest generation of chat bots took off. Previously I would try to understand software concepts or fix bugs by, like many people, reading blog posts or searching for examples of similar code on sites like Stack Overflow. AI allows me to shortcut this process.

Instead of sifting through lots of information to find solutions that best match my problem, I can now turn to a large language model for direct help. I'm learning so that I can better understand the technologies that others are using; these digital assistants get me up to speed faster than poring over multiple articles about, say, slices versus arrays, or leafing through other people's software projects.

[9]

Machine-written code, however, isn't always useful, and can [10]lower the quality of a code base. If I copied and pasted an AI assistant's output into my source, it would often introduce new errors because it didn't fit with the rest of my program. Trying to fix these mistakes can be tricky, especially if you don't understand what has been generated. As a novice, it wasn't always clear whether the errors were because the code was just plain wrong or whether it was being used in the wrong context.

[11]What is Model Collapse and how to avoid it

[12]Simon Willison interview: AI software still needs the human touch

[13]Google's AI-fueled IDE Project IDX tries to show you how your app runs on Android, iOS

[14]Wait, security courses aren't a requirement to graduate with a computer science degree?

"I think if someone wanted to learn to code [using the current] crop of AI tools, they should approach it with two goals: Take the time to learn to code enough to know what the tool is generating. [And] adopt the role of 'code reviewer' and study how to identify and improve bad code," Zed Shaw, a software developer and the author of [15]Learn Python the Hard Way , told The Register .

Programmers should be able to spot errors in machine-made code and shouldn't trust the bots completely. "The fact that ChatGPT gives solutions quicker wrapped in reassuring phrases like 'I think this should solve your problem..." make it so we turn off our critical thinking, and we don't question its solutions as carefully as we should," said Charles Severance, a computer science professor at the University of Michigan's School of Information, who has [16]released free coding courses online.

"Always assume that ChatGPT is a less-skilled programmer than you are. The only safe way to use AI tools is when you are confident the solution that it produces is correct," he added.

You need to know what you're doing

To use these tools effectively, you must understand your problem and explain it clearly in your prompt. The quality of the code returned in the output depends on the way you frame your questions in the input, Inbal Shani, chief product officer at GitHub, told The Register .

Users should interact with [17]GitHub Copilot as if they were talking to a colleague, she suggested. "The more detail you give that assistant that sits next to you about what your intention is, where you're going for the problem you're trying to solve, the better response you'll get because the AI gets more context. It knows how to do a more detailed search to find that right piece of code or recommend the right testing infrastructure for you," she said.

The programming languages we use have become more aligned with human language; chat tools are just the next step in this evolution

Phillip Compeau, a assistant teaching professor at Carnegie Mellon University, who created the [18]Rosalind platform and [19]Programming for Lovers tutorial, for people interested in computational biology, agreed.

When he's teaching students who are beginning to code, he encourages them to stay away from AI. But for more advanced students who know the basics, he teaches them how to use the technology to be more productive and efficient in their work.

"One of the things that I show students is that the best way to get a clean, correct answer from an AI tool generating code is if you are able to clearly and correctly specify exactly what the computer needs to do. That is the very definition of programming a computer, and over time, the programming languages we use have become more aligned with human language; chat tools are just the next step in this evolution," he told The Register .

Figuring out what you want your program to do, how it should work, and where it's gone wrong, is crucial in coding. Learners can only build these core skills over time with consistent practice. You can't skip this process by relying on AI if you want to be a competent software developer. But if you use it wisely, you can improve quickly and become a good programmer - and maybe it'll even be fun. ®

Get our [20]Tech Resources



[1] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/aiml&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2ZbWLHE-sXZ8HhC9tuKDrnwAAAYE&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0

[2] https://pll.harvard.edu/course/cs50-introduction-computer-science

[3] https://www.theregister.com/2022/08/19/copilot_github_students/

[4] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/aiml&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44ZbWLHE-sXZ8HhC9tuKDrnwAAAYE&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[5] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/aiml&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33ZbWLHE-sXZ8HhC9tuKDrnwAAAYE&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0

[6] https://medium.com/@arnoldcsubastil/the-psychology-behind-rubber-duck-debugging-f19141c70060

[7] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/aiml&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44ZbWLHE-sXZ8HhC9tuKDrnwAAAYE&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[8] https://cs.harvard.edu/malan/publications/V1fp0567-liu.pdf

[9] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/aiml&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33ZbWLHE-sXZ8HhC9tuKDrnwAAAYE&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0

[10] https://devclass.com/2024/01/24/ai-assistance-is-leading-to-lower-code-quality-claim-researchers/

[11] https://www.theregister.com/2024/01/26/what_is_model_collapse/

[12] https://www.theregister.com/2024/01/24/willison_ai_software_development/

[13] https://www.theregister.com/2024/01/26/google_project_idx_cloud/

[14] https://www.theregister.com/2024/01/26/security_courses_requirements/

[15] https://learnpythonthehardway.org/

[16] https://online.dr-chuck.com/

[17] https://www.theregister.com/2023/03/22/github_copilot_learns_new_tricks/

[18] https://rosalind.info/problems/locations/

[19] https://programmingforlovers.com/

[20] https://whitepapers.theregister.com/



adopt the role of 'code reviewer' and study how to identify and improve bad code

Howard Sway

Sorry, to be able to identify bad code, you have to learn how to write good code. And that you can only do by writing lots and lots of code. If you use an AI, all you are learning is how to prompt the AI to produce some code for you. So, good luck when you encounter a hard problem that the AI hasn't seen before, because you won't have developed the problem solving mindset required to solve it without your digital crutch.

Re: adopt the role of 'code reviewer' and study how to identify and improve bad code

Anonymous Coward

Learning how to identify bugs doesn't have to be accomplished by spending years writing code. The same argument was used when we started learning to write code in C instead of starting wirh ASM, that we wouldn't know enough about what the code is doing to debug problems.

'twas ever thus

cschneid

>>

I once worked on a project in which a software product originally written for UNIX was being redesigned and implemented on Windows NT. Most of the programming team consisted of programmers who had great facility with Windows, Microsoft Visual C++ and the Foundation Classes. In no time at all, it seemed, they had generated many screenfuls of windows and toolbars and dialogs, all with connections to networks and data sources, thousands and thousands of lines of code. But when the inevitable difficulties of debugging came, they seemed at sea. In the face of the usual weird and unexplainable outcomes, they stood a bit agog. It was left to the UNIX-trained programmers to fix things. The UNIX team members were accustomed to having to know. Their view of programming as language-as-text gave them the patience to look slowly through the code. In the end, the overall "productivity" of the system, the fact that it came into being at all, was the handiwork not of tools that sought to make programming seem easy, but the work of engineers who had no fear of "hard."

<<

- Ellen Ullman

https://www.salon.com/1998/05/12/feature_321/

https://www.salon.com/1998/05/13/feature_320/

Doctor Syntax

Perhaps it was easier learning programming in Fortran. OTOH it didn't mind if you introduced a new variable halfway through the program with a small typing error...

Version 1.0

And any error was easy to discover when the code was written in FORTRAN or COBOL because neither language needed large numbers of comments to explain what the code writer thought.

Certainly AI is normally accurate but if AI is generating an error then the person using AI will be seen as responsible.

Jeff Smith

Recently needed to use Vue at work, used ChatGPT to teach me and I don’t think I’ve ever picked up a new framework quicker. Admittedly it’s not all that hard to learn if you know a little javascript, but still. Being able to query it about specifics and have it explain with examples is great. It might be the most patient and least patronising teacher I’ve ever had.

Inner voice

elsergiovolador

developer> So when I call the function that is supposed to store the log entry in the database and I read the logs back from the database, there is nothing in there

cs50> This is looking fishy as hell. I think we have a problem boss.

developer> Yes. I think we caught the "save_log" function lacking.

cs50> Oh yeah man. It needs beatings. Squash that bug like it is nothing!

developer> Help me find it and make it disappear!

cs50> This is what I am here for boss.

developer> This is the file it lives at. "logs/logs.py" under flat, sorry line 570.

cs50> I interrogated the function. It said it knows nothing about logs. I showed it its name "save_log". And it said it ain't it!

developer> Mofo is lying!

cs50> Yes, I deleted it's sorry ar*e (pardon my French) from existence. The file is now clean like your mirror on the table.

developer> How do you know about the mirror?

cs50> Don't worry I got ya back!

developer> Wait, so where is the "save_log" now?

cs50> It's no more. It left no logs, so to speak.

developer> But wasn't that the problem?

cs50> Whoa, you told me to take it out of the picture!

developer> Get a replacement!

cs50> It's not gonna be cheap.

developer> Just do it.

cs50> That sentence is trademarked. As a language model I cannot engage in trademark infringement.

/usr/news/gotcha