Getting Started with Lyric
(note: lyric is not publicly released yet.)
Lyric is a modern programming language designed for clarity and expressiveness.
In this short tutorial, you’ll install Lyric, write your first program, and learn the basics of its syntax.
Installing Lyric
Lyric requires Python 3.10 or later.
- Lyric can be installed using pip (coming soon)
pip install lyric-lang
- Your First Lyric Program
Create a file called hello.ly:
def main() {
print("Hello from Lyric!")
}
Then run your script
lyric hello.ly
- Variables and Functions
- Define a function using def name(parameters) { ... }.
- Use return to send a value back to the caller.
- Call the function from main() — the entry point for your program.
def square(int n) {
return n * n
}
def main() {
int x = 5
print(square(x))
}
- Conditional Blocks
- Write a condition using if expression.
- Optionally add an else clause.
- Close the conditional with end.
- Indentation is optional but encouraged for readability.
def main() {
int x = 10
if x < 10
print("less than")
else
print("not less than")
end
}
- Control Flow
- Start a loop with given variable in range(...).
- Write your loop body normally.
- Close the loop with done.
- Lyric's range() function works like Python's — it generates a sequence of numbers.
def main() {
int total = 0
given i in range(5):
total += i
done
print(total)
}
- Using Python Modules
- Use importpy module to access a Python package.
- Call any function or class from that module as usual.
- This allows Lyric to leverage Python's ecosystem for advanced features.
importpy math
def main() {
print(math.sqrt(16))
}
- Exception Handling
- Start a protected block with
try:. - Use a generic
catch: to handle any runtime errors raised inside the try block. - Add an optional
finally: block for code that should always run — even if an error occurs. - End the structure with
fade.
def main() {
var items = [1, 2, 3]
try:
var x = items[5] # will raise an error
print("This won't run.")
catch:
print("Something went wrong.")
finally:
print("Cleanup runs no matter what.")
fade
}
- Next Steps
- Explore the Lyric Language Specification
- Follow Lyric's on-going development at MiraNova Studios
Thank you
Thank you for exploring Lyric — we hope this tutorial helped you understand the language’s clarity and simplicity.
Lyric is still evolving, and your interest and feedback help shape its future.
