Skip to content

Commit

Permalink
CODE_STYLE.md: profess love for Json, Toml, and snake_case (rerun-io#…
Browse files Browse the repository at this point in the history
…3350)

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/3350) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/3350)
- [Docs
preview](https://rerun.io/preview/505319ef6fd25235276b5e1394f3ae67227cac72/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/505319ef6fd25235276b5e1394f3ae67227cac72/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://ref.rerun.io/dev/bench/)
- [Wasm size tracking](https://ref.rerun.io/dev/sizes/)
  • Loading branch information
emilk authored Sep 18, 2023
1 parent b5a0e01 commit 4401c7d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CODE_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
* [`CONTRIBUTING.md`](CONTRIBUTING.md)
* [`RELEASES.md`](RELEASES.md)

## Languages
We prefer Rust.

We have a bunch of Bash and Python scripts that [we want to replace with Rust](https://github.com/rerun-io/rerun/issues/3349).

For configs we like JSON and TOML, and [dislike YAML](https://ruudvanasseldonk.com/2023/01/11/the-yaml-document-from-hell).

## Rust code

### Avoid `unsafe`
Expand Down Expand Up @@ -116,6 +123,8 @@ Use debug-formatting (`{:?}`) when logging strings in logs and error messages. T
Use `re_error::format(err)` when displaying an error.

## Naming
We prefer `snake_case` to `kebab-case` for most things (e.g. crate names, crate features, …). `snake_case` is a valid identifier in almost any programming language, while `kebab-case` is not. This means one can use the same `snake_case` identifier everywhere, and not think about whether it needs to be written as `snake_case` in some circumstances.

When in doubt, be explicit. BAD: `id`. GOOD: `msg_id`.

Be terse when it doesn't hurt readability. BAD: `message_identifier`. GOOD: `msg_id`.
Expand Down

0 comments on commit 4401c7d

Please sign in to comment.