This guide sets standards for Nevalang code to ensure consistency and readability.
Keep lines under 80 characters.
- Good for split-screen
- Fits larger fonts without scrolling
- Leaves space for IDE features (code lens, git blame, inline-hints, etc.)
- Allows reading full lines with eye movement
Use tabs over spaces.
- Tabs let users set their preferred width
- Tabs reduce file size
Group imports by type: stdlib, third-party, local. Separate groups with newlines if any group has more than 2 imports. Sort alphabetically within groups.
Names should inherit context from parent scope. Good naming eliminates need for comments. Names generally rather short than long.
- Packages/Files:
lower_snake_case
up to 3 words - Types:
CamelCase
up to 3 words - Interfaces:
CamelCase
withI
prefix up to 3 words - Constants:
lower_snake_case
up to 3 words - Components:
CamelCase
noun up to 3 words - Nodes:
lowerCamelCase
up to 3 words - Ports:
lowercase
, up to 5 characters
- Use outports to separate data flows, not for destructuring.
- Use
data
for input with payload,sig
for input without payload (trigger),res
for output with payload,sig
for output without payload (success), anderr
for failures. err
outport must be of typeerror
.sig
inport must be of typeany
for flexibility. Never useany
forres
outport.- Don't send input data downstream; the parent already has it.
- Use type-parameters to preserve type info between input and output.
- Omit port names when possible. It enables renaming of ports without updating the networks.