• TunaCowboy@lemmy.world
    link
    fedilink
    arrow-up
    11
    arrow-down
    1
    ·
    edit-2
    2 months ago

    What if I prefer this?

    #define CURLYOPENRIGHTCLOSEDLEFTBRACKET {
    #define CURLYOPENLEFTCLOSEDRIGHTBRACKET }
    #define CURVYOPENRIGHTCLOSEDLEFTBRACKET (
    #define CURVYOPENLEFTCLOSEDRIGHTBRACKET )
    #define PERIODWITHPERIODONTOP :
    #define COMMAWITHPERIODONTOP ;
    
    int main CURVYOPENRIGHTCLOSEDLEFTBRACKET CURVYOPENLEFTCLOSEDRIGHTBRACKET CURLYOPENRIGHTCLOSEDLEFTBRACKET
      if CURVYOPENRIGHTCLOSEDLEFTBRACKET 1 CURVYOPENLEFTCLOSEDRIGHTBRACKET CURLYOPENRIGHTCLOSEDLEFTBRACKET
        asm volatile CURVYOPENRIGHTCLOSEDLEFTBRACKET
          "mov $1, %%rax\n"
          "mov $1, %%rdi\n"
          "lea message(%%rip), %%rsi\n"
          "mov $4, %%edx\n"
          "syscall\n"
          PERIODWITHPERIODONTOP
          PERIODWITHPERIODONTOP
          PERIODWITHPERIODONTOP "%rax", "%rdi", "%rsi", "%rdx"
        CURVYOPENLEFTCLOSEDRIGHTBRACKET COMMAWITHPERIODONTOP
      CURLYOPENLEFTCLOSEDRIGHTBRACKET
      return 0 COMMAWITHPERIODONTOP
    CURLYOPENLEFTCLOSEDRIGHTBRACKET
    
    asm CURVYOPENRIGHTCLOSEDLEFTBRACKET ".section .data\n"
      "message: .ascii \"wut\\n\"\n"
      ".section .text\n" CURVYOPENLEFTCLOSEDRIGHTBRACKET COMMAWITHPERIODONTOP
    
  • mox@lemmy.sdf.org
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    2 months ago

    Growing up with C made me assume semicolons and braces were needed to avoid subtle bugs, but experience with more recent languages showed me that it’s possible to reliably parse the same semantic cues that humans use: indentation, parentheses, and other such context. (Perhaps this was less viable when C was invented, due to more constrained hardware.)

    I was skeptical at first, but in practice, I have never encountered a bug caused by this approach in Python, Nim, or any other language implementing it consistently, over the course of a decade or two using them. Meanwhile, I have seen more than a few bugs caused by brace and semicolon mistakes.

    So nowadays (outside of niche & domain-specific languages) I see braces and semicolons as little more than annoying noise and fuel for religious arguments.

    • VonReposti@feddit.dk
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      2 months ago

      I think you’ll like Ruby. It has mostly done away with braces and code blocks end with end, e.g.

      def create
        unless admin redirect_to new_session_path and return
        
        @product = Product.new product_params
      
        if @product.save
          flash[:success] = "New product has been created!"
          redirect_to edit_product_path(@product) and return
        else
          flash[:error] = "Something went wrong!
          render :new
        end
      end
      

      This is working code that I simplified a bit from an old project of mine.

      • Caveman@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        2 months ago

        Ruby syntax is nice although I prefer python way of enforcing indentation instead of adding "end"s. Personally I just want a statically typed language with enforced indent as syntax.

        • VonReposti@feddit.dk
          link
          fedilink
          arrow-up
          2
          ·
          2 months ago

          Funny, the forced indentation is what I hate about Python. If you think a missing semicolon can be hard to catch, don’t ever think about a missing whitespace :p

          The end keyword really isn’t a big deal for me. I find it to be a good way to easily spot the end of a method. But if you wouldn’t like it I’d still find it a good compromise to avoid syntax issues due to whitespace.

          • hglman@lemmy.ml
            link
            fedilink
            English
            arrow-up
            2
            arrow-down
            1
            ·
            2 months ago

            i can count on one hand how many times ive had white space issues in 15 years of using python. its just not an issue

            • 0ops@lemm.ee
              link
              fedilink
              arrow-up
              1
              ·
              2 months ago

              Same and agreed, especially if you keep your functions small and focused as you should. 3-5 indents is nbd to keep track of, and if you need more than that… No you don’t, refactor.

              I’ve had way more hangups with brackets then indentation, personally, not that either is a super frequent issue, but I’m indenting anyway, so brackets are redundant and just another thing I have to keep track of

    • Caveman@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      2 months ago

      Who’s going to write the extension so that they are all hidden and automatically inserted?

  • NigelFrobisher@aussie.zone
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    2 months ago

    My credo on this kind of thing is never do something that will make your successor so mad that they find out where you live and post parts of your body to Interpol.

  • MystikIncarnate@lemmy.ca
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 months ago

    I’m not a coder, and… Well… Thanks, I hate it.

    Even I know this is horrific. Where the fuck does this statement end? Which of these brackets refer to this section of other brackets. Idfk.

    I could give a shit less if it was just for a single block per or something but “;}}}” hurts me.

    • velvetThunder@lemmy.zip
      link
      fedilink
      English
      arrow-up
      3
      ·
      2 months ago

      Well the code indentation explains that, like python. The issue is not reading it. You would rather quit your job than edit this.

  • demizerone@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    2 months ago

    Auto formatter as part of the expected language tooling is Go’s greatest move, even if their formatter doesn’t go far enough.