Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Julia Module 1

Getting started: what Julia is for, installing it and running code interview questions

Interview questions on “Getting started: what Julia is for, installing it and running code”.

12 questions: 4 warm-ups and 8 with model answers · Levels: Fresher to senior

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher to mid

    What does just-in-time compilation mean in Julia, and why is the first call of a function slow?

    Julia compiles a function the first time it is called with a particular combination of argument types. It infers the type of every value in the function from those argument types, generates machine code through LLVM and keeps that code for the same types. The first call therefore pays for type inference and code generation, which for a small function can take a large part of a second, while every later call with the same types runs the stored machine code directly, often in microseconds. A call with new argument types, say Float32 instead of Float64, compiles a new specialisation. Packages are compiled once when first loaded and the result is cached in the depot. To time code fairly, call it once first, or use a benchmarking tool that runs it many times.

    From the lesson What Julia is for, and when to choose it

  2. Fresher to mid

    How do juliaup's release and lts channels differ, and how do you start each one?

    Answered in the lesson Install Julia with juliaup and manage versions

  3. Fresher to mid

    Besides the Julian mode, which modes does the Julia REPL have, and how do you enter and leave each?

    Answered in the lesson The REPL, scripts and the @main entry point

  4. Fresher to mid

    What does Revise.jl do, and why do Julia programmers use it?

    Answered in the lesson Notebooks, editors and the Revise workflow

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Fresher to mid

    A colleague times a new Julia function once with @time, sees 1.2 seconds, and concludes that it is slower than their NumPy version, which takes 5 ms. What is wrong with the measurement, and how would you measure the two fairly?

    What it tests
    Knowing that a first call includes just-in-time compilation, that single runs and untyped globals distort timings, and how to time compiled code fairly.
    First step
    Read the @time line: if it reports a large compilation share, most of the 1.2 s was compiling, not computing. Call the function once, then time a second call or the fastest of several, with the data passed as arguments, and time the NumPy version the same way.
    Follow-ups

    From the lesson What Julia is for, and when to choose it

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  2. Mid to senior

    Your lab's Python particle simulation spends about 90 % of its run time in a hand-written loop over particles that no NumPy function covers. Would you port it to Julia, and what would you measure and check before deciding?

    What it tests
    Judging a language move by where the time goes, the measured costs of Julia (compilation per process, package precompilation, missing libraries) and a small, checkable trial.
    First step
    Profile first, to confirm that the loop really takes the 90 % and to see how long one run lasts. Then port only that loop to a Julia function, check that it gives the same numbers, and compare its time after the first call with the Python loop's.
    Follow-ups

    From the lesson What Julia is for, and when to choose it

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  3. Mid to senior

    On a shared cluster your home folder has a 2 GB quota, and installing Julia packages starts failing with disk-quota errors. How do you move Julia's packages elsewhere, and what exactly must the new JULIA_DEPOT_PATH value contain?

    What it tests
    Knowing what the depot holds, how DEPOT_PATH is built from JULIA_DEPOT_PATH, and why the trailing separator keeps the bundled depots.
    First step
    Find what fills the quota, usually packages, artifacts and compiled caches in ~/.julia. Then set JULIA_DEPOT_PATH to a folder on a larger file system followed by a colon, such as /scratch/me/julia-depot:, before Julia starts, and check DEPOT_PATH in a new session.
    Follow-ups

    From the lesson Install Julia with juliaup and manage versions

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  4. Mid to senior

    Your package must work on the Julia 1.10 LTS and on 1.13. How do you test both on one laptop and in continuous integration, and what does supporting 1.10 change in the code itself?

    What it tests
    Using juliaup channels side by side, a test matrix in continuous integration, and code that avoids or guards features newer than the LTS.
    First step
    Install both with juliaup, juliaup add lts beside the release, and run the test suite with julia +lts and julia +release. In continuous integration, run the same job on both versions. In the code, avoid or guard names that arrived after 1.10, such as logrange and @main.
    Follow-ups

    From the lesson Install Julia with juliaup and manage versions

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 2 minutes
  5. Fresher to mid

    A script that works when its lines are pasted into the REPL fails in a continuous integration job with UndefVarError: subtypes not defined in Main. Explain why, fix it, and say how you would stop similar surprises.

    What it tests
    Knowing that the REPL loads InteractiveUtils for you while a script does not, and running scripts the way the integration job does before committing.
    First step
    The REPL loads InteractiveUtils automatically, and a script run with julia file.jl does not. Add using InteractiveUtils at the top, or avoid the helper in code that runs unattended, then run the script as the job does, julia --startup-file=no file.jl, in a fresh process.
    Follow-ups

    From the lesson The REPL, scripts and the @main entry point

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 2 minutes
  6. Mid to senior

    Design a small Julia command-line tool that converts numbers given as arguments and is called from shell pipelines. Which entry point, output streams and exit codes would you use, and how would you test them?

    What it tests
    Using @main and its return value as the exit status, standard output for results and standard error for messages, distinct non-zero codes, and tests that run the script as a separate process.
    First step
    Put the logic in functions and add an entry point, function (@main)(args), that returns 0 on success and a non-zero code, such as 2, for bad input. Print results to standard output and messages to standard error, so the next program in a pipeline receives only data.
    Follow-ups

    From the lesson The REPL, scripts and the @main entry point

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  7. Fresher to mid

    A colleague's notebook shows 3 wet days, but when you run the same notebook from top to bottom you get an UndefVarError instead. How do you find the cause, and how do you make the result reproducible?

    What it tests
    Recognising hidden state left by cells that were deleted or run out of order, and moving the logic into functions and a script that runs in a fresh process.
    First step
    Restart and run every cell from the top: the first cell that fails names a variable that only existed in the old session. In this case a deleted cell defined threshold, so put that definition back, or better, pass the threshold in as an argument.
    Follow-ups

    From the lesson Notebooks, editors and the Revise workflow

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  8. Mid to senior

    You use Revise in a long-running session. You edit a function in your package and save, yet a long simulation you started earlier keeps behaving the old way. List the likely causes in order and how you would check each one.

    What it tests
    Knowing world age, so that running code keeps old methods, Revise's loading order and tracking rules, and the limit on redefining structs before Julia 1.12.
    First step
    Ask whether the code that is running started before the edit: a running function or task keeps the methods of its world age. Call the function fresh at the prompt; if that shows the new behaviour, only the long run is stale, so restart it or call through invokelatest.
    Follow-ups

    From the lesson Notebooks, editors and the Revise workflow

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes

All Julia interview questions · The Julia track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.