Taro Logo
18

Learning a code-base in a new language - How to do it?

Profile picture
Mid-Level Software Engineer at TikToka year ago

I joined Tiktok coming from not such a big company & fast culture. I had two projects where I needed to read massive code bases for tasks. The code base is in C++. A language I haven't used in years. How should I go about it?

Should I spend time learning the language before diving into the code or otherwise? I feel under-confident; other engineers scan & understand code even when they don't know the language too well.

669
2

Discussion

(2 comments)
  • 9
    Profile picture
    Tech Lead @ Robinhood, Meta, Course Hero
    a year ago

    C++ is a rough language to learn - I know this because C++ was the primary language for UCLA Computer Science back in my day. It's pretty verbose and a lot of stuff doesn't come "for free" (like automatic garbage collection). It can be hard picking up C++ if you're used to a more streamlined language like Python or even Java.

    Should I spend time learning the language before diving into the code or otherwise?

    It's probably worth it going through a course or book that covers the absolute basics of C++. I looked at W3 Schools' C++ material briefly and it seems decent: https://www.w3schools.com/cpp/

    If books are your thing, they can be effective for "101-style" material (classes, variables, etc), because it's all evergreen. I forget which book we used at UCLA, but this one seems solid: C++ All-in-One For Dummies

    On top of these, I still recommend the usual advice of playing around with the code, seeking lots of help from teammates, and all that good stuff. These resources cover that in more detail:

  • 15
    Profile picture
    Tech Lead @ Robinhood, Meta, Course Hero
    a year ago

    Something else I'll mention is that there's nothing wrong with shamelessly copy-pasting πŸ˜‰. At a Big Tech company like TikTok, it's not likely that you'll get a coding task (especially if you're onboarding) where the code is completely novel and unlike something else that already exists in the codebase.

    At Meta, my strategy working in an unfamiliar codebase was often:

    1. Find a commit that does something similar to what I'm doing
    2. Copy-paste the code
    3. Desperately guess and change the variables and other parameters to make the code adhere to my use-case
    4. Run the code and hope it meets success criteria
    5. Repeat #3 and #4 until it works. If I get stuck, ask for help

    From Step #4, verifying that stuff works often won't be fully defined on your task (e.g. "How do I run my new API endpoint, send it data, and verify the response?"). If that's the case, aggressively push to clarify this. This is the most important piece of going through the feedback loop of trying stuff and seeing if it works.

    This type of basic pattern matching is also something AI can be really good at. Maybe you can get permission from your manager to integrate GitHub Copilot or feed large amounts of your team's C++ code into ChatGPT? Here's the case study we recently gave about the topic: [Case Study] How Engineers Unlock Huge Impact With Artificial Intelligence (AI)

TikTok, known in China as Douyin, is a short-form video hosting service owned by Chinese company ByteDance. It hosts a variety of short-form user videos with durations from 15 seconds to ten minutes
TikTok16 questions