Hot Posts

6/recent/ticker-posts

How to use AI coding tools to learn a new programming language

[Collection]

The days of the single-language developer are fading. While companies like Shutterstock built empires on a single language (Perl in their case), the landscape has shifted. Today’s developers are expected to navigate a diverse technological landscape and start building projects that require proficiency in a range of languages and frameworks. This increased demand for versatility can feel quite overwhelming.

Thankfully, AI coding tools like GitHub Copilot, cursor.sh, and phind are emerging to empower developers in their learning journeys. These broadly available and adaptable tools offer real-time assistance and personalized guidance, making learning new languages faster and more efficient for developers of all experience levels.

In this post, we will:

  • Hear from some developers both in and outside of GitHub who have harnessed AI coding tools to upskill and learn new languages.
  • Provide practical tips to maximize your language-learning experience.
  • Take a look at some of the benefits you’ll see by using AI coding tools to learn a new programming language.

Comic about programming languages.

Real developer journeys: Learning new languages with AI 📚

Meet Kedasha Kerr and Alessio Fiorentino. Kedasha is one of GitHub’s own developer advocates, and Alessio is a DevOps architect and GitHub user.

As a seasoned JavaScript developer, Kedasha embarked on a machine learning course to deepen her understanding of AI. However, the course curriculum required her to learn Python, a completely new language for her. To combat the learning curve, Kedasha turned to GitHub Copilot’s chat functionality. This feature allowed her to interact with the AI in a conversational manner to ask questions about Python syntax, best practices, and even seek help with specific coding challenges she had for coursework.

“I had dabbled with Python, but I had never used it seriously or built anything with it. So, I used Copilot to help me, especially with conditionals. I would see an example from the professor, then I would go to Copilot and ask for it to explain conditionals to me as if I was a high school student with zero coding experience. I even asked it to draw a diagram to show me how data flows in Python, and Copilot coupled with Mermaid literally walked me through the explanation,” Kedasha explains.

“I used these tools to explain context and help me visualize the things that I was trying to learn. And if I was ever totally confused, I would just pop problems into the chat interface and ask it to break things down for me step by step. Honestly, it’s been a great learning buddy,” she adds.

Similarly, Alessio sought out AI coding tools to help him learn Rust for a new project he was working on. Here’s what Alessio had to say about using AI to assist his learning journey:

Headshot photograph of Alessio Fiorentino, DevOps Architect
“One of the key benefits of using AI is that it helps me learn and write better Rust code. Rust is a powerful language that provides full control over the execution flow, but it has many nuances and requires a different way of thinking, especially for those who started with Python or JavaScript. AI assists me in navigating these complexities and ensures that I write efficient and idiomatic Rust code.

One of the standout features of AI is its ability to help me get straight to the problem without the need for trial and error in finding the right search terms. By providing context through prompts, AI delivers focused and relevant results.

In addition to Rust, AI aids me in working with frameworks that I’m less familiar with. For example, it provides in-depth guidance when I’m using FastAPI for backend development or Svelte for frontend development. This saves me a lot of time and effort in understanding and implementing these frameworks effectively.

While I believe in the importance of reading official documentation to gain a solid foundation, AI coding tools become incredibly valuable when tackling more complex and nuanced problems. It’s like a ‘training on the job 2.0’ experience, where you start with a little initial knowledge but are rapidly accelerated in becoming more productive with the assistance of AI.”

Though we acknowledge that these are individual experiences, they showcase the power of AI coding tools in language acquisition. AI coding tools helped both Kedasha and Alessio by acting as a personalized learning companion, while offering contextual guidance and reducing the time spent on tedious tasks. This anecdotal evidence hopefully can serve as inspiration for other developers, as well as pave the way for further research into the measurable impact of AI on the learning process.

Practical tips and tricks 🧑‍🏫

We gathered a few valuable tips for you to keep in your back pocket as you start learning with AI, but before we jump into those, we want you to keep this in mind:

