Quickstart Guide
A quickstart guide to help you run Dorpn v0.4.0+ programs on the go — from your
first print() to structured programs with _Start().
1. Output
The print() function writes to stdout followed by a newline. Multiple arguments are separated by
a space automatically.
print("Hello, World!")
print("Score:", 100, "| Passed:", true)
2. Variables & Constants
Use tag to declare a mutable variable. Dorpn infers the type from the assigned value, or you can
annotate it explicitly using :Type.
tag name = "Jordan"
tag age = 19
tag temperature = 36.6
tag active = true
Explicit type annotation:
tag username :String = "Jordan"
tag level :Int = 42
tag rating :Float = 8.75
tag verified :Bool = false
Use Const for values that must not change after declaration:
Const MAX_RETRIES = 5
Const APP_NAME = "MyApp"
Const TAX_RATE = 0.15
3. User Input
ask() reads a line from stdin and returns it as a String. The prompt is displayed
inline before input.
tag username = ask("Enter your username: ")
tag city = ask("Enter your city: ")
print("Welcome,", username)
print("Location set to:", city)
4. Conditional Logic
Dorpn uses if, elif, and else for branching. Conditions are
indentation-scoped — no braces required.
tag score = 85
if score >= 90:
print("Grade: A")
elif score >= 75:
print("Grade: B")
elif score >= 60:
print("Grade: C")
else:
print("Grade: F — please retry")
Boolean expressions work directly as conditions:
tag isAdmin :Bool = true
tag isVerified :Bool = false
if isAdmin and isVerified:
print("Full access granted")
elif isAdmin:
print("Admin access — verification pending")
else:
print("Access denied")
5. Loops
Fixed iteration loop:
loop 5:
print("Iteration running...")
Loop with an index variable:
loop i in 10:
print("Step", i)
Building a pattern with a loop:
tag height = 6
loop row in height:
tag stars = row * 2 + 1
tag spaces = height - row - 1
print(" ".repeat(spaces) + "*".repeat(stars))
6. Keep — Conditional Loop
keep repeats a block as long as its condition holds. Use halt to exit the loop
early, and skip to jump to the next iteration.
tag attempts = 0
tag password = ask("Enter password: ")
keep password != "secure123":
attempts = attempts + 1
if attempts >= 3:
print("Too many failed attempts. Exiting.")
halt
print("Wrong password. Try again.")
password = ask("Enter password: ")
print("Access granted.")
halt breaks out of the enclosing loop entirely. skip
jumps immediately to the next iteration, similar to continue in other languages.7. Functions
Functions are declared with func. Parameters require explicit type annotations. The return type
is specified after -> when the function returns a value.
func greet(name :String, role :String):
print("Welcome,", name)
print("Role assigned:", role)
greet("Jordan", "Developer")
Function with a return value:
func calculateTotal(price :Float, quantity :Int) -> Float:
return price * quantity
tag total = calculateTotal(12.5, 4)
print("Total cost:", total)
Functions can call other functions:
func square(n :Int) -> Int:
return n * n
func sumOfSquares(a :Int, b :Int) -> Int:
return square(a) + square(b)
tag result = sumOfSquares(3, 4)
print("Sum of squares:", result)
Functions with no return value — void v0.4.0+
Use void after -> to mark a function that intentionally returns nothing.
void is alternative of pass. It only exists in the
function body blocks, to
make the "returns nothing, on purpose" intent explicit and readable — it isn't part of Dorpn's type set
(Int, Float, String, Bool, and their 32-bit
counterparts).func logStatus(msg :String):
void #pass this function
8. String Operations
Strings support concatenation with +. Numbers are automatically coerced when combined with
strings.
tag firstName = "Ada"
tag lastName = "Lovelace"
tag fullName = firstName + " " + lastName
print(fullName)
print("─".repeat(20))
print("Characters:" , fullName)
Built-in string methods:
tag word = "Dorpn"
print(word.flip()) # nproD
print(word.alter("D", "d")) # dorpn
print("*".repeat(15)) # ***************
9. Types & 32-bit Variants
Dorpn supports standard types and their 32-bit counterparts for lower memory usage.
tag a :Int = 1000
tag b :Int32 = 1000
tag c :Float = 3.141592
tag d :Float32 = 3.141592
tag e :String = "Hello"
tag g :Bool = true
print(type(a), type(b))
print(type(c), type(d))
Bool32 and String32 were deprecated in earlier
pre-releases and have now been fully removed from the lexer, parser, and type system.
Using either name is now a compile error — use Bool and String instead.
Int32 and Float32 are unaffected and remain valid.
10. Entry Point — _Start()
By default, any top-level code in Dorpn executes automatically. This works for small scripts. However, for
structured programs with multiple functions and complex logic, Dorpn supports an explicit entry point using
_Start().
Without _Start() — top-level execution
func calculateTotal(price :Float, quantity :Int) -> Float:
return price * quantity
tag total = calculateTotal(12.5, 4)
print("Total cost:", total)
Top-level tag statements and calls execute directly inside the generated main().
Simple and sufficient for short scripts.
With _Start() — explicit entry point
func loadConfig(path :String):
tag file :String = Onload(path)
print("Config loaded:", file.size(), "bytes")
func displayWelcome(name :String):
print("─".repeat(30))
print("Welcome,", name)
print("─".repeat(30))
func _Start():
tag name = ask("Enter your name: ")
loadConfig("config.txt")
displayWelcome(name)
When _Start() is defined, Dorpn automatically calls it at the end of the generated
main(). All other functions act as helpers — _Start() is the single controlled entry
point for the entire program.
| Scenario | Approach |
|---|---|
| Quick scripts, simple calculations | Top-level code, no _Start() needed |
| Multiple functions, structured logic | Define _Start() as the entry point |
| Programs that scale or grow over time | Always prefer _Start() |
11. Complete Example
A small program combining everything covered above:
Const MAX_SCORE = 100
func getGrade(score :Int) -> String:
if score >= 90:
return "A"
elif score >= 75:
return "B"
elif score >= 60:
return "C"
else:
return "F"
func printReport(name :String, score :Int):
tag grade = getGrade(score)
print("─".repeat(30))
print("Student :", name)
print("Score :", score, "/", MAX_SCORE)
print("Grade :", grade)
print("─".repeat(30))
tag name = ask("Enter student name: ")
tag score = ask("Enter score: ")
printReport(name, score)
12. Compiling to JavaScript v0.4.0+
Alongside the native C backend, Dorpn can also compile a .dpn file straight to JavaScript —
useful for scripting and quick testing without a native build step. Use the -js flag (or its
longer alias --Javs) when compiling:
# Compile to JavaScript
dorpn program.dpn -js
# Alternative flag (same result)
dorpn program.dpn --Javs
The C backend stays the default — plain dorpn program.dpn still produces a native executable.
Adding either flag switches the compile target to JavaScript instead.
-js. Future
releases will keep expanding parity between the two.Where to Go Next
Click through to dive deeper into the current available features of the Dorpn v0.4.x series.
| Guide | Contents |
|---|---|
| Variables & Scope | Variable declaration, scope, and mutation rules |
| Type System | Full type system including 32-bit variants |
| Operators | Arithmetic, comparison, and logical operators |
| Built-in Functions | ask, print, type, min, max,
add and more
|
| Built-in Methods | String methods — .repeat(), .flip(), .alter() |
