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.

Language Atlas (mini-courses for more languages) Module 10

Gleam on the BEAM and in JavaScript interview questions

Interview questions on gleam on the BEAM and in JavaScript: warm-ups, then what each harder question tests and how a good answer starts.

11 questions: 4 warm-ups and 7 with model answers · Levels: Fresher to staff

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher to mid

    What are gleam.toml and manifest.toml, and which of them do you commit?

    Answered in the lesson Gleam on Erlang/OTP 29 and Node.js: first project

  2. Fresher to mid

    How does Gleam handle an operation that can fail, without exceptions?

    Answered in the lesson Gleam for JavaScript and Python developers

  3. Fresher to mid

    What is a subject in Gleam, and why does Gleam send messages through one instead of to a process id?

    Answered in the lesson Gleam processes, actors and FFI

  4. Fresher to mid

    Why does the booking core take the time as an argument instead of reading the clock?

    Answered in the lesson Project: a ticket-booking core in Gleam

Questions with model answers

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

  1. Mid to staff

    A new Gleam project has two parts: a service that keeps every show's state in memory and serves thousands of requests a second, and form checks that must give the same results in the browser and on the server. Which target or targets does each part use, and how do you lay out the code?

    What it tests
    Matching targets to runtimes, knowing what exists only on the BEAM, the integer difference between the targets, and structuring a package so a shared core builds for both.
    First step
    Split the decision by part. The service needs processes and actors, which exist only on the BEAM, so it uses the Erlang target. The form checks must run in a browser, which needs the JavaScript target, and on the server, so they are a pure module that builds for both, with every number kept well below 2^53 and tests run with gleam test on each target.
    Follow-ups

    From the lesson Gleam on Erlang/OTP 29 and Node.js: first project

    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. Fresher to senior

    A Python service splits a bill two ways with share = (total - discount) // 2, and the port to Gleam reads { total - discount } / 2. Every test passes, yet a refund of -7 now gives -3 each where Python gave -4. Explain the difference, fix the port, and say how you would have caught it.

    What it tests
    Truncating against floor division, the sign of a remainder, Gleam's floor_divide and modulo, and tests that cover negative values and the zero divisor when numeric code moves between languages.
    First step
    Compare the two operators on the failing value. Python's // rounds down, so -7 // 2 is -4; Gleam's / on Ints drops the fraction towards zero, so -7 / 2 is -3. They agree when both numbers have the same sign or the division is exact. Python's result is int.floor_divide(-7, 2), which returns Ok(-4).
    Follow-ups

    From the lesson Gleam for JavaScript and Python developers

    Model answer, Pro.

    In the answer:

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

    Your Gleam package runs its pricing rules on the BEAM and in the browser. After a teammate adds a small retry with process.sleep to the rules module, CI's JavaScript build fails with Unsupported target, while the Erlang tests pass. What is going on, and how do you fix the design?

    What it tests
    Knowing which packages exist on which target, why every module of src is compiled for each target, and keeping target-specific behaviour at the edges of a shared package.
    First step
    Read the error: process.sleep comes from gleam_erlang, whose functions are externals with an Erlang implementation only, so the JavaScript build stops at the call. The rules module is shared, and a build compiles every module of src for its target, so the whole JavaScript build fails, not only the pages that use the retry.
    Follow-ups

    From the lesson Gleam for JavaScript and Python developers

    Model answer, Pro.

    In the answer:

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

    A Gleam service keeps each shopping cart in an actor under a supervisor. After a bad deploy, users report empty carts that nobody cleared, and the logs show crash reports for cart actors. Explain what happened, and redesign it so that a crash never loses what a customer added.

    What it tests
    Knowing that a restart starts from the initial state, reading crash and supervisor reports, restart intensity, and where durable state belongs in an actor design.
    First step
    Connect the two symptoms: a supervisor restarts a crashed actor by calling its start function again, so the new process begins with the starting state, an empty cart. The carts were not cleared; they died with the processes that held them. The reports confirm it: a crash report per cart actor, then child_terminated from the supervisor.
    Follow-ups

    From the lesson Gleam processes, actors and FFI

    Model answer, Pro.

    In the answer:

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

    A Gleam service binds an Erlang library function with @external, typed fn(String) -> Int. Its tests pass, but in production some requests crash with erlang:error(Badarg). The Gleam compiler never warned. Why, how do you find the bad input, and how do you fix the binding for good?

    What it tests
    Understanding that externals are trusted, the BEAM forms of Gleam types, reading the foreign function's documentation, wrapping a foreign function, and testing a binding on every target it claims.
    First step
    Start from the rule the language tour states: the compiler cannot see the types of foreign functions, so it trusts the annotation, and a wrong one fails at run time. Read the Erlang function's documentation for what it accepts and returns, and compare that with what a Gleam String is on the BEAM, a UTF-8 binary.
    Follow-ups

    From the lesson Gleam processes, actors and FFI

    Model answer, Pro.

    In the answer:

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

    After a release of the booking service, two customers turn up with tickets for the same seat. The service keeps one actor per show and its core is pure. How do you trace what let it happen, and what would you check first?

    What it tests
    Knowing where a one-actor design can still race, reading the message types as the place where decisions are split, and checking the process layout for two owners of one show.
    First step
    Ask how two decisions about one seat could both succeed. Inside one Hold handled by one actor they cannot, so look for a gap: a message pair that checks and then changes, such as an availability check followed by a write, or two actors that each believe they own the show. Compare the release's message types and the process tree with the last good release.
    Follow-ups

    From the lesson Project: a ticket-booking core in Gleam

    Model answer, Pro.

    In the answer:

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

    The booking service grows to 300 shows on sale at once. Design how processes are started, found and supervised, and what must survive a crash of one show's actor, given that holds last 10 minutes and confirmed sales must never be lost.

    What it tests
    Applying actors, supervisors and restarts to a real design: dynamic children, finding them without dynamic atoms, restart limits, and which state is durable and which may be lost.
    First step
    Keep one actor per show, because shows share no seats, and start them as needed under gleam_otp's factory supervisor. Find them through a registry, such as an actor holding a dict from show id to subject, not a process.new_name per show, since names are atoms that must not be created dynamically. Then decide what a restart may lose.
    Follow-ups

    From the lesson Project: a ticket-booking core in Gleam

    Model answer, Pro.

    In the answer:

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

All Language Atlas (mini-courses for more languages) interview questions · The Language Atlas (mini-courses for more languages) 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.