Alpha. Vary is under active development and not ready for production use. Syntax, APIs, performance, and behaviour may change between releases.

Python comparison

Vary vs Python

A side-by-side comparison of syntax and semantics. Python is a far more mature language with a larger ecosystem. Where Vary has something built in, Python typically has third-party equivalents.

For a property-testing-specific comparison, see Hypothesis comparison.

FeaturePythonVary
TypingDynamic, optional hintsStatic, enforced at compile time
ExecutionInterpretedCompiled to JVM bytecode
Variablesx = 42 (always mutable)let x = 42 / mut x = 0
Type annotationsOptionalParameter types required
Null handlingAnything can be NoneOnly T? types can be None
StringsstrStr
BooleansTrue / FalseTrue / False (same)
Collectionslist, dict, setList[T], Dict[K, V], Set[T]
Data types@dataclassdata keyword
InheritanceMultiple inheritanceNo inheritance; interface + implements
Enumsenum.Enumenum with payloads and exhaustive match
Pattern matchingmatch/case (3.10+)match/case with guards and or-patterns
Concurrencyasync/await, threadsspawn/join
Lambdaslambda x: x + 1lambda x: Int: x + 1 (typed)
Error handlingtry/except/raiseSame syntax
ContractsNo built-in (third-party: icontract, deal)Built-in in {} / out (r) {} / old()
Importsfrom x import ySame, plus aliases
Web/HTTPFlask, Djangoexpose Interface via http
Testingpytest, unittestBuilt-in test DSL + observe
Mutation testingThird-party (mutmut)Built-in vary mutate
RuntimeCPython / PyPyJVM (Eclipse Temurin 25)

Runtime differences

Python runs on CPython (or PyPy). Vary compiles to JVM bytecode and runs on the Java Virtual Machine. This has practical consequences:

AreaPythonVary
Startup timeFast (tens of ms)Slower (hundreds of ms due to JVM cold start)
Long-running performanceGood, but limited by GIL for CPU-bound threadsJIT-compiled over time; real multithreading
Memory modelReference counting + cycle collectorGarbage collected (G1, ZGC, etc.)
Integer sizeArbitrary precision64-bit (long)
Float size64-bit (double)64-bit (double)
CollectionsNative Python objectsJava ArrayList, HashMap, HashSet under the hood
Package ecosystempip, PyPI (500k+ packages)No package manager yet; stdlib only

Python starts faster. The JVM is a better fit for long-running services where JIT warmup pays off and real threading matters.

Python features intentionally excluded

Each conflicts with static analysis, predictable compilation, or explicit control flow.

FeatureWhy excluded
MetaclassesMakes class definition non-deterministic; breaks static analysis
General-purpose decoratorsHides control flow; conflicts with explicit execution
*args / **kwargsUndermines explicit signatures and static typing
Context managers (with)Requires implicit protocol hooks
Generators (yield)Hidden state machines; complicates bytecode generation
C extensionsIncompatible with JVM bytecode
Dynamic import hooksBreaks compile-time dependency analysis
Monkey patchingViolates immutability guarantees
Walrus operator (:=)Hides mutation inside expressions
Wildcard imports (from x import *)Makes static analysis non-local
Bare except:Swallows unexpected failures