Ahmni

ahmni llc · August 10, 2024

Programming Language Retrieval with ChatGPT

Here are a few tips for learning the syntax of a new programming language, featuring LLMs.

I use Claude 3.5 Sonnet here which was much better at following instructions for these tasks. However the one task I found ChatGPT 4o to be much better at was evaluating my code for efficiency.

Self-Explanation Retrieval

It’s natural to want LLMs to explain code to us, but what if we explained code to LLMs instead? That way instead of passively taking in information we get all the benefits of retrieval, testing effects, and immediate feedback.

Me:

User asking Claude to explain code concepts

Claude:

Claude providing feedback on self-explanation

Me:

Follow-up question to Claude about the code

Claude:

Claude's detailed response about code logic

Syntax Clozes

One of the underlying principles of these techniques is to focus on learning one thing at a time. It’s not helpful to overload with multiple things at once, like multiple lines of new languages syntax and solving a leetcode algorithm all at once. So let’s just focus on individual lines of syntax.

Syntax cloze exercise generated by Claude

Completed syntax cloze with answers revealed

Syntax Conversion

Do you already know one language? If you already know Python, for example, and want to learn C++, a great way to learn is to convert between languages.

Requesting Python to C++ code conversion from Claude

Claude's C++ conversion response

Follow-up syntax conversion question

Claude's final conversion response

Ask for Specific Feedback

When learning a new language we can paste code in to an LLM and ask for feedback about efficiency, style, and correctness.

Asking Claude for specific code efficiency feedback

Claude's code review and efficiency suggestions