First Program¶
Let's write your first Desi program - the classic "Hello, World!"
Hello, World!¶
Create a new file called hello.desi:
Understanding the Code¶
Let's break down each part:
- Every Desi program needs a
mainfunction. The return type is optional! print()is a built-in function that outputs to the console
Run It¶
The simplest way — build and run in one step:
Output:
Or build an executable you can distribute:
🎉 Congratulations! You've just run your first Desi program!
A More Interesting Example¶
Let's create something more substantial - a greeting program:
# greet.desi
def greet(name: str) -> str:
return "Namaste, " + name + "!"
def main() -> int:
let message = greet("Desi Developer")
print(message)
# String interpolation with f-strings
let x = 10
let y = 20
print(f"Sum: {x + y}")
0
Run it:
Output:
Key Concepts¶
Variables¶
Use let for immutable variables:
Use var for mutable variables:
Functions¶
Define functions with def:
Or use the implicit return (last expression):
Comments¶
Return Types¶
String Interpolation¶
Creating a Project¶
For larger programs, use desic init to create a project with a desi.mod manifest:
This creates:
myapp/
├── desi.mod # Project manifest
├── src/
│ └── main.desi # Entry point
└── tests/ # Test files
What's Next?¶
Now that you can write basic programs, continue with:
- IDE Setup - Configure your editor for Desi
- Introduction Tutorial - Learn Desi in depth
- Variables & Types - All about types