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 153 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.
  • 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
            • hiddenlayer555@lemmy.mlH [email protected]

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

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

              Not to short-circuit the joke, but in this case, it's because the valid JavaScript version is...

              let a
              

              ...and one of TypeScript's main design goals is to be a superset of JavaScript, that only adds syntax, and doesn't re-write it.

              Beyond that, it's probably a case of some new language just using what the designer is familiar with.

              zea_64@lemmy.blahaj.zoneZ P 2 Replies Last reply
              12
              • P [email protected]

                So, a keyword

                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 [email protected]
                #35

                So I think it's still probably unclear to people why "mix of keywords and identifiers" is bad: it means any new keyword could break backwards compatibility because someone could have already named a type the same thing as that new keyword.

                This syntax puts type identifiers in the very prominent position of "generic fresh statement after semicolon or newline"

                ..though I've spent like 10 minutes thinking about this and now it's again not making sense to me. Isn't the very common plain "already_existing_variable = 5" also causing the same problem? We'd have to go back to cobol style "SET foo = 5" for everything to actually make it not an issue

                P A hiddenlayer555@lemmy.mlH 3 Replies Last reply
                18
                • tdawg@lemmy.worldT [email protected]

                  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 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
                  #36

                  Is it rarer? I think a lot of modern languages go for the first option but pretty much all C style languages use the latter. It's probably a wash for which is more popular I'd think.

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

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

                    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 [email protected]
                    #37

                    TypeScript doesn't need the "function" keyword for a method in an object or on a class though.

                    const foo = {
                      bar(): string {
                       ... 
                      } 
                    }
                    

                    which I assume is doable because the syntax is unambiguous.

                    PHP's object orientation is similar to languages like Java and C#, which is what I was comparing to.

                    S M 2 Replies Last reply
                    0
                    • 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.

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

                      C++ has auto, which determines the type automatically.

                      1 Reply Last reply
                      13
                      • M [email protected]

                        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 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
                        #39

                        The first programming language I used was Visual Basic (both VBA in Excel, and VB3 then VB6). I think it used redim to resize arrays.

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

                          Is it rarer? I think a lot of modern languages go for the first option but pretty much all C style languages use the latter. It's probably a wash for which is more popular I'd think.

                          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
                          #40

                          I'm talking about quantity not the popularity of a given language. There are certainly a number of popular languages that follow that convention

                          1 Reply Last reply
                          0
                          • 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() {
                            
                            C This user is from outside of this forum
                            C This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #41

                            JavaScript (Typescript for the type part) and python, the most popular scripting languages, use the same order as PHP.

                            It's usually compiled languages that do the other one.

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

                              That looks like rust ngl

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

                              It's also valid rust syntax.

                              But if it were rust, this meme would not make sense, since you would just type let a and type inference would do its thing. Which is much more ergonomic.

                              N V 2 Replies Last reply
                              13
                              • hiddenlayer555@lemmy.mlH [email protected]

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

                                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
                                #43

                                Javascript gonna Javascript

                                V 1 Reply Last reply
                                3
                                • 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.

                                  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
                                  #44

                                  I don't understand how not using a keyword to define a function causes the meaning to change depending on imports. I've never run into an issue like that before. Can you give an example?

                                  M 1 Reply Last reply
                                  17
                                  • S [email protected]

                                    So I think it's still probably unclear to people why "mix of keywords and identifiers" is bad: it means any new keyword could break backwards compatibility because someone could have already named a type the same thing as that new keyword.

                                    This syntax puts type identifiers in the very prominent position of "generic fresh statement after semicolon or newline"

                                    ..though I've spent like 10 minutes thinking about this and now it's again not making sense to me. Isn't the very common plain "already_existing_variable = 5" also causing the same problem? We'd have to go back to cobol style "SET foo = 5" for everything to actually make it not an issue

                                    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
                                    #45

                                    Ah I was misunderstanding the problem. And learned something new about C#, seems in order to avoid breaking existing code they introduce "contextual keywords" var being added later, it is a contextual. You can create a class 'var' and the compiler will prefer it.

                                    1 Reply Last reply
                                    4
                                    • C [email protected]

                                      It's also valid rust syntax.

                                      But if it were rust, this meme would not make sense, since you would just type let a and type inference would do its thing. Which is much more ergonomic.

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

                                      let a = String::from(“Hello, world!”).into()

                                      I’ll see myself out.

                                      A 1 Reply Last reply
                                      6
                                      • C [email protected]

                                        JavaScript (Typescript for the type part) and python, the most popular scripting languages, use the same order as PHP.

                                        It's usually compiled languages that do the other one.

                                        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
                                        #47

                                        TypeScript doesn't need the "function" keyword for a method in an object or on a class though.

                                        const foo = {
                                          bar(): string {
                                           ... 
                                          } 
                                        }
                                        

                                        which I assume is doable because the syntax is unambiguous.

                                        In PHP's case, the method syntax should also be unambiguous.

                                        1 Reply Last reply
                                        1
                                        • M [email protected]

                                          That looks like rust ngl

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

                                          I was thinking the same thing. who would write typescript if they could just do Rust?

                                          V 1 Reply Last reply
                                          4
                                          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