Build yourself a tool, fool!

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Build yourself a tool, fool!

Debugging complex business logic is hard: there's an intentional disconnect between what you see as an end user and what actually happens under the hood. So we reach for tools: debuggers, println, or more recently - AI agents.

But why stop there? The best tools are the ones that solve a specific problem, and with AI it's never been easier to write (and delete) throwaway code.

In this talk, using an elaborate playlist generator as an example, I'll show you why you should consider building tools specific to your application, and share a few lessons I've learned in the process of building my own.

Jakub Kozłowski

December 03, 2026

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

54 slides
  1. Build yourself a tool, fool! Art of Scala | Warsaw,

    December 3, 2026 Jakub Kozłowski, Principal Engineer @ SiriusXM
  2. First… let’s build our application! Playlist generator Rule-based Talks From

    a few recent Scala conferences Ads For Scala libraries
  3. Main API Create a playlist: get its ID and the

    first few items Extend it: attempt to get the next item Defined in Smithy IDL 2.1 operation CreatePlaylist { output := { @required playlistId: PlaylistId @required items: [PlaylistItem] } } operation ExtendPlaylist { input := { @required playlistId: PlaylistId } output := { item: PlaylistItem } }
  4. Main API Create a playlist: get its ID and the

    first few items Extend it: attempt to get the next item Defined in Smithy IDL 2.1 operation CreatePlaylist { output := { @required playlistId: PlaylistId @required items: [PlaylistItem] } } operation ExtendPlaylist { input := { @required playlistId: PlaylistId } output := { item: PlaylistItem } }
  5. Playlist items Scala and TypeScript Synergy Mihaela Gheorghe-Roman circe Ad

    union PlaylistItem { talk: Talk ad: Ad } structure Talk { @required title: String @required speakers: [Speaker] @required thumbnailUrl: String } structure Ad { @required name: String @required logoUrl: String }
  6. Playlist items Scala and TypeScript Synergy Mihaela Gheorghe-Roman circe Ad

    union PlaylistItem { talk: Talk ad: Ad } structure Talk { @required title: String @required speakers: [Speaker] @required thumbnailUrl: String } structure Ad { @required name: String @required logoUrl: String }
  7. Playlist items Scala and TypeScript Synergy Mihaela Gheorghe-Roman circe Ad

    union PlaylistItem { talk: Talk ad: Ad } structure Talk { @required title: String @required speakers: [Speaker] @required thumbnailUrl: String } structure Ad { @required name: String @required logoUrl: String }
  8. Sample rules We don’t repeat talks or ads No back-to-back

    talks with the same speaker At least one in 5 talks with a female speaker Talks about AI exactly 2 positions apart Talks take at most 35 minutes
  9. Why don’t my own talks show up? It’s hard to

    know how the rules behave, even if you know the configuration… but the end-user UI doesn’t show that. 1 Optimizing Scala bytecode for fun and profit 2 Migration Without Tears: 2,000 Projects, One New LTS 3 Solal Pirelli Wojciech Mazur Ad circe Yet another JSON library for Scala
  10. Why don’t my own talks show up? It’s hard to

    know how the rules behave, even if you know the configuration… but the end-user UI doesn’t show that. 1 Optimizing Scala bytecode for fun and profit 2 Migration Without Tears: 2,000 Projects, One New LTS 3 Solal Pirelli Wojciech Mazur Ad circe Yet another JSON library for Scala ???
  11. We hide a lot from our users Playlist Where your

    data is stored Which service has it What you did to it The experience the users are (not) paying for
  12. We hide a lot from our users Playlist Where your

    data is stored Which service has it What you did to it The experience the users are (not) paying for Users don't see it
  13. We hide a lot from our users Playlist Where your

    data is stored The experience the users are (not) paying for Users don't see it Which service has it What you did to it We don't see it either
  14. General-purpose tools They work on any program, so they know

    nothing about your domain. case Rule.AtLeastOneIn(n, predicate, _) => val sameKind = history.filter(kindOf(_) == kind) val window = sameKind.takeRight(n - 1) // ...
  15. General-purpose tools They work on any program, so they know

    nothing about your domain. case Rule.AtLeastOneIn(n, predicate, _) => val sameKind = history.filter(kindOf(_) == kind) val window = sameKind.takeRight(n - 1) // ... RuleEngine.scala:273 Enabled Condition: Stops N times
  16. General-purpose tools They work on any program, so they know

    nothing about your domain. case Rule.AtLeastOneIn(n, predicate, _) => val sameKind = history.filter(kindOf(_) == kind) val window = sameKind.takeRight(n - 1) // ... RuleEngine.scala:273 Enabled Condition: history.size == 50 What if you want to go back to item 39 again?
  17. General-purpose tools They work on any program, so they know

    nothing about your domain. case Rule.AtLeastOneIn(n, predicate, _) => val sameKind = history.filter(kindOf(_) == kind) val window = sameKind.takeRight(n - 1) // ... RuleEngine.scala:273 Enabled Condition: candidates.exists(isMine) What about other types of rules used?
  18. General-purpose tools They work on any program, so they know

    nothing about your domain. case Rule.AtLeastOneIn(n, predicate, _) => val sameKind = history.filter(kindOf(_) == kind) val window = sameKind.takeRight(n - 1) // ... RuleEngine.scala:273 Enabled Condition: candidates.exists(isMine) What about other types of rules used? Step-through debuggers weren’t meant for this.
  19. Step 1: a richer, stateless API Explicit inputs Rules Random

    seed Past results Explicit outputs Results Log messages Other diagnostics operation Preview { input := { @required rules: RuleSet @required seed: Long @required history: [ItemId] // ... } output := { @required trace: [GenerationStep] } }
  20. Step 1: a richer, stateless API Explicit inputs Rules Random

    seed Past results Explicit outputs Results Log messages Other diagnostics operation Preview { input := { @required rules: RuleSet @required seed: Long @required history: [ItemId] // ... } output := { @required trace: [GenerationStep] } }
  21. One core, two APIs Main API keeps only the items

    Core logic returns a full trace Preview API keeps everything
  22. Start small structure GenerationStep { item: PlaylistItem @required pickedFrom: Integer

    } Scala and TypeScript Synergy Mihaela Gheorghe-Roman picked from 7
  23. How many rules applied to a step? structure GenerationStep {

    item: PlaylistItem @required pickedFrom: Integer @required evaluations: [Evaluation] } structure Evaluation { @required rules: [RuleEvaluation] } structure RuleEvaluation { @required rule: Rule @required outcome: RuleOutcome @required matchedBefore: Integer @required matchedAfter: Integer } Scala and TypeScript Synergy Mihaela Gheorghe-Roman picked from 7 No repeats Female speaker: 1 in every 5 Speaker from PL: every 3 At most 35 min 74→70 70→10 10→8 8→7 applied applied applied applied
  24. Why didn’t a rule match a talk? structure RuleEvaluation {

    @required rule: Rule @required outcome: RuleOutcome @required matchedBefore: Integer @required matchedAfter: Integer @required rejected: [ItemRef] @required attributes: [ItemAttribute] @required logs: [String] @required context: RuleContext } Scala and TypeScript Synergy Mihaela Gheorghe-Roman picked from 7 No repeats 74→70 Female speaker: 1 in every 5 70→10 Speaker from PL: every 3 10→8 At most 35 min 8→7 id alreadyPlayed: 8 applied rejected: 4 applied speaker windowSize: 4 rejected: 60 None of the last 4 talks has a female speaker, so this one must speaker distance: 2 duration applied rejected: 2 applied rejected: Future of Programming
  25. Why didn’t a rule match a talk? structure RuleEvaluation {

    @required rule: Rule @required outcome: RuleOutcome @required matchedBefore: Integer @required matchedAfter: Integer @required rejected: [ItemRef] @required attributes: [ItemAttribute] @required logs: [String] @required context: RuleContext } Which items the rule filtered out Scala and TypeScript Synergy Mihaela Gheorghe-Roman picked from 7 No repeats 74→70 Female speaker: 1 in every 5 70→10 Speaker from PL: every 3 10→8 At most 35 min 8→7 id alreadyPlayed: 8 applied rejected: 4 applied speaker windowSize: 4 rejected: 60 None of the last 4 talks has a female speaker, so this one must speaker distance: 2 duration applied rejected: 2 applied rejected: Future of Programming
  26. Why didn’t a rule match a talk? structure RuleEvaluation {

    @required rule: Rule @required outcome: RuleOutcome @required matchedBefore: Integer @required matchedAfter: Integer @required rejected: [ItemRef] @required attributes: [ItemAttribute] @required logs: [String] @required context: RuleContext } What the rule looks at in each item. Always the same for that rule Scala and TypeScript Synergy Mihaela Gheorghe-Roman picked from 7 No repeats 74→70 Female speaker: 1 in every 5 70→10 Speaker from PL: every 3 10→8 At most 35 min 8→7 id alreadyPlayed: 8 applied rejected: 4 applied speaker windowSize: 4 rejected: 60 None of the last 4 talks has a female speaker, so this one must speaker distance: 2 duration applied rejected: 2 applied rejected: Future of Programming
  27. Why didn’t a rule match a talk? structure RuleEvaluation {

    @required rule: Rule @required outcome: RuleOutcome @required matchedBefore: Integer @required matchedAfter: Integer @required rejected: [ItemRef] @required attributes: [ItemAttribute] @required logs: [String] @required context: RuleContext } The reasoning, in words Scala and TypeScript Synergy Mihaela Gheorghe-Roman picked from 7 No repeats 74→70 Female speaker: 1 in every 5 70→10 Speaker from PL: every 3 10→8 At most 35 min 8→7 id alreadyPlayed: 8 applied rejected: 4 applied speaker windowSize: 4 rejected: 60 None of the last 4 talks has a female speaker, so this one must speaker distance: 2 duration applied rejected: 2 applied rejected: Future of Programming
  28. Why didn’t a rule match a talk? structure RuleEvaluation {

    @required rule: Rule @required outcome: RuleOutcome @required matchedBefore: Integer @required matchedAfter: Integer @required rejected: [ItemRef] @required attributes: [ItemAttribute] @required logs: [String] @required context: RuleContext } Free-form JSON: the data behind the reasoning, at this step Scala and TypeScript Synergy Mihaela Gheorghe-Roman picked from 7 No repeats 74→70 Female speaker: 1 in every 5 70→10 Speaker from PL: every 3 10→8 At most 35 min 8→7 id alreadyPlayed: 8 applied rejected: 4 applied speaker windowSize: 4 rejected: 60 None of the last 4 talks has a female speaker, so this one must speaker distance: 2 duration applied rejected: 2 applied rejected: Future of Programming
  29. What to use for the frontend? It depends… Yes Will

    others use it? JavaScript / TypeScript Scala.js? I probably wouldn't: JS/TS has better developer experience, more UI libraries No, but I like the Web platform No A desktop app Swift, maybe Flutter?
  30. Useful tool: Smithy IDL What about API clients? Language Codegen

    Scala smithy4s TypeScript smithy-ts-codegen Swift smithy-swift / custom codegen
  31. Frontend-specific endpoints For information the API doesn’t expose. Thin backend

    GET /bff/items Frontend API /api/* for picking a history GET /bff/items/:id/preview for hover cards No longer just static files Data catalog talks and ads read-only!
  32. Auto-updating results: yes or no? Only if the output is

    deterministic Let people opt out Debounce expensive calls Don’t make the layout jump At most 30 min Cats Go Wasm/WASI: Typelevel on Serv… 8 min Scala and C – tight as brothers 28 min On Folding 30 min A Typelevel Prospectus 28 min
  33. Deployment: go serverless These tools mostly sit unused, so you

    can run them serverless to reduce spend. 1 day 10 calls Watch out for footguns: Streamed responses Large responses
  34. Q: Is this still relevant in the age of agents?

    Are YOU still relevant? Agents can fix your code but they can’t understand it for you
  35. Q: Is this still relevant in the age of agents?

    Are YOU still relevant? Agents can fix your code but they can’t understand it for you At least build these APIs so that the model can quickly experiment on its own. Make an MCP?
  36. Q: I don’t want to vibe code a complex user

    interface Then don’t. You can, and should, apply proper engineering practices: testing, CI/CD, some kind of human review
  37. Summary APIs hide complexity from users, and from us Expose

    the same logic through a richer API, with a full trace Build a UI that speaks your domain’s language Start small, keep iterating, don’t overthink it
  38. Links Slides & code, past talks, YouTube videos: https://linktr.ee/kubukoz Smithy

    IDL smithy-ts-codegen Pain-free APIs with Smithy4s (slides)

More Decks by Jakub Kozłowski

Other Decks in Programming