Migration from Python
What changes coming from Python: the words, the indentation you already know, what has no equivalent, and what is stable in 1.0.
Venutian is not a dialect of Python. It reads close enough to English that a Python programmer feels at home in the first five minutes, then hits a short list of real differences. This page is that list.
Variables
No let, var, or const, same as Python. A name is bound with = the first time it is used, and rebound the same way:
count = 0
count = count + 1
Indentation
Blocks are marked by indentation, exactly like Python, with no braces and no end keyword. Every example in these docs indents by four spaces.
def becomes make, return becomes give
make add(a, b)
give a + b
A top level make is registered before any statement in the file runs, so it can be called from code written earlier in the file, before its own declaration is reached. Python's def has no equivalent to this; a function called before its def line runs in Python raises a name error.
if / elif / else becomes when / otherwise when / otherwise
when score >= 90
print "A"
otherwise when score >= 80
print "B"
otherwise
print "C"
No parentheses, no colon.
for and while keep their shape, with new words for break and continue
| Python | Venutian |
|---|---|
for x in y |
repeat for x in y |
while condition |
repeat while condition |
break |
stop |
continue |
skip |
match / case |
choose / is |
The loop bodies keep their shape. For the pattern matching form, see the language tour.
try / except becomes attempt / rescue
attempt
result = 10 / 0
rescue e
print "caught:", e
One rescue clause, no finally, no exception hierarchy to catch specific classes of. Every built in fault surfaces to rescue as plain Text; raising and catching your own structured value, a shape carrying fields, is the closer match to Python's class exceptions. See errors.
class becomes shape, with single inheritance
shape declares a plain, positionally constructed, mutable record, closer to a Python dataclass than to a full class. A shape can inherit another shape's fields with inherits, but it has no self and no methods attached to the shape itself; a shape holds data, and ordinary make functions take the record as an explicit first argument:
shape Person
name: Text
job: Text
make greeting(person)
give "Hi, " + person.name
bob = Person("Bob", "developer")
print greeting(bob)
Hi, Bob
Where a Python design reaches for a deep class hierarchy, hold one shape as a field of another instead, or use inherits for a single parent. See types and shapes.
import becomes use, and there is no module object
:: utils/mathy.ven
make double(n)
give n * 2
:: main.ven
use "utils/mathy.ven"
print double(21)
use is a compile time splice of another file's declarations into yours, resolved by path rather than by package name, and it brings every name in unqualified. There is no module.function() syntax, because there is no module object at runtime; see modules.
No dict, tuple, or set literal in the core syntax
Venutian's core types are Integer, Number, Text, Truth, Nothing, List, Function, and one type per declared shape. Where a Python program reaches for a dict, tuple, or set literal, reach for vcollections from the standard library instead: ordered maps, counters, and the other containers a program needs, written the same way any package is.
Type annotations are not enforced
A parameter list accepts a type annotation, and venutian check reads it, but a plain function call is never checked against it at the call site. A function declared a: Integer, b: Integer called with two Text values just runs. Treat annotations as documentation and as input to tooling, venutian tools among them, not as a runtime guarantee; see the CLI.
Threads, not an event loop
Python's asyncio and its async / await keywords have no counterpart. Venutian's spawn starts a real OS thread immediately, and await blocks until it finishes; share and protect give threads a safe way to touch the same variable. See concurrency for the full picture, including what spawn and await do not do.
What is stable today
Venutian 1.0.0 is the current release. Pin the exact version a project was built against, and recompile any .vbc file after an upgrade.
Where to go next
- Language tour for the full grammar in one pass.
- Types and shapes for the complete data model.
- Standard library for the containers and algorithms Python's built in functions and standard library cover.