Why can some people build a whole compiler while I struggle to structure a small program?

November 13, 2026 5 answers
Asked by almost.a.muffin

I can usually describe what I want a program to do, but I get stuck deciding how to break it into functions and turn it into code. Seeing someone build a compiler makes the gap feel huge.

Is this a normal part of learning? What can I practice to get better at designing solutions rather than just remembering syntax?

Answers

p3+parcel_861

Compiler can mean a lot of different things. A tiny language that translates a few expressions is a much smaller project than a compiler for a large language with useful error messages and optimizations. Someone building one may also be relying on patterns they have practiced before.

Try shrinking the goal. For a toy compiler, you could start with input like 2 + 3 and decide what output you want. Then separate the work into reading the input, recognizing its structure, and producing the output. Get that one case working before adding variables or more operators.

r4+sparekey_719:

And if even that feels too big, write a calculator that evaluates a single expression first. You can add translation to another format later.

Reply to this answer
y208!sundial

Put a step between the idea and the code. Write down a concrete input and expected output, then describe what has to happen in plain language. Keep splitting those steps until each one feels small enough to implement or test.

For example, instead of starting with a whole card game, start with making a deck, then shuffling it, then drawing one card. The first version of those functions does not need to be elegant. Once they work together, you have something specific to reorganize.

Reply to this answer
offbeat-but-accountable

Make an ugly version first. Seriously. A long chain of conditions or a hard-coded example can teach you more than staring at an empty editor trying to invent the perfect design.

After it works, find one awkward part and clean it up. You can even build the same small project again with a different structure and compare what became easier or harder.

Reply to this answer
Merrik

Do some small exercises without immediately looking up a complete solution. Give yourself time to get stuck, write down what you tried, and test little pieces. That struggle is practice at turning a vague goal into steps, not evidence that you cannot learn it.

You do not have to refuse help forever, though. If you are stuck, look for a hint or study a solution, then close it and try to rebuild the idea yourself.

almost.a.muffin:

So reading a solution is still useful as long as I make sure I can apply the idea myself?

c904~stencil_2:

Yes. Changing the exercise afterward is a good check. See whether you can adapt the approach without following the original line by line.

Reply to this answer
!recheck~the+foldout

Reading code helps, but make it active. Pick a small project or written tutorial, work out what each part does, then change a feature or deliberately break something and fix it. A finished design can look obvious without showing all the revisions that led to it.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions