• Rhllor@feddit.de
    link
    fedilink
    arrow-up
    72
    ·
    10 months ago

    Actually had a colleague who determined distances on microscopy images that way. She would measure the scale bar included in the image with her ruler on the screen, measure the distance she was interested in and calculate the distance using the rule of three. I mean, why bother using the measuring tool included in the software.

    • sznio@lemmy.world
      link
      fedilink
      arrow-up
      45
      ·
      10 months ago

      I’ve heard of people printing out charts, then cutting out the part they wanted to calculate an integral of, then weighing the paper.

      • siipale@sopuli.xyz
        link
        fedilink
        arrow-up
        25
        ·
        10 months ago

        I’ve heard of it too. You would need an analytical balance to get accurate measurements weighing a piece of paper. Just cut out the part you want to take an integral of, then cut out a piece of paper with known size (or cut several pieces with different sizes to get more accurate results) and weigh each of them. I guess this used to be cheaper and faster than using computers when computers were big and expensive.

        • jadero@programming.dev
          link
          fedilink
          arrow-up
          6
          ·
          10 months ago

          Or maybe just a powder balance. When I was a kid in the 1960s, Dad did a lot of reloading his own ammunition. We kids had fun doing things like weighing our names (weigh a small piece of paper to get the tare, weigh again to get the loaded weight, subtract) and other miniscule things. As I recall, it was accurate to less than a grain (0.065 gram).

          One of the things we did was weigh different shapes of paper to calculate area. Start with a sample of a unit area. Cut out a funky shape and weigh it, then do the math.

      • Quereller@lemmy.one
        link
        fedilink
        arrow-up
        5
        ·
        10 months ago

        I was reading an old book about chromatography in laboratory and they exactly describe this method to determine the amount of substance.

      • TheGreenGolem@lemm.ee
        link
        fedilink
        arrow-up
        28
        arrow-down
        1
        ·
        10 months ago

        Me too, any day. I hate everything where indentation matters. Let me just throw my garbage there and YOU sort it out, you are the fucking computer, not me. You do the work.

        So fuck you, YAML! All my homies love JSON!

      • wols@lemm.ee
        link
        fedilink
        arrow-up
        16
        arrow-down
        1
        ·
        10 months ago

        Yup.

        Spaces? Tabs? Don’t care, works regardless.
        Copied some code from somewhere else? No problem, 9/10 times it just works. Bonus: a smart IDE will let you quick-format the entire code to whatever style you configured at the click of a button even if it was a complete mess to begin with, as long as all the curly braces are correct.

        Also, in any decent IDE you will very rarely need to actually count curly braces, it finds the pair for you, and even lets you easily navigate between them.

        The inconsistent way that whitespace is handled across applications makes interacting with code outside your own code files incredibly finicky when your language cares so much about the layout.

        There’s an argument to be made for the simplicity of python-style indentation and for its aesthetic merits, but IMO that’s outweighed by the practical inconvenience it brings.

    • fidodo@lemm.ee
      link
      fedilink
      arrow-up
      1
      ·
      10 months ago

      Have you tried using an auto formatter? Let’s you write code however and fixes the structure automatically on save. It’s way easier for me to write curly braces then hit ctrl+s than have to select multiple lines manually and tab in and out. I feel the biggest gains I’ve made in productivity came after I learned to embrace tooling.

  • gerryflap@feddit.nl
    link
    fedilink
    arrow-up
    41
    arrow-down
    3
    ·
    10 months ago

    People here are taking this way too seriously lol. I love Python, and I never really had any issues with the indentation being used instead of curly braces or something. This is just a silly meme, not a personal attack

    • CoderKat@lemm.ee
      link
      fedilink
      English
      arrow-up
      15
      arrow-down
      1
      ·
      10 months ago

      Ugh, there’s some parts of YAML I love, but ultimately it’s a terrible format. It’s just too easy to confuse people. At least it has comments though. It’s so dumb that JSON doesn’t officially have comments. I’ve often parsed “JSON” as YAML entirely for comments, without using a single other YAML feature.

      YAML also supports not quoting your strings. Seems great at first, but it gets weird of you want a string that looks like a different type. IIRC, there’s even a major version difference in the handling of this case! I can’t remember the details, but I once had a bug happen because of this.

      Performance wise, both YAML and JSON suck. They’re fine for a config file that you just read on startup, but if you’re doing a ton of processing, it will quickly show the performance hit. Binary formats work far better (for a generic one, protobuffers has good tooling and library support while being blazing fast).

      • sonnenzeit@feddit.de
        link
        fedilink
        arrow-up
        8
        ·
        10 months ago

        It’s so dumb that JSON doesn’t officially have comments.

        So much this.

        Used to work at a company where I sometimes had to manually edit the configuration of devices which were written and read in JSON. Super inconvenient if you have to document all changes externally. As a “hack” I would sometimes add extra objects to store strings (the comments). But that’s super dicey as you don’t know if it somehow breaks the parsing. You’re also not guaranteed the order of objects so if the configuration gets read, edited and rewritten your comment might no longer be above/below the change you made.

        Always found it baffling that such a basic feature is missing from a spec that is supposed to cover a broad range of use cases.

      • vrighter@discuss.tchncs.de
        link
        fedilink
        arrow-up
        5
        ·
        10 months ago

        json 5 does support comments. alternatively, yaml is a superset of json. any valid json is also valid yaml. but yaml also supports comments. So you can also write json with comments, and use a yaml parser on it, instead of a standard json parser

    • lhamil64@programming.dev
      link
      fedilink
      arrow-up
      5
      ·
      10 months ago

      One of these days I’ll actually look up how YAML indentation works. Every time I use it it’s trial and error until I stop getting errors.

      • merc@sh.itjust.works
        link
        fedilink
        arrow-up
        2
        ·
        10 months ago

        That’s a super risky way to do it. It might stop giving you errors because you finally got the indentation right, or it might stop giving you errors because you got the indentation “right” but not how you you meant to organize the objects.

  • pamymaf@kbin.run
    link
    fedilink
    arrow-up
    30
    arrow-down
    2
    ·
    10 months ago

    @alphacyberranger
    This is why I have my VSCodium set to highlight all indentation levels in my settings.json

    To see the editor indent guides, set “editor.guides.indentation”: true and “editor.guides.highlightActiveIndentation”: true.

    editorIndentGuide.background: Color of the editor indentation guides.
    editorIndentGuide.activeBackground: Color of the active editor indentation guide.

    https://code.visualstudio.com/api/references/theme-color

      • pamymaf@kbin.run
        link
        fedilink
        arrow-up
        2
        ·
        10 months ago

        @Toldry

        Here’s the relevant section of my settings.json

        json { "workbench.tree.renderIndentGuides": "always", "workbench.tree.indent": 15, "editor.guides.indentation": true, "workbench.colorCustomizations": { "editorIndentGuide.background": "#fd6bff", "tree.indentGuidesStroke": "#fd6bff" } }

        @alphacyberranger

  • BoofStroke@lemm.ee
    link
    fedilink
    arrow-up
    28
    arrow-down
    5
    ·
    edit-2
    10 months ago

    Programming languages that use white space to delimit structure are annoying at best. I get annoyed at yaml too, but I’m ok once I have a few templates set up.

        • mexicancartel@lemmy.dbzer0.com
          link
          fedilink
          English
          arrow-up
          4
          arrow-down
          1
          ·
          10 months ago

          Why tabs suck? Explain.

          Tabs are neat.

          Does you app have too many nested functions?

          Use tab width = 2

          Do your app have too less nested functions?

          Use tab width = 8

          Is your app having average number of nested fns?

          Use tab width = 4(mostly default)

          And all theese can happen without modifying a single byte in the source file, unlike spaces!

          • merc@sh.itjust.works
            link
            fedilink
            arrow-up
            5
            ·
            10 months ago

            Except that you have to either indent with only tabs or indent with only spaces. Any time you mix tabs and spaces you are just asking for disaster.

            If you indent with only tabs you can’t align things except on tab boundaries. If you have a function that takes 10 parameters and want to do it on multiple lines, the alignment of the extra parameters is going to be ugly.

            If you indent with only spaces, you can indent things so that all the parameters line up directly underneath the parenthesis, for example.

            • mexicancartel@lemmy.dbzer0.com
              link
              fedilink
              English
              arrow-up
              1
              ·
              10 months ago

              I agree we shouldn’t mix tabs with spaces. But use tabs always. I could line up parameters together but may not be just under parentheris, and it looks good and readable for me

        • PreachHard
          link
          fedilink
          arrow-up
          4
          arrow-down
          3
          ·
          edit-2
          10 months ago

          Yeah who tf isn’t using tabs as spaces, it isn’t 2010

  • amanaftermidnight@lemmy.world
    link
    fedilink
    English
    arrow-up
    40
    arrow-down
    21
    ·
    edit-2
    10 months ago

    Most disingenuous post ever.

    The image shown is a dude with a browser dev console, probably measuring a div for the its CSS size (which do support centimeters and inches).

    In python, 4 spaces is just enough spacing between indent levels. And if your levels get too deep it’s a sign that you’re not being pythonic. Nesting too deep is the problem, not the whitespacing being significant.

    • UlrikHD@programming.dev
      link
      fedilink
      arrow-up
      18
      arrow-down
      1
      ·
      10 months ago

      Python are fine with whatever number of spaces you want to use. You can use 8 spaces which forces you carefully consider each nest, you can use 1 if you’re a monster, or you can use tabs if you’re enlightened, python only demands consistency.

      • joey_moey@feddit.dk
        link
        fedilink
        English
        arrow-up
        3
        arrow-down
        1
        ·
        10 months ago

        Yeah I remember picking up a script after a reinstall, and gedit had reverted to default settings. It’s fun trying to spot whether it’s 1 tab or 4 spaces. After that day, I switched to two spaces as my default.

        • mexicancartel@lemmy.dbzer0.com
          link
          fedilink
          English
          arrow-up
          2
          ·
          10 months ago

          All theese indentation issues arises from using spaces instead of tabs. And tabs are really flexible so that everyone can set their text editor to whatever tab length they want and still be consistant

        • mexicancartel@lemmy.dbzer0.com
          link
          fedilink
          English
          arrow-up
          3
          ·
          10 months ago

          Thats the problem. Then you commit. I clone it. I can’t use tabs because you turned everything into spaces. Why not turn spaces into tabs?

      • CoderKat@lemm.ee
        link
        fedilink
        English
        arrow-up
        1
        ·
        10 months ago

        I normally love tabs and it’s what Go uses both by convention and it’s semi opinionated formatter. But PEP-8 suggests spaces and ultimately, consistency is more important.

        Not having to argue about tabs vs spaces lets us focus on the real problems, like vim vs emacs.

        • mexicancartel@lemmy.dbzer0.com
          link
          fedilink
          English
          arrow-up
          1
          ·
          10 months ago

          I am aware but don’t know why four spaces is suggested. Tabs are consistant and flexible. Using spaces might cause errors in number of spaces and makes code messy.

          Also emacs for the win

    • JonEFive@midwest.social
      link
      fedilink
      arrow-up
      2
      ·
      10 months ago

      This post on programmer humor is now funnier as a result of your analysis. Everything is funnier when it is 100% accurate.

      • UlrikHD@programming.dev
        link
        fedilink
        arrow-up
        16
        arrow-down
        1
        ·
        10 months ago

        4 spaces, although I’ll die on the hill that tabs should always be used instead of space for indentation. Not just in python.

    • kevincox@lemmy.ml
      link
      fedilink
      arrow-up
      15
      ·
      10 months ago
      1. Use tabs.
      2. Enable visible whitespace.

      Tada, your indentation level is nicely visible.

    • gandarf @midwest.social
      link
      fedilink
      English
      arrow-up
      15
      arrow-down
      2
      ·
      10 months ago

      Tabs. But really with modern IDE it’s irrelevant. Whatever the tech lead says I guess.

      • GBU_28@lemm.ee
        link
        fedilink
        English
        arrow-up
        8
        ·
        10 months ago

        With things like black, flake 8 and Isort I can code however I want, list/format however I want, and commit team compliant content. The dream is real

        • CoderKat@lemm.ee
          link
          fedilink
          English
          arrow-up
          1
          ·
          10 months ago

          I love such formatters and wish they were even more widespread. In many cases, I really want consistency above all and it’s so dang hard to achieve that without an opinionated formatter. If the formatters isn’t opinionated enough, it just leads to countless human enforced rules that waste time (and lead to an understandable chorus of “why can’t the formatter just do that for meeeee”).

          • GBU_28@lemm.ee
            link
            fedilink
            English
            arrow-up
            2
            ·
            10 months ago

            So you can have a local, and a team config. So at time of commit the code rules your team has selected are enforced. So if I looked at my code, on GitHub, it would look as expected by the team.

            If I load it locally, it formats as I like.

            Check out the cicd stuff on PRs for github

      • RogueBanana@lemmy.zip
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        10 months ago

        Yeah but outside of that where the code is implemented or in a documentation, tabs are still easier to look through. And it does look pretty as long as there aren’t too many nested functions.

        • mexicancartel@lemmy.dbzer0.com
          link
          fedilink
          English
          arrow-up
          1
          ·
          10 months ago

          Even with nested functions tabs are neat.

          Does you app have too many nested functions?

          Use tab width = 2

          Do your app have too less nested functions?

          Use tab width = 8

          Is your app having average number of nested fns?

          Use tab width = 4(mostly default)

          And all theese can happen without modifying a single byte in the source file, unlike spaces!

    • Jakylla@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      4
      arrow-down
      3
      ·
      10 months ago

      4 Spaces, then one tab, then 3 spaces, then 2 tabs, then 2 spaces, then 3 tabs…

      Python supports that (and I hate this)

        • Jakylla@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          10 months ago

          Not any standard (and actually not at all something to do for real), but try it, it works

          def magic(a, b, c):
              if a > 0:
              	if b > 0:
              	   		if c > 0:
              	   		  return 'All positive'
              
              return 'Not all positive'
          
          print(magic(1,2,3))
          print(magic(-1,1,2))
          print(magic(1,-1,0))
          print(magic(-1,-1,-2))
          

          (you should be able to verify I used both tab and spaces f*cking bad way in this example, like I described)

          Output:

          All positive
          Not all positive
          Not all positive
          Not all positive
          
          
          ** Process exited - Return Code: 0 **
          Press Enter to exit terminal
          
          • realaether@lemmy.world
            link
            fedilink
            English
            arrow-up
            2
            ·
            10 months ago

            That’s really interesting. So does that mean the interpreter just checks whether the current line is more indented, less indented, or equal vs. the preceding, without caring by how much?

      • grozzle@lemm.ee
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        10 months ago

        “indentation is indentation!” (mr_incredible_cereal.jpg)

        it may look messy, but would you actually rather Python didn’t support some inconsistency when the intent is clear?

        being exact just for the sake of being pedantic isn’t useful.

  • RoyaltyInTraining@lemmy.world
    link
    fedilink
    arrow-up
    11
    arrow-down
    1
    ·
    10 months ago

    I don’t think this is a huge problem with a correctly set up text editor and the right techniques to limit code nesting. Doesn’t change my dislike of python tho.

  • some_guy@lemmy.sdf.org
    link
    fedilink
    arrow-up
    5
    arrow-down
    1
    ·
    10 months ago

    I started with Perl. This taught me a certain mindset that works well with Bash and Ruby. I’ve tried to learn Python several times and I just fucking hate it. I gave up when I realized that it just doesn’t work the way that my brain works.

    I wonder if the outcome would have been different if I’d started with Python? How might that have shaped my thinking / reasoning? Fwiw, I was also ok with PHP and SQL, but I don’t know much or anything about the backgrounds on those foundations. Maybe my above statements were completely bullshit.

    • evranch@lemmy.ca
      link
      fedilink
      arrow-up
      11
      ·
      10 months ago

      I used to love Perl as it worked the way my brain worked.

      Then I started taking medication for ADHD.

      I haven’t used Perl since except for text parsing, it’s an absolute hot mess of a language (though very powerful and functional at the things it does well)

      • some_guy@lemmy.sdf.org
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        10 months ago

        That’s super interesting.

        I have a mental divergence that isn’t ADHD. I was reviewing stats on it that said people who have it are some percent more likely to have ADHD. I wonder if my previous enjoyment of Perl is because I’m on an ADHD spectrum. It would be interesting to find out.

    • magic_lobster_party@kbin.social
      link
      fedilink
      arrow-up
      3
      ·
      10 months ago

      I kind of started with Python, and I hate Perl. Relying so much on global variables like $_, @_, $1, $2 is just the worst idea ever. Oh you want to call a function? Better be safe and backup all global variables you’re using, because they will be overwritten! Want to use some regex in a function? Better ensure all callers have made backups of the $1, $2, $3 variables.

      The end result is just large amounts of defensive boilerplate everywhere because things will break if you don’t.

      There’s also no good way to tell which functions use $_ without looking up the docs or keeping everything in memory.

      The only merit Perl got in my opinion is its regex support. Quite handy for bash one liners time from time.