• ForegoneConclusion@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    1 year ago

    Depends on the requirements. Writing the code in a natural and readable way should be number one.

    Then you benchmark and find out what actually takes time; and then optimize from there.

    At least thats my approach when working with mostly functional languages. No need obsess over the performance of something thats ran only a dozen times per second.

    I do hate over engineered abstractions though. But not for performance reasons.

    • Ryan@programming.dev
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      You need to me careful about benchmarking to find performance problems after the fact. You can get stuck in a local maxima where there is no particular cost center buts it’s all just slow.

      If performance specifically is a goal there should probably at least be a theory of how it will be achieved and then that can be refined with benchmarks and profiling.

    • Aceticon@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      In my experience we all go through a stage at the Designed-Developer level of, having discovered things like Design Patterns, overengineering the design of the software to the point of making it near unmaintainable (for others or for ourselves 6 months down the line).

      The next stage is to discover the joys of KISS and, like you described, refraining from premature optimization.

    • CanadaPlus@lemmy.sdf.org
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      1 year ago

      Writing the code in a natural and readable way should be number one.

      I mean, even there it depends what you’re doing. A small matrix multiplication library should be fast even if it makes the code uglier. For most coders you’re right, though.