Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. Why make it complicated?

Why make it complicated?

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
116 Posts 58 Posters 148 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • hiddenlayer555@lemmy.mlH [email protected]

    Made with KolourPaint and screenshots from Kate (with the GitHub theme).

    dan@upvote.auD This user is from outside of this forum
    dan@upvote.auD This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #14

    Can we talk about PHP functions with typehints too?

    public static function foo(): string {
    

    Practically every other language with similar syntax does this instead:

    public static string foo() {
    
    hiddenlayer555@lemmy.mlH S C 3 Replies Last reply
    7
    • dan@upvote.auD [email protected]

      Can we talk about PHP functions with typehints too?

      public static function foo(): string {
      

      Practically every other language with similar syntax does this instead:

      public static string foo() {
      
      hiddenlayer555@lemmy.mlH This user is from outside of this forum
      hiddenlayer555@lemmy.mlH This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #15

      TIL PHP has statics.

      Also, does PHP actually enforce the type declarations? I'd assume it would but knowing PHP...

      dan@upvote.auD 1 Reply Last reply
      5
      • hiddenlayer555@lemmy.mlH [email protected]

        TIL PHP has statics.

        Also, does PHP actually enforce the type declarations? I'd assume it would but knowing PHP...

        dan@upvote.auD This user is from outside of this forum
        dan@upvote.auD This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #16

        It enforces scalar types (string, int, etc) at runtime if you enable strict mode. There's also static analysis tools like PHPStan and Psalm that will flag issues at build time.

        W 1 Reply Last reply
        3
        • dan@upvote.auD [email protected]

          Older variants used DIM for arrays and LET for other variables. DIM was originally called that because it was setting the dimensions of the array.

          In modern BASIC variants, DIM has become a backronym: "declare in memory".

          T This user is from outside of this forum
          T This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #17

          TIL Backronyms and cuil BASIC technicalities
          Much obliged all

          1 Reply Last reply
          3
          • _ [email protected]

            python:

            a: str = 1

            beigeagenda@lemmy.caB This user is from outside of this forum
            beigeagenda@lemmy.caB This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #18

            And then assign an int to a string just to mess with the interpreter.

            S I 2 Replies Last reply
            20
            • hiddenlayer555@lemmy.mlH [email protected]

              Made with KolourPaint and screenshots from Kate (with the GitHub theme).

              O This user is from outside of this forum
              O This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #19

              First time i used let it was to inline variable declaration with assignment . Can’t remember the language.

              1 Reply Last reply
              1
              • dan@upvote.auD [email protected]

                Older variants used DIM for arrays and LET for other variables. DIM was originally called that because it was setting the dimensions of the array.

                In modern BASIC variants, DIM has become a backronym: "declare in memory".

                M This user is from outside of this forum
                M This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #20

                Even older variants required both a let to declare the variable and a dim to set its size.

                I remember a REDIM command, but I really can't remember what basic it's from.

                dan@upvote.auD 1 Reply Last reply
                1
                • hiddenlayer555@lemmy.mlH [email protected]

                  Made with KolourPaint and screenshots from Kate (with the GitHub theme).

                  M This user is from outside of this forum
                  M This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #21

                  Good, now invent a keyword for variables you don't want to declare the type. And now that you have a mix of keywords and identifiers on the same place, you can never update your language again.

                  Also, make the function declarations not use a keyword too, so you get the full C-style madness of code that changes meaning depending on what libraries you import.

                  P V S Z 4 Replies Last reply
                  80
                  • N [email protected]

                    More than you'd ever want to know: https://en.m.wikipedia.org/wiki/Let_expression

                    T This user is from outside of this forum
                    T This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #22

                    I doubted you until I got about halfway through this whole page. I concede tho--you are most correct lol
                    Still a decent read and for that I thank you

                    1 Reply Last reply
                    5
                    • hiddenlayer555@lemmy.mlH [email protected]

                      Made with KolourPaint and screenshots from Kate (with the GitHub theme).

                      tdawg@lemmy.worldT This user is from outside of this forum
                      tdawg@lemmy.worldT This user is from outside of this forum
                      [email protected]
                      wrote on last edited by [email protected]
                      #23

                      Because sometimes that let can be replaced by other things like const. Which can be managed statically by the machine and not by my (imperfect) ability to know if it's mutated or not

                      scoopta@programming.devS L 2 Replies Last reply
                      22
                      • beigeagenda@lemmy.caB [email protected]

                        And then assign an int to a string just to mess with the interpreter.

                        S This user is from outside of this forum
                        S This user is from outside of this forum
                        [email protected]
                        wrote on last edited by
                        #24

                        only the linter gives a hoot - the interpreter will happily leave that footgun for later

                        1 Reply Last reply
                        43
                        • dan@upvote.auD [email protected]

                          Older variants used DIM for arrays and LET for other variables. DIM was originally called that because it was setting the dimensions of the array.

                          In modern BASIC variants, DIM has become a backronym: "declare in memory".

                          S This user is from outside of this forum
                          S This user is from outside of this forum
                          [email protected]
                          wrote on last edited by
                          #25

                          In modern BASIC variants, DIM has become a backronym: “declare in memory”.

                          TIL. I always thought it was a backronym for declare in (yo) momma.

                          1 Reply Last reply
                          4
                          • dan@upvote.auD [email protected]

                            Can we talk about PHP functions with typehints too?

                            public static function foo(): string {
                            

                            Practically every other language with similar syntax does this instead:

                            public static string foo() {
                            
                            S This user is from outside of this forum
                            S This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #26

                            Rust and TypeScript use the return-type-at-the-end convention as well.

                            D dan@upvote.auD 2 Replies Last reply
                            13
                            • tdawg@lemmy.worldT [email protected]

                              Because sometimes that let can be replaced by other things like const. Which can be managed statically by the machine and not by my (imperfect) ability to know if it's mutated or not

                              scoopta@programming.devS This user is from outside of this forum
                              scoopta@programming.devS This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #27

                              Ok but, in the second example you typically just put final or const in front of the type to denote immutability. I still don't see the advantage to the first declaration.

                              tdawg@lemmy.worldT 1 Reply Last reply
                              0
                              • tdawg@lemmy.worldT [email protected]

                                Because sometimes that let can be replaced by other things like const. Which can be managed statically by the machine and not by my (imperfect) ability to know if it's mutated or not

                                L This user is from outside of this forum
                                L This user is from outside of this forum
                                [email protected]
                                wrote on last edited by
                                #28

                                I think you can do const thing = ... as constto lock down the mutation?

                                Z 1 Reply Last reply
                                4
                                • S [email protected]

                                  Rust and TypeScript use the return-type-at-the-end convention as well.

                                  D This user is from outside of this forum
                                  D This user is from outside of this forum
                                  [email protected]
                                  wrote on last edited by
                                  #29

                                  Python too.

                                  frostypolicy@suppo.fiF 1 Reply Last reply
                                  1
                                  • M [email protected]

                                    Good, now invent a keyword for variables you don't want to declare the type. And now that you have a mix of keywords and identifiers on the same place, you can never update your language again.

                                    Also, make the function declarations not use a keyword too, so you get the full C-style madness of code that changes meaning depending on what libraries you import.

                                    P This user is from outside of this forum
                                    P This user is from outside of this forum
                                    [email protected]
                                    wrote on last edited by [email protected]
                                    #30

                                    In C#, you can use 'var' to have an impilict type variable.

                                    String name = ""

                                    var name = ""

                                    P 1 Reply Last reply
                                    11
                                    • D [email protected]

                                      Python too.

                                      frostypolicy@suppo.fiF This user is from outside of this forum
                                      frostypolicy@suppo.fiF This user is from outside of this forum
                                      [email protected]
                                      wrote on last edited by
                                      #31

                                      And Kotlin.

                                      S 1 Reply Last reply
                                      4
                                      • scoopta@programming.devS [email protected]

                                        Ok but, in the second example you typically just put final or const in front of the type to denote immutability. I still don't see the advantage to the first declaration.

                                        tdawg@lemmy.worldT This user is from outside of this forum
                                        tdawg@lemmy.worldT This user is from outside of this forum
                                        [email protected]
                                        wrote on last edited by
                                        #32

                                        oh for sure, but I think that's the rarer case for language implementions. Having a consistent structure with alternative keywords in static positions is just easier to develop an AST for. Personally my favorite language doesn't even allow for const values (except by convention) so it's really just a matter of preference

                                        scoopta@programming.devS 1 Reply Last reply
                                        1
                                        • P [email protected]

                                          In C#, you can use 'var' to have an impilict type variable.

                                          String name = ""

                                          var name = ""

                                          P This user is from outside of this forum
                                          P This user is from outside of this forum
                                          [email protected]
                                          wrote on last edited by
                                          #33

                                          So, a keyword

                                          S 1 Reply Last reply
                                          22
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups