๐Ÿงฌ
๐Ÿ“ How Programming Languages Work ยท PL-101 ยท Assignments

How Programming Languages Work โ€” Assignments

Work each problem yourself first, then open the worked solution to check your thinking. This is where the course sticks.

๐Ÿ“ 5 problemsโœ๏ธ Worked solutions
Problem 1

Describe the pipeline that turns source text into a running program.

Show worked solution

A strong answer names the stages - lexing (text to tokens), parsing (tokens to a tree/AST), interpreting or compiling (tree to running) - and explains a language is a translator, not magic.

Problem 2

Show the tokens a lexer would produce for a small expression, and describe the rules.

Show worked solution

Good answers break an expression into typed tokens (numbers, operators, names) and describe the lexer as a loop recognising each kind, skipping whitespace/comments.

Problem 3

Explain how a parser turns '2 + 3 * 4' into a tree that respects precedence.

Show worked solution

Strong answers describe building an AST whose shape encodes precedence (3*4 deeper/first), via recursive descent with one function per precedence level calling the next-tighter.

Problem 4

Describe how a tree-walking interpreter runs a node (e.g. addition, if, a call).

Show worked solution

Good answers explain evaluating a node by (often) evaluating its children then combining per the node type, with recursion handling nesting, and note the interpreter defines what constructs mean.

Problem 5

Argue when a domain-specific language is worth building versus a library.

Show worked solution

Strong answers set a high bar: a DSL wins for a recurring, domain-shaped problem where tailored notation is a real gain (possibly for non-programmers), while a library is better for most cases - citing larzscript (money) as a genuine DSL case.

More in this course

Course home → · Browse all courses →