AI tools are assistants, not replacements. They can suggest code, catch errors, and provide explanations, but you still need to understand the core concepts of the language. Don’t solely rely on AI-generated code—sometimes the suggestions are wrong. It’s important to always analyze outputs, understand why it works, and learn the underlying principles of the specific language.

  1. Optimize your learning environment. This begins with exploring different AI coding tools and finding one that suits your learning style and the language you want to learn. It’s also important to supplement these tools with traditional learning practices, such as online tutorials, textbooks, or video courses. These can provide a more structured learning path, as well as more in-depth explanations for certain concepts.
  2. Don’t be afraid to experiment! Use the AI as a safety net—try different approaches to problems and see how the AI reacts so you can learn both from successes and errors. For example, let the AI suggest code snippets, but try to actively think about the suggestions and why they will (or won’t) work. You can also practice with error correction by letting the AI highlight errors and using them as learning opportunities to identify and rectify mistakes in your code.

  3. Be specific and give context. When you’re learning a new programming language with AI coding tools, providing context is crucial for two main reasons:

    • Improved accuracy and relevance. AI tools rely on context to understand your intent and the problem you’re trying to solve.
    • Deeper understanding and skill development. AI suggestions based on context can lead you to explore the underlying reasons why certain code works the way it does. This deeper understanding goes beyond rote memorization and promotes long-term knowledge retention.

    It’s best to treat prompts as discrete and atomized tasks to get to an end result. Not only will this help you build better prompts for the AI, but it will also help you better articulate what you are trying to achieve.

  4. Reach out to developers in the community. Developers who are actively experimenting with AI or are fluent in the language you’re trying to learn will provide more help than this blog post ever could. GitHub Community discussions are a great place to find folks with similar interests or answers to questions on numerous topics. For example, you could check out the Copilot discussion to learn more about Copilot to see if it’s the right fit for your toolkit to learn a new language!

Benefits of hurdling the programming language barrier with AI 🚧

Now that you’ve explored how to use AI to learn a new programming language, here are some of the benefits you can expect to take advantage of:

  • Real-time assistance and feedback. These AI-powered coding tools leverage machine learning algorithms trained on vast public code repositories to offer functionalities, such as context-aware code completion, syntax and logic error detection, and immediate access to relevant documentation and code examples. This not only accelerates the writing process; it also helps identify errors and potential improvements to help developers grasp the nuances of a new language. Plus, some tools (like Copilot) employ a chat interface which helps you ask specific questions about a new language you’re learning.

Asking GitHub Copilot for assistance writing a Hello World program in Python and Rust.

  • Adaptive learning pathways. Everyone learns at different paces in different ways—some folks are autodidacts and others thrive with more personal instruction. Luckily, AI tools aren’t one-size-fits-all solutions when it comes to helping you learn a new programming language. They can assess your individual skill level and adjust their assistance accordingly. This personalized approach ensures you’re challenged appropriately, neither overwhelmed nor underwhelmed, leading to a more efficient and engaging learning experience. Here’s an example of how:

Scenario: you’re a beginner learning Python and you want to write a simple script to calculate the area of a rectangle.

Initial stage:

  • Low confidence: the AI initially detects you’re a beginner based on factors like the simplicity of your code and the use of basic syntax.
  • High level of assistance: after recognizing your inexperience, the AI offers extensive help:
    Contextual code completion: as you type area( for a function call, the AI suggests the complete function area(length, width).
  • Example code: the AI displays a code snippet demonstrating how to use the area function with sample values.

As you progress:

  • Gradual decrease in assistance: as you write code for calculating length and width, and then call the area function with those variables, the AI observes your growing understanding.
  • Reduced completion: the AI might only suggest function names or variable names after you start typing, requiring you to fill in the details.

Focus on best practices: the AI might highlight areas for improvement, suggesting ways to make your code more efficient or readable.

  • More time on your hands. By offering code completion and syntax checks, AI tools free up valuable time. For example, studies show 55% faster task completion with Copilot’s predictive text feature. This allows you to focus on understanding the core concepts of the language, experiment with new functionalities, and build more complex projects, all of which are crucial for solidifying your programming knowledge.
  • Opportunities to upskill. The world of tech is constantly evolving, and new languages emerge all the time. A prime example is Mojo, a new language launched in May 2023 that combines Python-like syntax with the performance of C++. With AI assistance, upskilling with a new language becomes a more achievable and less daunting prospect. Whether you need to learn Python for data science or Java for Android development, AI tools can equip you with the necessary foundational knowledge and accelerate your journey towards becoming a more versatile developer.

Take this with you 🤝

The landscape of software development is evolving, and AI coding tools are at the forefront of this transformation. With these tools, you can explore your own programming language interests, streamline your skill acquisition journey, and ultimately feel empowered to stay competitive in your career. Plus, the opportunities they offer to democratize access to programming knowledge and accelerate the growth of skilled developers everywhere is pretty exciting.

Check out this blog post to learn more exciting ways you can use Copilot with your projects.

If you’d like to try out GitHub Copilot as an aid to your learning journey, start your free trial here.

The post How to use AI coding tools to learn a new programming language appeared first on The GitHub Blog.

Explore how AI coding tools like GitHub Copilot can accelerate your journey to learn new programming languages.

The post How to use AI coding tools to learn a new programming language appeared first on The GitHub Blog.