# Language Profiles

---

# Language Conventions

_Standards and Conventions / Language Profiles_

> How language profiles apply common rules without adopting entire external guides.

These profiles apply the common rules through each language's syntax and
established conventions. They do not adopt every recommendation in an external
styleguide. An external guide's preferences do not override explicit Peios
decisions such as the shared 100-column target.

---

# Rust

_Standards and Conventions / Language Profiles_

> Peios coding conventions for Rust.

Use four spaces, a 100-column formatter target, `snake_case`
functions/modules, `PascalCase` types, and `SCREAMING_SNAKE_CASE` constants.
Follow `rustfmt` for mechanical layout. Use the edition and formatter
version selected by the project. Required Rust braces remain required; a short
early return can be expanded by the formatter.

Apply the ownership and error rules using ordinary Rust mechanisms: `Option`
for absence, `Result` for expected failures, and ownership/`Drop` for resource
lifetimes. Use `mut` where mutation is needed and keep visibility narrow. An
`unsafe` block needs the safety explanation required by the common guide,
including assumptions maintained outside the block.

Reference: [Rust style guide](https://doc.rust-lang.org/style-guide/).

---

# Go

_Standards and Conventions / Language Profiles_

> Peios coding conventions for Go.

Follow `gofmt`, including tab indentation and automatic alignment. Use
`mixedCaps` for unexported identifiers and `MixedCaps` for exported
identifiers, including types and constants; initial capitalization controls
visibility. Use short lowercase package names and conventional abbreviations
such as `ID` and `HTTP`. These are language exceptions to the common naming
table.

Keep the 100-column readability target where practical, but do not fight
`gofmt` or treat it as a hard limit; `gofmt` has no configurable wrapping
target. Go requires braces around control-flow bodies.

Apply the common cleanup rule using `defer` where its function-exit lifetime
is appropriate. Check meaningful cleanup errors. Ordinary failures use error
values; a goroutine still needs an owner and shutdown/failure handling.

References: [Effective Go](https://go.dev/doc/effective_go) and [Go code
review comments](https://go.dev/wiki/CodeReviewComments).

---

# Python

_Standards and Conventions / Language Profiles_

> Peios coding conventions for Python.

Use four spaces and the shared naming conventions. Retain the Peios 100-column
target rather than adopting PEP 8's shorter line recommendation. Use
docstrings for the public interfaces and non-obvious contracts covered by the
common rule.

Give ordinary functions in maintained Python code type hints for parameters
and return values, including functions in maintained scripts. Allow justified
exceptions, and omit redundant annotations such as the usual `self` parameter.
For example, `def load_config(path: Path) -> Config` makes the interface
clear.

Type hints support readers and automatic checking; they do not validate
incoming data at runtime. The validation-boundary rules still apply.

Use context managers for scoped resource cleanup where appropriate. Use the
language's explicit absence value, `None`, without conflating it with valid
values such as zero or an empty collection.

References: [PEP 8](https://peps.python.org/pep-0008/) and [Python typing
guidance](https://typing.python.org/en/latest/guides/libraries.html).

---

# JavaScript and TypeScript

_Standards and Conventions / Language Profiles_

> Peios coding conventions for JavaScript and TypeScript.

Use conventional `camelCase` variables/functions and `PascalCase`
types/classes. Use the shared constant naming rule for named constants, not
for every local binding declared with `const`. Keep four spaces and the
100-column target: a formatter's two-space default alone does not override the
Peios baseline.

Apply read-only-by-default to bindings with `const`, and use `let` where
reassignment is needed. Remember that `const` does not freeze object contents.
The common optional-brace and explicit-argument rules apply.

In TypeScript, use strict type checking by default. Avoid `any` as a way to
bypass checking; use `unknown` for values that must be checked before use.
Allow narrow, explained exceptions where needed, such as integration with an
untyped third-party interface. Type declarations alone do not validate
external data.

That type-checking requirement concerns TypeScript; this guide does not itself
require converting JavaScript projects to TypeScript. Apply the approved
common quote preference and explicit semicolons using the pinned formatter
settings.

References: [TypeScript strict
checking](https://www.typescriptlang.org/tsconfig/strict.html) and [MDN
JavaScript
conventions](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Code_style_guide/JavaScript).

---

# C

_Standards and Conventions / Language Profiles_

> Peios coding conventions for C.

Prefer explicit struct names, such as `struct Buffer`, rather than introducing
a typedef solely to omit the `struct` keyword. Allow typedefs when they
provide a useful abstraction, such as an opaque library handle.
Kernel-specific rules remain separately scoped.

Write pointer declarations with the star next to the declared name, as in
`char *name`. Normally declare one variable per statement. Allow compact loop
declarations when their meaning remains clear. Avoid declarations such as
`char* first, second`, where only the first variable is a pointer.

Prefer ordinary functions, including inline functions where appropriate, over
function-like macros. Use function-like macros when preprocessor capabilities
are actually needed. Named constants and conditional compilation remain valid
uses of the preprocessor.

The common formatting and naming defaults apply outside documented repository
exceptions. This means, for example, four spaces and same-line function braces
for ordinary Peios C, but the Linux profile for kernel C.

---

# Shell

_Standards and Conventions / Language Profiles_

> Peios coding conventions for Shell.

Keep shell focused on connecting existing commands. Move substantial parsing
or application logic to a more suitable language, considering complexity and
the available runtime rather than imposing a hard script-length cutoff.

Make the intended interpreter explicit and use syntax supported by that
interpreter. Apply the error and cleanup rules to command exit statuses,
pipelines, and temporary resources. Preserve argument boundaries when
expanding values: filenames containing spaces must not silently become several
arguments. Use four-space indentation where shell syntax permits it; syntax
that requires literal tabs retains them.

---

# Bazel and Starlark

_Standards and Conventions / Language Profiles_

> Peios coding conventions for Bazel and Starlark.

Use four spaces, `snake_case` functions/variables, and explicit `load`
imports. Use the language's underscore-prefixed private top-level names. Keep
the shared 100-column readability target, allowing intact labels where
splitting them is not useful. Starlark is not Python; Python-only typing and
syntax rules do not apply to it.

Use `buildifier` as the formatting baseline. Keep target declarations readable
and use shared abstractions for shared concepts rather than merely hiding
repeated declarations. Document public `.bzl` interfaces and their contracts.

Reference: [Bazel's Starlark guide](https://bazel.build/rules/bzl-style).

---

# Other Formats and Languages

_Standards and Conventions / Language Profiles_

> Peios coding conventions for other formats and languages.

Respect format-required syntax, such as tabs in Make recipes and the absence
of trailing commas in JSON. Do not apply a source-language rule mechanically
to a different format. Add a scoped language profile when a new language needs
choices that the common policy does not settle.
