• ThatGuy46475@lemmy.world
    link
    fedilink
    arrow-up
    100
    ·
    11 hours ago

    A group of researchers was studying how different people solve problems. They gathered a physicist, a mathematician, and an engineer and gave them each a problem: find the volume of a red sphere. The mathematician solves it first. Asked how, he explains that he used a simple formula. The physicist solves it next. Asked how, he explains that he submerged the sphere in water and measured the rise in water level. Hours later, they find the engineer buried in paperwork. Asked about his progress, he says “I can only find a table of values for the volume of blue spheres.”

    • ChickenLadyLovesLife@lemmy.world
      link
      fedilink
      English
      arrow-up
      8
      arrow-down
      1
      ·
      5 hours ago

      They later added an Anthropologist, who understood that more questions needed to be asked. His first question was “do you want fries with that?”

    • NaibofTabr@infosec.pub
      link
      fedilink
      English
      arrow-up
      67
      arrow-down
      1
      ·
      edit-2
      10 hours ago

      On further inspection, it was found that the mathematician had assumed an ideal sphere of constant radius, while the real object was in fact oblate. The mathematician had neglected to take any measurements, leading to an incorrect value. The physicist’s answer was correct, but only at sea level at nominal temperature.

      The engineer is currently using calipers to measure the diameter of the object at many different angles in order to build a CAD model. He said we could expect results next year.

      • BartyDeCanter@piefed.social
        link
        fedilink
        English
        arrow-up
        2
        ·
        2 hours ago

        Anywhere with gravity sufficient to overcome the surface tension of the water from forming around the object or clinging to the container.

      • tyler@programming.dev
        link
        fedilink
        arrow-up
        29
        ·
        9 hours ago

        The physicist’s answer would be correct anywhere, no matter the temperature or density of the fluid.

        • montechristo@feddit.org
          link
          fedilink
          English
          arrow-up
          11
          ·
          9 hours ago

          Supposing that the measurements with and without the sphere are taken under identical circumstances. But you deserve the upvote either way.

        • Omgpwnies@lemmy.world
          link
          fedilink
          English
          arrow-up
          8
          arrow-down
          1
          ·
          7 hours ago

          Also, any CompSci grad I’ve worked with couldn’t write code for shit unless they learned how outside of their schooling, and yet so many go the CompSci -> programmer route instead of doing like SW Eng or something like that.

  • BCsven@lemmy.ca
    link
    fedilink
    arrow-up
    55
    ·
    12 hours ago

    Ha. I had a convo with a programmer in the 90s. He was explaining a complex problem and the steps to solve in the code, to adjust things based on user choices and parameters.

    And I said why wouldn’t you presolve all of them and then provide a lookup to go get the solution from a list. And he just looked stunned and walked away.

    • Thorry@feddit.org
      link
      fedilink
      arrow-up
      20
      ·
      10 hours ago

      Reminds me of the first time I saw Sin and Cos lookup tables being used in early 3D gaming. The computers could calculate those just fine, especially with a math co-processor. But for 3D gaming it would be too slow to get a good framerate. So lookup tables were used to greatly improve the speed.

      Back on those days all sort of neat tricks like that would be used. Often done as little demo programs that were very impressive. Before the internet it was hard to look up something like that and the latest and greatest tricks weren’t written in books yet. So often little code snippets and demo programs would be shared amongst programmers using the sneakernet, so we could all learn and get better.

    • Sludge@sh.itjust.works
      link
      fedilink
      arrow-up
      10
      ·
      10 hours ago

      Ah my prior manager suggested something similar… Dynamic views that would adjust based on user set parameters… We set up canned views and called it a day.

      He was let go, but always pushed for the art of the possible (even if it would take a few extra sprints to wrap)

      • BCsven@lemmy.ca
        link
        fedilink
        arrow-up
        7
        ·
        11 hours ago

        Because he hadn’t thought of what I suggested and it was much easier than what he was trying to program. I wasn’t suggesting he write the program, solve it and table it; it was more like empirical knowledge/common sense stuff to narrow options, then fill the rest in based on what made sense. Then its just a horizontal or vertical intersection to find the outputs required instead of a complex calculation every time

  • henfredemars@infosec.pub
    link
    fedilink
    English
    arrow-up
    28
    ·
    12 hours ago

    It really depends on what you’re building. In an embedded shop, lookup tables are first class solutions to most problems. Computer scientists though, 100%!

    • mushroommunk@lemmy.today
      link
      fedilink
      arrow-up
      27
      ·
      12 hours ago

      Depends on the available memory and size of the tables. I’ve worked on cases where time to compute didn’t matter as much as shaving off three more bytes did. Large lookup tables would have absolutely killed us compared to running some math.

      • henfredemars@infosec.pub
        link
        fedilink
        English
        arrow-up
        10
        ·
        12 hours ago

        Good point! Good point.

        I’ve seen bubble sort implemented because we had data that said it was faster and was slightly smaller for the exact type data we were sorting and its expected distribution.

        • disorderly@lemmy.world
          link
          fedilink
          arrow-up
          14
          ·
          11 hours ago

          I fondly remember the time I hired a QT expert onto an embedded app team and on his first project he imported a sort algorithm from std. He found the system got weird and glitchy, and often crashed.

          Yeahhh turns out the algorithm he chose needed to make a copy in memory and the thread he was working in only had 2048 bytes of stack, so larger inputs would corrupt the stack allocated to the next thread. I had to explain to him that we had a full second to complete the math before we had to give back our semaphore, so saving a couple milliseconds on the sort was not a priority. Fun times.

    • Err(()).unwrap()@lemmy.world
      link
      fedilink
      arrow-up
      13
      ·
      edit-2
      11 hours ago

      IIRC, Elite used lookup tables for trigonometric functions on certain target platforms (maybe the NES) because memory wasn’t as much of a constraint as computing performance. It’s a barrel of game compressed into a pint of code.

  • Warl0k3@lemmy.world
    link
    fedilink
    arrow-up
    19
    ·
    edit-2
    11 hours ago

    When I was a kid and my mother was teaching me to read SQL, she really drove home that Elegance is in the eye of the beholder. While a C++ dev finds beauty in reducing a signal processing step to O(n) by recursing through five lines of bitwise ingenuity, a SQL dev finds radiance in completing the task without using any loops at all.

    • hemko@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      9
      arrow-down
      1
      ·
      10 hours ago

      When I was a kid and my mother was teaching me to read SQL

      Why would a mother do this, I’m horrified

      • Warl0k3@lemmy.world
        link
        fedilink
        arrow-up
        12
        ·
        edit-2
        9 hours ago

        In the case of my mother, she’s pretty autistic and a very well known data scientist. This was her way of teaching me how she relates to the world - I’m quite grateful to her for it; it has given me a love of programming and allowed me get a great deal closer with her.

    • Dimantina@lemmy.world
      link
      fedilink
      arrow-up
      13
      ·
      11 hours ago

      Alright to anyone who would question this statement. I am a mom, and have had extremely similar conversations with my kid regarding programming and perspectives.

      Seriously it’s important for problem solving to not get caught up in perfect solutions or solutions you think are the right path be cause of your own bias’.

      Sometimes to solve a problem you are stuck on, or is proving too challenging the best course of action is to figure out why you are trying to solve it that way, and what other solutions there might be.

  • hperrin@lemmy.ca
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    1
    ·
    9 hours ago

    This wholly depends on where this code is running. If it’s running on the server, you want the best algorithm for most cases, to try to minimize work and power consumption, and maximize capacity. If it’s running on the client, just use whatever.

  • mlg@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    ·
    11 hours ago

    Remember the olden C days before compilers got really good (and freely available) so we’d still have inline assembly everywhere for better optimization lol.