Article

Why it is hard to learn another programming language Part III

Published on 5 min read

    Why it is hard for developers to learn another language and how a professional training can help - Part III

    Note: other posts in this series - Part I and Part II.

    In the first two posts in this series, we focused on how the dialogues in a group setting of a professional training and the combination of lecture and hands-on exercises is crucial for developing the mental model of a new programming language. Today's third and last part of the series will focus on how a professional training can turn the mental model of a previous experience, that would likely cause interference, into a learning opportunity with the help of a professional training.

    A short recap

    We are regularly confronted with the fact that experienced programmers find Rust a language hard to learn. Research suggests that this is not only the case for Rust, but a general problem: If you already know one programming language, learning another comes with its own set of challenges. In this blogpost I will discuss the findings of the article Here We Go Again: Why is it difficult for Developers to Learn Another Programming Language? in the context of how a professional training can help to overcome the issues the authors raise. The article identified three major sources of problems that make switching to a new programming language difficult:

    1. Interference when learning a new language

    When learning something new, we try to connect the new information to similar information that we already have. The old information can help to integrate the new information, but it can also interfere with learning something new, because the similarities are too superficial, or the new information contradicts the old information.

    2. Programmers apply opportunistic learning strategies and learn on their own

    “Just in time learning” is described as a learning strategy that is based on a need-to-know basis using online available resources while learning alone. Instead of learning a new language systematically from the ground up with a broad horizon of applications in mind, the focus is often on a narrow skillset required to get a very specific task done.

    3. Breaking of old habits and shifting mindsets becomes more difficult

    Learning a new language requires a mind shift, getting familiar with new tooling, possibly building a new mental model of what programming looks like in the new language. Using your old mental model as the sole guide to learning a new language can under some circumstances make it very hard to get into a new mental model, which is necessary to be successful in the new language.

    How can a professional training help turn previous experience into an advantage instead of letting it become a blocker?

    As a starter: Rust was developed by taking a lot of tried and tested concepts from other languages so chances are good that starting with Rust, some things will feel familiar if it is not your first programming language. But these concepts have not just been taken unchanged, they have been tweaked to fit into Rust's philosophy. This can be a source of confusion.

    A practical Example: Python vs. Rust

    Python's objects have some similarity to Rust's type implementations, yet they have key differences in functionality and conceptualization. Coming from Python, there are several things that will feel familiar when studying Rust's type implementations:

    • Rust also has a Self keyword that stands for the type.
    • Python has an __init__ function, Rust's impl blocks have a fn new() function.
    • Just like in Python, you can define methods for the type.
    • A type in Rust can sort of "inherit" properties (Traits in Rust) that have been defined somewhere else.
    • Traits in Rust are analogues to interfaces in Python's abc.ABCMeta.

    But here it starts to get fuzzy not only conceptually, but in practical application as similarities get superficial and shallow - a very likely source for interference. To avoid that this acts like a false friend later on, there needs to be a lot of contextualizing:

    • Rust does not only have Self but also self, &self and &mut self and proper usage requires at least basic understanding of Rust's ownership model, something Python does not have.
    • In Python the name of the constructor__init__ is required, while fn new() in Rust is merely convention.
    • In Python we deal with classes that can be based on a number of types, in Rust we implement functionality to a type that is a struct.
    • A struct in Rust can't just inherit properties of other types the way a class can do in Python. The shallow similarity is that pre-defined properties are applied to something user-defined. In Rust, a Trait makes certain guarantees of what kind of functionality a Type provides, and the actual functionality has to be implemented by the user. In Python on the other hand, functionality that is inherited to a child object does not have to be implemented again, but it can be overridden by the child.

    One solution: Don't learn alone and do it thoroughly

    It is possible to lessen the risk of interference seriously impacting your understanding when learning Rust as an autodidact. But it requires a deep dive into comparing both language's features not only syntactically but also semantically and conceptually. It's not only work you have to do for one language feature, but for most, because you don't know where interference is lurking, prior to understanding the feature! It becomes less time consuming when learning in a group, because for one, research work can be shared and discussing different mental models can be a valuable corrector. But the time and organizational overhead of a self-organized learning group is not a side job.

    Going back to the three causes of problems mentioned above, it all boils down to avoiding opportunistic learning styles and learning alone if you want to lessen interference.

    The better solution: Get a professional training

    When preparing for a training we also assess what languages the participants are mainly coming from. We select a trainer who has previous experience with these languages and knows the typical pitfalls that can occur when switching to Rust. But this is not only about avoiding pitfalls. The trainer will point out true similarities you can rely on. This enables you to start with Rust with confidence, so that you don't have to worry about interference. There's also a grey area between pitfalls and true similarities. Here, we're able to discuss which assumptions about something seemingly familiar are true and which ones are not. This avoids that participants' previous experience can act as a blocker in adopting Rust. Additionally, these discussions often lead to a deeper understanding of both languages, with a minimum of time expenditure and organizational overhead.

    Conclusion

    A professional training gives your team a head-start by avoiding interference by taking the participants' previous experience into account and adapting the training to known pitfalls and use true similarities as a speed-up. This is the fast lane to up-skilling an entire team to be able to write production code in Rust.