• fartsparkles@sh.itjust.works
        link
        fedilink
        arrow-up
        1
        ·
        9 months ago

        Highly agree. I’ve been writing code since I was in the single digits and while these days I write mostly Python, Haskell, and C++, I was blown away by the quality of C# and dotNET’s documentation (used it for a few Unity projects) to the point I actually miss it and am considering C# for a Godot project.

        I’m not at all a fan of Windows, Office, Azure etc but Microsoft truly got C# right.

    • starman@programming.dev
      link
      fedilink
      English
      arrow-up
      7
      ·
      edit-2
      9 months ago

      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

      • 𝒍𝒆𝒎𝒂𝒏𝒏@lemmy.dbzer0.com
        link
        fedilink
        arrow-up
        11
        arrow-down
        1
        ·
        9 months ago

        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++

        • christophski@feddit.uk
          link
          fedilink
          English
          arrow-up
          6
          ·
          9 months ago

          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.

          • To summarize the explanations i’ve come across: It’s tailored to Google’s internal teams maintaining tons of legacy C++ code, doesn’t cover exception handling, and generally has outdated advice best suited for the code they developed in that time period. While their style guide is ideal for maintaining consistency with Google’s existing codebase, someone working on a modern C++ project should consider using the language’s more modern features and STL components

            Something I’d want to note though, someone developing in C++ for an embedded platform or even working on hardware drivers would probably have very lean and mean code which doesn’t conform to a particular style guide, especially ones advising against use of “unsafe” operations.

      • Ephera@lemmy.ml
        link
        fedilink
        arrow-up
        6
        ·
        9 months ago

        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.

      • v0rld@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        9 months ago

        Is JavaScript a serious language? /s

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

      • sloppy_diffuser@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        9 months ago

        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

  • Aa!@lemmy.world
    link
    fedilink
    arrow-up
    17
    ·
    9 months ago

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

    • TootSweet@lemmy.world
      link
      fedilink
      English
      arrow-up
      5
      ·
      9 months ago

      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.

  • DrDeadCrash@programming.dev
    link
    fedilink
    arrow-up
    13
    ·
    9 months ago

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

    • brian@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      9 months ago

      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

  • Kogasa@programming.dev
    link
    fedilink
    arrow-up
    9
    ·
    9 months ago

    For practical advice, I recommend starting a project with dotnet new editorconfig which covers many of the .NET coding conventions. If you want more strict standards you can use StyleCop, but you will need to configure it a bit to be consistent with the .NET conventions.

  • navigatron@beehaw.org
    link
    fedilink
    arrow-up
    4
    ·
    9 months ago

    JavaScript / TypeScript are famously free-form, but a number of styles (and style-enforcing tools) have emerged.

    “Prettier” is the most recent. It actually parses your code into an AST and then re-prints it according to its style.

    “ESLint” is the most widespread; it is more of a framework into which rules can be plugged.

    I use “XO”, which is essentially a custom eslint ruleset with a few other nice things tacked on.

    The best part of eslint/xo is the “—fix” command, which can auto-fix most mistakes.

    • brian@programming.dev
      link
      fedilink
      arrow-up
      4
      arrow-down
      1
      ·
      9 months ago

      I refuse to believe that people use a php style guide. I have yet to open a php file in the course of any job that doesn’t mix tabs and spaces arbitrarily on top of numerous other horrors.

      Luckily it’s not often that I have to, so sample size may play in a bit…

  • nephs@lemmygrad.ml
    link
    fedilink
    arrow-up
    2
    ·
    9 months ago

    Javascript has airbnb style guide, enforceable through eslint. There’s also react related eslint extensions to give you a lot of best practices to follow.

    There’s also prettier, which is just about formatting.

  • stevecrox@kbin.social
    link
    fedilink
    arrow-up
    3
    arrow-down
    1
    ·
    edit-2
    9 months ago

    Python is unique in formatting forms part of the syntax, every language has linters but its far more common for orgs to tweak the default rules .

    For example Java has Checkstyle. The default rules ‘sun checks’ give a line length of 80, tabs are 4 spaces and everything is placed on a new line.

    Junior devs inevitably want to trash the line length (honestly on 1080p monitors, 120 makes sense,).

    There is always a new line/same line discussion (everyone perfers same line but there is always one die hard new line person).

    The tab width discussion always has one junior dev complain that “tabs are better”, as someone who started development on Visual Studio 6 where half the team double spaced, the other half used tabs. Those people get a lecture from me on how we can convert tabs to spaces but not the inverse so it will always be spaces if I am near.

    With Checkstyle you upload the rule file as an artifact into your M2 repository. Then you can pull it down as a dependency when the checkstyle plugin runs.

  • TehPers@beehaw.org
    link
    fedilink
    English
    arrow-up
    2
    ·
    9 months ago

    Someone else already mentioned Rust, but to add to it, rustup installs rustfmt (opinionated formatter) and clippy (linter) by default, but you can choose not to run them or even install them. rustfmt has a few configuration options, but is for the most part strict in how it formats code.

    PEP8 is nice since it sets some common rules across Python projects, but I’m not a fan of some of the decisions they made. The biggest one for me was discouraging defining variables/attributes/etc that use the same name as built-ins. That means no variable named input, no attr on your data model named id, etc. Still, since the language doesn’t strictly enforce this, you can easily adjust these rules to meet your project’s needs.

    I believe go requires you to run the bundled formatter to even compile the code, but I could be misremembering.

  • amio@kbin.social
    link
    fedilink
    arrow-up
    2
    ·
    9 months ago

    Sort of. Python is a lot more ceremonious about its PEPs or whatever, but there are official naming guidelines for .NET in general at least. The rest of it falls more under the general “this and that is considered ‘good’ code, this and that is not”. You could prefer ancient-style C# or heavily functional C#, there’s the SOLID stuff that applies both generally and specifically to OOP, etc

  • burliman@lemmy.today
    link
    fedilink
    arrow-up
    1
    ·
    9 months ago

    C# has the Microsoft coding standards that are most accepted. PHP has the PSR standards. JavaScript has pretty much nothing and is the Wild West.

    Those are the only ones I know about.

  • Ephera@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    9 months ago

    In my experience, they’re rarely as strictly enforced as e.g. flake8 does it for Python, but yeah, there is usually some resource suggesting a code style. If all else fails, you can look at some of the code the language authors have written. They’ll usually have developed a rather consistent style…