Learn NME by making seven programs
This path starts with one sentence and ends with a compiler. Run every example before moving on; changing a word and observing the result is part of learning.
Project 1: Hello World
Create hello.nme (in the same folder where you ran nme --version; any text
editor works — on Windows, Notepad saves UTF-8 by default):
show Hello world!
run it →nme run hello
show is an action. Everything after it is the sentence to display. Korean is
equally valid:
안녕하세요! 말해줘
run it →Try changing the message. Run
examples/hello-sentence.nme when you want
to see a repeat too, or
examples/hello-sentence.ko.nme for the
Korean twin.
Project 2: A greeting program
What is your name?
Nice to meet you name!
run it →The first line creates the name name from an ordinary question. The second
line recognizes that known name and inserts its value. The Korean version needs
no formatting syntax:
이름이 뭐예요?
이름 만나서 반가워요!
run it →Challenge: ask for a favorite color and show it in another sentence.
Project 3: Number guessing
Start with a random answer and numeric input:
set answer to random number from 1 to 10
ask number guess Pick a number from 1 to 10
run it →Then compare them:
if guess equals answer
show Correct!
if guess is less than answer
show Go higher
if guess is greater than answer
show Go lower
run it →The complete Korean program is
examples/guessing-game.ko.nme; its
English twin is
examples/guessing-game.nme:
nme run examples/guessing-game.ko
What was compiled:
1부터 10까지 랜덤정수becomes__import__("random").randint(1, 10);숫자로 물어봐becomesint(input(...));같으면,작으면, and크면become==,<, and>;- indentation groups the statements controlled by each condition.
Challenge: change the range to 1–100, then add a second guess by repeating the input and conditions.
If indentation is getting in the way, write the same control flow as one flat
block and close it with end:
while guess is not equal to answer
show Try again
ask number guess Pick another number
end
run it →!= means 'not equal to'; its sentence spelling is is not equal to.
Use break, and/or, elif, and else in the same style. Their Korean
spellings are 멈춰, 그리고/또는, 아니면 만약에, and 아니면.
Project 4: Greet a list of names
So far every program held one value at a time. A list holds several, and a
list is written as a sentence too. Make friends.nme:
set friends to list of Mina, Ada, Grace
for each friend in friends
show Hello friend!
wait 1 second
end
run it →nme run friends
It greets all three, one per second.
set friends to list of Mina, Ada, Gracebuilds a list of three names.for each friend in friendswalks the list from start to end, calling whichever one it is holdingfriend.wait 1 secondpauses before the next line.
You can also start empty and add one at a time.
set friends to empty list
append Mina to friends
append Ada to friends
show friends
run it →Challenge: ask for a name three times, append each answer, then greet them all.
Four programs in, and nothing so far has needed a quote, a bracket, a colon or
an =. Sentence syntax carried all four on its own. The next two projects
are for someone who already knows Python, or who one day wants to. Skipping them
now costs you nothing — guides 86 to 88 continue in sentences.
Project 5: Use all three levels
Sentence syntax is not a cage. Use compact beginner syntax or Python whenever it says the idea more clearly:
people = ["Ada", "Grace"]
2 times:
say "beginner syntax"
repeat 2 times
한국어 문장형 말해줘
for person in people:
show Hello person!
run it →The list and for person loop are advanced Python. 2 times: and say are
beginner NME. repeat and show are sentence NME. This is one language, not
three files or modes. Run
examples/three-levels.nme. The finished
flat-control-flow pair is
examples/control-flow-sentence.nme
and
examples/control-flow-korean.nme — run
both and compare the identical output.
Try adding a flat NME block beside the Python loop:
while person != "Grace"
show Hello person
break
end
run it →Challenge: write a Python function and use sentence show inside it.
Project 6: Move one game toward Python
The time-loop mystery is the same project written at three levels. Start with the conversational English version, then compare the compact beginner version, and finally read the ordinary Python version:
time-loop-sentence.nme— easiest sentences,end, and natural conditions; the Korean twin istime-loop-sentence.ko.nme;time-loop-beginner.nme— compactsave,ask,when, andN times:forms.saveis the beginner store action (e.g.save score to 3); the Korean twin istime-loop-beginner.ko.nme;time-loop-python.en.nme— lists, dictionaries, f-strings,while,break, and ordinary Python (Korean twin:time-loop-python.nme).
All three compile with the same command:
nme check examples/time-loop-sentence
nme check examples/time-loop-beginner
nme check examples/time-loop-python.en
For a larger standalone example before the Python version feels comfortable,
try the Korean roulette.nme. Its English
companion is roulette.en.nme.
Run one when you are ready to answer its prompts. The point is not to rewrite the whole project at once: replace one block or line with the next level and keep the rest of the program unchanged.
Project 7: Build a compiler in NME
This is an optional advanced capstone, not a new syntax level. Before opening it, make sure the earlier projects feel comfortable. If indexing, slices, or Python method calls are still new, leave this project for later and keep building small programs with sentence and beginner NME first:
count = 0
while count < 2
add 1 to count
end
2 times: say "one small rule"
run it →A compiler reads one language and writes another. It does not need to execute
the source directly. The example
examples/tiny-compiler.en.nme compiles this
tiny two-sentence language:
say Hello
3 times say I built a compiler in NME
run it →The compiler produces Python equivalent to:
print('Hello')
for _ in range(3): print('I built a compiler in NME')
Run the compiler, then inspect the compiler's own generated Python:
nme run examples/tiny-compiler.en
nme build examples/tiny-compiler.en -o tiny-compiler.py
The example deliberately mixes advanced Python for list processing with sentence NME for its output. That is how a beginner can grow a compiler one small rule at a time while retaining the full Python ecosystem.
To turn it into a file compiler:
- Add
from pathlib import Pathat the top, then replacetiny_sourcewithinput_name = "tiny.txt"andPath(input_name).read_text(encoding="utf-8").splitlines(). - Define
output_name = "tiny.py"and writegeneratedwithPath(output_name).write_text(generated, encoding="utf-8"). - Add a friendly error for any line that matches neither tiny sentence.
- Add tests that compile a source file and run the generated Python.
This mirrors NME's real architecture at a smaller scale: tokenize or classify input, create a precise intermediate meaning, lower it to target code, and test the result. NME's production compiler is written in Rust for reliability and distribution, but compilers made with NME may use all of NME and Python.
Your next steps
- Read the language reference only when you need an exact rule.
- Use
nme checkafter every small change. - Convert an existing Python exercise with nme convert.
- Build a native artifact only after the program works with
nme run.