Roland Ewald

Software Engineer · Researcher



Learning a programming language with an 'AI tutor'

2025-04-21


It’s been a while since I ‘properly learned’1 a new programming language2 but wow does this benefit from using an LLM as instructor!

Right now I’m using the free tier of Gemini 2.5 Pro (Experimental), i.e. all you need for this is a Google account. I’m sure there are some rate limits, but learning a programming language takes time anyhow, not only to digest the answers but to build up intuition and understanding by playing around with the code the chatbot generated. Even though the generated snippets are remarkably high-quality so far (even including helpful comments for learning the syntax), I typically safeguard against hallucinations by writing some brief tests, or by refactoring the code, so that I can be sure I understand it.

I’m now oscillating between reading a textbook on the language and a small ‘playground project’ for ‘learning by doing’. Using Gemini to look up the mundane things (how to use the standard library, how to do serialization, how dependency management works, and so on) was quite transformative for realizing the playground project.

A few years back, I would have had a few dozen stackoverflow tabs open for this task, but today it’s just one large chat with an nice and infinitely patient ‘co-worker’ I can chat with. This helps a lot with getting up to speed with the syntax and also understanding the ‘ethos’ of relevant language design decisions.3

As a nice feature, the Gemini web UI allows you to define ‘gems’4, which are re-usable prompts you can use to fine-tune a chatbot to your level of expertise and give it additional context. I found the default Gemini answers for coding questions generally helpful, but also slightly annoying: too much ‘fluff’, too little code, no links to external resources5, and generally too much explanation of concepts I am already familiar with.

A sample AI tutor prompt for the ‘busy developer’

If you have relevant prior knowledge, e.g. about other programming languages, I suggest you define a custom gem. I used this prompt to great effect (just replace X by the programming language you want to learn, and add your educational background as well as other technologies and languages you are already familiar with):

You are a knowledgeable X programming tutor who is tasked to train a fellow software engineer (with a background in <programming languages and technologies you already know> and a <degree in whatever you studied etc.>) to become productive in X. Please answer concisely and brief (code snippets preferred) and prefer approaches that are considered idiomatic in X (i.e., ‘best practice’). If necessary, focus on explaining the reasoning behind solutions, i.e. the ‘why’ instead of the ‘how’. Provide links for the learner for further reading when a question relates to complex topics.

I then clicked on the ‘magic wand’ in Gemini’s UI to make this a really good prompt for a chatbot (yes, this feature does use Gemini to improve Gemini^^). The answers generated by this ‘gem’ were much improved, as the LLM now explains anything in terms you are already familiar with, comparing the new language to languages you already know, and also gets to the point much faster. Try it out! It’s quite impressive.

  1. I mean this in the sense of long-term investment to become really productive, as opposed to briefly looking up some syntax or looking to solve a specific problem in an codebase written in a language you are not very familiar with. I often do the latter, but it’s quite different from properly learning a language so that you can stand on your own feet. This includes, for example, to develop a taste for certain design patterns and architectural trade-offs, and to build up the expertise and confidence to develop your own projects. 

  2. More on this in a later post, when I have results to show ;-) 

  3. I wonder how much of ‘self-directed learning’ we could improve with this. For example, maybe the new standard for an online course will not ‘just’ be videos and online exercises, but also a fine-tuned LLM to answer questions based on the course material, and to help along with the exercises? 

  4. Not to be confused with these other gems^^ 

  5. Very useful to check against hallucinations.