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.
  • Z [email protected]

    Good, now invent a keyword for variables you don't want to declare the type.

    auto. Also in D, you only need const if you don't want to specify a type for a constant, the compiler automatically inferres it to you.

    Function declarations can be easily decyphered from context, no problem.

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

    Maybe that's what the people developing spoken languages thought, while normalising conversations overdependent on context.

    But hey, now we have another comedic tool in anime.

    1 Reply Last reply
    2
    • B [email protected]

      The actual reason why let ... in syntax tends to not use C-style "type var" like syntax is because it's derived from the syntax type theory uses, and type theorists know about parameterised types. Generics, in C++ parlance, excuse my Haskell:

      let foo :: Map Int String = mempty

      We have an empty map, and it maps integers to Strings. We call it foo. Compare:

      Map Int String foo = mempty

      If nothing else, that's just awkward to read and while it may be grammatically unambiguous (a token is a name if it sits directly in front of =) parser error messages are going to suck. Map<Int,String> is also awkward but alas that's what we're stuck with in Rust because they reasoned that it would be cruel to put folks coming from C++ on angle bracket withdrawal. Also Rust has ML ancestry don't get me started on their type syntax.

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

      How do you do nested parameterized types without it becoming ambiguous though? That's IMO the biggest advantage of the bracket syntax. For example: Map<Tuple<Int, Int, Int> Int>

      B 1 Reply Last reply
      2
      • 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

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

        any new keyword could break backwards compatibility

        Wouldn't that happen anyway with variable and function names? Any type other than primitive/built in ones are usually camel case so lower case keywords are more likely to clash with single word variable and function names, unless you restrict the cases of those too or allow keyword overriding or something.

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

          How do you do nested parameterized types without it becoming ambiguous though? That's IMO the biggest advantage of the bracket syntax. For example: Map<Tuple<Int, Int, Int> Int>

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

          Map (Int, Int) Int. Kind of a bad example because tuples have special-case infix syntax, the general case would be Map Int (Either Int Bool). Follows the same exact syntax as function application just that types (by enforced convention) start upper case. Modulo technical wibbles to ensure that type inference is possible you can consider type constructors to be functions from types to types.

          ...function application syntax is a story in itself in Haskell because foo a b c gets desugared to (((foo a) b) c): There's only one-argument functions. If you want to have more arguments, accept an argument and return a function that accepts yet another argument. Then hide all that under syntactic sugar so that it looks innocent. And, of course, optimise it away when compiling. Thus you can write stuff like map (+5) xs in Haskell while other languages need the equivalent of map (\x -> x + 5) xs (imagine the \ is a lambda symbol).

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

            Map (Int, Int) Int. Kind of a bad example because tuples have special-case infix syntax, the general case would be Map Int (Either Int Bool). Follows the same exact syntax as function application just that types (by enforced convention) start upper case. Modulo technical wibbles to ensure that type inference is possible you can consider type constructors to be functions from types to types.

            ...function application syntax is a story in itself in Haskell because foo a b c gets desugared to (((foo a) b) c): There's only one-argument functions. If you want to have more arguments, accept an argument and return a function that accepts yet another argument. Then hide all that under syntactic sugar so that it looks innocent. And, of course, optimise it away when compiling. Thus you can write stuff like map (+5) xs in Haskell while other languages need the equivalent of map (\x -> x + 5) xs (imagine the \ is a lambda symbol).

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

            Interesting. Thanks!

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

              any new keyword could break backwards compatibility

              Wouldn't that happen anyway with variable and function names? Any type other than primitive/built in ones are usually camel case so lower case keywords are more likely to clash with single word variable and function names, unless you restrict the cases of those too or allow keyword overriding or something.

              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]
              #97

              Yeah, it's in my edit I realized the same thing. I'm thinking it doesn't actually really make sense and the real reason is more "the specific way C does it causes a lot of problems so we're not poking syntax like that with a 10 foot pole" + "it makes writing the parser easier" + maybe a bit of "it makes grepping easier"

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

                Rust is verbose, but C++ might still take the cake with its standard library templates. Especially when using fully-qualified type names...

                auto a = ::std::make_shared<::std::basic_string<char, ::std::char_traits<char>, MyAllocator<char>>>();

                A reference-counted shared pointer to a string of unspecified character encoding and using a non-default memory allocator.

                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]
                #98

                Yeah, I mean Rust is only verbose if you want it to be. let foo = "bar"; is valid rust too, no need to declare the type and definitely no need to declare the lifetime.

                For that matter, if you ever declare something as explicitly 'static in code that isn't embedded or super optimized, you're probably doing it wrong.

                1 Reply Last reply
                0
                • V [email protected]

                  I would because I know TypeScript and I don't know Rust.

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

                  ok but then you can't do Rust, so this does not apply.

                  but if you did.. !

                  V 1 Reply Last reply
                  0
                  • W [email protected]

                    ok but then you can't do Rust, so this does not apply.

                    but if you did.. !

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

                    Probably would still use TypeScript, because I use that for work. 🤷‍♂️ Rust just seems like... a lot. Regarding Rust, I've seen a lot of praises and a not so insignificant amount of complaints that make me very hesitant to take the plunge. Can't remember off the top of my head what it was, specifically, but it was enough for me to write it off, that much I remember.

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

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

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

                      STRING A WHAT, MOTHERFUCKER

                      1 Reply Last reply
                      5
                      • psaldorn@lemmy.worldP [email protected]

                        If there's only two options you only need one keyword

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

                        Ah, but this is JS, so there are three options! And they all function entirely differently. And your assumptions don't apply, either. 😄

                        1 Reply Last reply
                        0
                        • V [email protected]

                          Probably would still use TypeScript, because I use that for work. 🤷‍♂️ Rust just seems like... a lot. Regarding Rust, I've seen a lot of praises and a not so insignificant amount of complaints that make me very hesitant to take the plunge. Can't remember off the top of my head what it was, specifically, but it was enough for me to write it off, that much I remember.

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

                          People really overstate it, it's not that hard. It has a reputation of being difficult because people use it for difficult, low-level tasks, OS stuff, parsers, cryptography, highly optimised serialisation, but those things would be hard in any language. For a newcomer it's, IMO, way easier than say C++, because it doesn't have a mindbogglingly huge std lib with decades of changing best practices to try to figure out. To do simpler things in it is really pretty straightforward, especially if you're already comfortable with a robust type system.

                          V 1 Reply Last reply
                          1
                          • _ [email protected]

                            Dude, even just a "FY,I, you sure about this?" would be nice. I gladly embrace python's by-all-means-shotgun-your-leg-off philosophy, but the noobs could use the help.

                            lime@feddit.nuL This user is from outside of this forum
                            lime@feddit.nuL This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #104

                            the problem is that the language doesn't and can't support one single way to use type annotations without changing fundamental functionality. you can absolutely hook up mypy to your editor for newbies, but once you get on the intermediate level, fighting with mypy takes more code than actually solving the problem.

                            also there was that proposed update to mypy that was put on held when it turned out that the maintainers didn't know how annotations are used in the wild.

                            _ 1 Reply Last reply
                            0
                            • lime@feddit.nuL [email protected]

                              the problem is that the language doesn't and can't support one single way to use type annotations without changing fundamental functionality. you can absolutely hook up mypy to your editor for newbies, but once you get on the intermediate level, fighting with mypy takes more code than actually solving the problem.

                              also there was that proposed update to mypy that was put on held when it turned out that the maintainers didn't know how annotations are used in the wild.

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

                              Oh I'm well aware. Took me a solid year to appreciate type annotations for what they are and yeah I'm happy using what we have in stdlib now and not messing with mypy tyvm. The problem is that history is lost to newcomers who have very different expectations. Modern IDE's mostly solve it though, so for all my Java peeps dipping their toes into the snake waters, listen to your ide

                              lime@feddit.nuL 1 Reply Last reply
                              0
                              • _ [email protected]

                                Oh I'm well aware. Took me a solid year to appreciate type annotations for what they are and yeah I'm happy using what we have in stdlib now and not messing with mypy tyvm. The problem is that history is lost to newcomers who have very different expectations. Modern IDE's mostly solve it though, so for all my Java peeps dipping their toes into the snake waters, listen to your ide

                                lime@feddit.nuL This user is from outside of this forum
                                lime@feddit.nuL This user is from outside of this forum
                                [email protected]
                                wrote on last edited by
                                #106

                                i mean, i'm all for rejiggering the internals. i've personally written at least two libraries that uses type annotations in reverse to force arguments into the correct type, and i feel like that should probably be a separate mechanism to "just call the annotation"

                                _ 1 Reply Last reply
                                0
                                • P [email protected]

                                  People really overstate it, it's not that hard. It has a reputation of being difficult because people use it for difficult, low-level tasks, OS stuff, parsers, cryptography, highly optimised serialisation, but those things would be hard in any language. For a newcomer it's, IMO, way easier than say C++, because it doesn't have a mindbogglingly huge std lib with decades of changing best practices to try to figure out. To do simpler things in it is really pretty straightforward, especially if you're already comfortable with a robust type system.

                                  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]
                                  #107

                                  This contradicts what I've heard others say about it. I have a feeling it is quite subjective, and this might just be an anecdotal recommendation because you have an easy time with it. Maybe I will too! But maybe I won't.

                                  Either way, one part of me really wants to try it, but one part has very little time in life. 🥲

                                  Also comparing it to C++ might not be the flex we think it is. 😅

                                  P 1 Reply Last reply
                                  0
                                  • V [email protected]

                                    This contradicts what I've heard others say about it. I have a feeling it is quite subjective, and this might just be an anecdotal recommendation because you have an easy time with it. Maybe I will too! But maybe I won't.

                                    Either way, one part of me really wants to try it, but one part has very little time in life. 🥲

                                    Also comparing it to C++ might not be the flex we think it is. 😅

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

                                    Well sure, I guess you're right, it's definitely a bit subjective and some people have an easier time with some languages and ways of thinking than others for sure. And I didn't really mean to say that it was totally super easy, but... no kind of programming is really super easy. It is quite different and that in itself has a learning curve.

                                    My recommendation is for sure anecdotal, but I think the point about it seeming more difficult than it really is because people often use it for difficult stuff is actually true.

                                    V 1 Reply Last reply
                                    1
                                    • lime@feddit.nuL [email protected]

                                      i mean, i'm all for rejiggering the internals. i've personally written at least two libraries that uses type annotations in reverse to force arguments into the correct type, and i feel like that should probably be a separate mechanism to "just call the annotation"

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

                                      dataclasses do this for you at the class level. They enforce type annotations at instantiation.

                                      https://docs.python.org/3/library/dataclasses.html

                                      lime@feddit.nuL 1 Reply Last reply
                                      0
                                      • S [email protected]

                                        Yeah, it's in my edit I realized the same thing. I'm thinking it doesn't actually really make sense and the real reason is more "the specific way C does it causes a lot of problems so we're not poking syntax like that with a 10 foot pole" + "it makes writing the parser easier" + maybe a bit of "it makes grepping easier"

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

                                        One thing that annoyed me about C# as a Java guy is that it really wants you to use camel case for function and property names, even private ones. I don't like it specifically because it's hard to differentiate between a function/property and a type.

                                        But C# has quite a few keywords and seem to like adding them more than Java.

                                        Maybe that's their way of ensuring keywords don't clash with stuff?

                                        1 Reply Last reply
                                        0
                                        • P [email protected]

                                          Well sure, I guess you're right, it's definitely a bit subjective and some people have an easier time with some languages and ways of thinking than others for sure. And I didn't really mean to say that it was totally super easy, but... no kind of programming is really super easy. It is quite different and that in itself has a learning curve.

                                          My recommendation is for sure anecdotal, but I think the point about it seeming more difficult than it really is because people often use it for difficult stuff is actually true.

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

                                          Take my up vote. I agree with everything in that comment. 👍

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