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
- Types:
CamelCase
- Interfaces:
CamelCase
withI
prefix - Constants:
lower_snake_case
- Components:
CamelCase
noun - Nodes:
lower_snake_case
- Ports:
lowercase
- Use outports to separate data flows, not for destructuring.
- Use
data
for input,res
for output anderr
for failures. - Outport
err
must be of typeerror
. - Ports
data
andres
of typeany
are interpreted as signals. - Use name
sig
if you have extra trigger-inport. - Use names
then
andelse
if you implement boolean branching. - Use specific inport names if have more than one - e.g.
(filename, data)
forio.WriteAll
. - Use type-parameters to preserve type info between input and output if needed.
- Omit port names when possible. It enables renaming of ports without updating the networks.
- Use
?
for to propogate errors except custom error handling is needed.