3 ms·
I've written a lot of code in a lot of different languages and have preferences for each that are based on the general type of code that tends to be written. E.
by joshka 3y ago
I've written a lot of code in a lot of different languages and have preferences for each that are based on the general type of code that tends to be written. E.g. what length are the identifiers and standard function names, what is the standard spacing, how are idiomatic language features used.
My subjective opinions on a few of them:
Java I find works well with a soft 100, hard 120. The language and library tends to prefer and encourage longer class and function names, and these are often repeated multiple times in a single line.
C# seems to work well with 100.
Rust I find well works with 100, and this is the default out of the box format for rustfmt.
Javascript (especially with 2 spaces) works well with 80 characters.
When writing code for documentation sites (e.g. https://ratatui.rs/tutorials/hello-world/ https://ratatui.rs/tutorials/hello-world/), often the code block fits in an area which is surrounded by prose with a width optimized for reading. The resulting width of the code block tends to be ~80 or less. It's worth making this tweak to your formatting for such example code.