• Zeth0s@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    ·
    edit-2
    1 year ago

    Actually programs are much less readable than corresponding math representation. Even in a simpler example of a for loop. Code is known to quickly add cognitive complexity, while math language manage to keep complexity understandable.

    Have you tried reading how a matrix matrix multiplication is implemented with for loops? Compare it with the mathematical representation to see what I mean

    Success of fortran, mathematica, R numpy, pandas and even functional programming is because they are built to make programming closer to the simplicity of math

    • maegul (he/they)
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      1
      ·
      1 year ago

      Will I think there’s a danger here to conflate abstraction with mathematical notation. Code, whether Fortran, C or numpy, is capable of abstraction just as mathematics is. Abstraction can help bring complexity under control. But what happens when you need to understand that complexity because you haven’t learnt it yet?

      Now sure writing a program that will actually work and perform well adds an extra cognitive load. But I’m talking more about procedural pseudo code being written for the purposes of explaining to toss who don’t already understand.

      • Zeth0s@lemmy.world
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        1 year ago

        Math is the language developed exactly for that, to be an unambiguous, standard way to represent extremely complex, abstract concepts.

        In the example above, both the summation and the for loop are simply

        a_1 + a_2 + ... + a_n
        

        Math is the language to explain, programming languages is to implement it in a way that can be done by computers. In a real case scenario is more often

        sum(x)
        

        or

        x.sum()
        

        as a for loop is less readable (and often unoptimized).

        If someone doesn’t know math he can do the same as those who don’t know programming: learn it.

        Learning barrier of math is actually lower than programming