45 points

Since you specifically mentioned C# : https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions

I’d be surprised if there is a serious language that doesn’t come with at least some semi-official style guide. But usually they are not universally followed and everybody just does their own thing.

permalink
report
reply
12 points

Just to add, I’d argue dotnet has one of the best sets of guidance on style. It goes beyond just naming and towards how to structure code for easier consumption and consistency. People love to dump on MSFT, but the dotnet platform is superb.

https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/

permalink
report
parent
reply
1 point
Deleted by creator
permalink
report
parent
reply
1 point
Deleted by creator
permalink
report
parent
reply
7 points
*

I’d be surprised if there is a serious language that doesn’t come with at least some semi-official style guide.

Does JavaScript have one?

Edit: Except google’s style guide

permalink
report
parent
reply
10 points

Edit: Except google’s style guide

This legit made me laugh lol, Google’s style guides for their longer standing languages are always dismissed, especially their one for C++

permalink
report
parent
reply
6 points

Not sure if they still do it, but Google’s python code is some of the ugliest python I’ve seen and uses 2-space indentation.

permalink
report
parent
reply
3 points

What is wrong with Google’s C++ guide?

permalink
report
parent
reply
6 points

Google’s, Mozilla’s and Apple’s style guides are pretty much as official as you’re gonna get here.

The ‘prettier’ formatter is also rather popular and as such its stylistic choices, although that is of course moreso a hammer than a guide.

permalink
report
parent
reply
4 points

Is JavaScript a serious language? /s

Joking aside: One of Brendan Eich’s books probably contains something resembling a style guide.

permalink
report
parent
reply
3 points
*

Eslint rules and prettier. I use the AirBnB ruleset as a base close to my personal preferences and then customize to my liking.

I don’t really have to do any manual formatting. I just save to apply the formatting.

edit: javascript

permalink
report
parent
reply
2 points

Java walks in, whose stdlib uses different styles in the same file.

permalink
report
parent
reply
23 points

Rust has a style guide and comes with a linter. But I don’t think you need to follow it if you don’t want.

permalink
report
reply
16 points

Rust, like the majority of modern languages, has an official formatter which everyone should be using. Formatters are good enough nowadays that everyone should be using them.

permalink
report
parent
reply
1 point

What other languages have formatter programs?

permalink
report
parent
reply
17 points

I’m fond of Go, which comes with its own auto formatter. It eliminates all arguments over style and format.

permalink
report
reply
5 points

Beat me to it. There’s plenty to rave about in Go, and that’s definitely one of my favorite things.

Also, it’s refreshing to actually use tab characters and not two spaces or four spaces or whatever.

permalink
report
parent
reply
7 points

I absolutely loathe soft tabs. Hard tabs 4lyfe.

permalink
report
parent
reply
4 points

I will never forgive this offense

permalink
report
parent
reply
14 points

go fmt has been a thing for almost 11 years

permalink
report
reply
1 point
*
Deleted by creator
permalink
report
parent
reply
13 points

If you’re using visual studio (2022 is current) the idiomatic styling will be mostly correct by default (Ctrl k,e will reformat).

permalink
report
reply
2 points
*

I’ve found it to be less strict than I’d prefer. Things like whether parameters are aligned or indented, whether or not the first one is on its own line, what statements are indented in fluent calls that have blocks, etc.

A lot of other formatters (prettier, anything for python, etc) force something consistent in those cases, whereas it seems like the dotnet formatter prefers to leave things as they were.

I’d love for it to be more opinionated and heavy handed if anyone has suggestions

permalink
report
parent
reply
1 point

I’ve never looked into it very deeply, but it uses a styling spec called EditorConfig. Check it out, https://editorconfig.org/

permalink
report
parent
reply

Programming

!programming@programming.dev

Create post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Community stats

  • 3.7K

    Monthly active users

  • 1.8K

    Posts

  • 29K

    Comments