Skip to content
DevMeme
5679 of 7590
Languages Post #6230 · source on Telegram

Duck Typing Crosses the Road

Description

A two-panel black-and-white line drawing shows a road scene annotated with code-like labels about chickens crossing a road. In the top panel, text says "a duck??? in the chicken function?? i must give a compiler error!!!" while a C# logo stands near labels such as "void ChickenCrossRoad(Chicken ...chicken)", "new Chicken()", and "new Duck()". In the bottom panel, the same scene says "i guess the road is bussy" with a JavaScript logo allowing "new Chicken()", "new Truck()", "new Cat()", and "new ElonMusk()" into `function ChickenCrossRoad(Chicken)`. The meme contrasts nominal/static type checking and compiler enforcement in C# with JavaScript's looser runtime behavior and duck-typing-adjacent permissiveness.

Comments

58
Anonymous ★ Top Pick JavaScript saw a parameter name and treated it as stakeholder guidance, not a contract.
  1. Anonymous ★ Top Pick

    JavaScript saw a parameter name and treated it as stakeholder guidance, not a contract.

  2. @GLXBX 1y

    Bussy🤯☠☠☠ (Stands for boy-pussy)

    1. @jaaaaded 1y

      damn i was thinking the same

    2. @paranoidPhantom 1y

      Typical dev meme user

  3. @Araalith 1y

    What compile error C# is talking about? And it's a void method, not a function.

    1. @noi01 1y

      Method is just a function, bounded to a class. So it is a function

      1. @callofvoid0 1y

        the thing is it is void how can it return anything ?

        1. @noi01 1y

          Appropriate username

          1. @callofvoid0 1y

            :-)

        2. @noi01 1y

          Void function changes state of a program, it is basically a return value, but indirectly

          1. @callofvoid0 1y

            yes, if it does something on the argument or the object it is called on

      2. @Araalith 1y

        Function returns result, otherwise it's a procedure. But anyway, C# has Func as a Delegate (with result)

        1. @noi01 1y

          Procedure, function, method, it's all different names in different languages to the same thing, if we break down to a pure math - we have just functions

  4. @desrevereman 1y

    bussy

  5. @vladyslav_google 1y

    What's the problem to check in JS case, if the "chicken" argument is instance of Chicken, and not something else?

    1. @Araalith 1y

      TS exists for 11 years, but people are still blaming pure JS while using BS languages like Python or Lua

      1. @GLXBX 1y

        BS - BadaSs?

        1. @Araalith 1y

          Yes. "I need your memory, CPU and all the time you have"...

          1. @L2CacheGay 1y

            it’s a matter of picking the right tool for the right job

            1. @L2CacheGay 1y

              lua, for instance, is amazing at being a plugin language

              1. @L2CacheGay 1y

                easy to embed, fast enough (especially if you’re using luajit), and pretty watertight in terms of sandboxing

              2. @Araalith 1y

                Nope

                1. @GLXBX 1y

                  Name a better tool

                  1. @Araalith 1y

                    Even JS is a better tool then Lua. No really, Lua is a disaster in every way, but when it comes to debugging it's beyond terrible

                    1. @GLXBX 1y

                      Nothing beats js in the ability to bring suffering into one's life

                    2. @anilakar 1y

                      Lua is an excellent, lightweight embeddable interpreter with a dogshit language strapped on. It's a lazy cop-out way for a dev to create extendable and scriptable programs. I meant, four dogshit languages strapped on. Every minor* version breaks things both in the syntax and standard library (yes, even string.gsub behaviour changes between releases) so you need to support all of them separately. A good custom wrapper for the standard library can alleviate a ton of issues with the language, but even in the exceptional case of devs adding in one, you gotta learn it from the beginning because it's not, well, standard. *) When you point this out, the main defense they have is that Lua is not using semver.

                      1. @Araalith 1y

                        From my perspective, Lua is annoying because: - It implements its own syntax for basic operations that is incompatible with any other language (like string concatenation) - It doesn't limit global access to variables (the "S" in Lua supposedly stands for "Safety" and "Stability") - Debugging is worse than even debugging pure C - Every time I need something, it's either not implemented in Lua or implemented in the most bizarre way possible

                        1. @anilakar 1y

                          Like I said, you have to write your own wrappers on top of the abysmally quirky standard lib. 🤣 When you google how to do something in Lua and end up in lua-users.org it's most probably a benchmark with fifteen different ways to do a simple thing. You need to manually create local temporary variables for speed, which is ridiculous. Or not use, say pairs() but next, foo to get more perf.

          2. @GLXBX 1y

            Sounds better than wasting your whole life on investigating some bullshit error in js

            1. @vladyslav_google 1y

              Easily getting fixed by try...catch block and logging the stack of the error

              1. @GLXBX 1y

                Sometimes it's something stupid to the point when you start to question common sense Like, all the languages dump maps into json as objects, but js, the origin of json, dumps them into ... fucking nothing I ain't no expert, but I have never ever faced as much bullshitery, as I face it every time when coding in js, and I switch stacks oh so often

            2. @Araalith 1y

              There are known issues in all the programming languages and frameworks. I can remember dozens for C#, especially when it comes to async.

  6. @Dymidrol 1y

    Eventloop is busy figuring out your life that's why

  7. @GLXBX 1y

    Yeah another crazy shit Only two languages that I truly hate: C# and JS Never tried TS tho, maybe I should give it a try

    1. @GLXBX 1y

      *Transsexual, of course, not js's offspring

    2. @Araalith 1y

      Oh, I can name even more for Perl. Classic C is a just one huge trap, you can shot your leg with a simple string operation

      1. @GLXBX 1y

        Yo, but C's so smol, you learn it in a week or two in a sandbox and never really shoot your leg on production I love this tiny thing

        1. @Araalith 1y

          Implicit type conversion rules in JS can be learned in 5 minutes, they are simple AF. But ppl crying for decades because of them.

          1. @GLXBX 1y

            Because you offer them to eat shit, claiming: "it's only for five minutes, and then you'll get used to it"

            1. @Araalith 1y

              "I dreamed for all my life how I add a number to an object and compare the result with an array, JS ruined my dreams"...

              1. @GLXBX 1y

                I miss static typing😔

                1. @Araalith 1y

                  TS

                  1. @GLXBX 1y

                    Why would I do TS instead of a real girl Kotlin?

                    1. @Araalith 1y

                      I'm not familiar with Kotlin, but isn't it related to Java?

                      1. @GLXBX 1y

                        It is, as a base version, but it can be compiled into JS And Kotlin Multiplatform is a thing

  8. @graduated_vernier 1y

    If it honks like a duck, has shitty hair plugs like a duck, it clearly must be a duck.

  9. @GLXBX 1y

    Or whatever else not connected to js

  10. @zvyozdniymichal 1y

    very unfortunate typo

  11. @zvyozdniymichal 1y

    also why the fuck

  12. @zvyozdniymichal 1y

    are people going on a full internet debate

    1. dev_meme 1y

      Return times / Normalize long-form debates in Internet!

      1. dev_meme 1y

        We have it and it was perfect!

    2. @dsmagikswsa 1y

      This is also a meme

  13. @zvyozdniymichal 1y

    it's a meme

  14. @fll_fll_fll 1y

    Bla bla bla… the first time I got into programming was with LUA (one of the few good things that Rio de Janeiro has to offer).

    1. dev_meme 1y

      I got into programming by large degree thanks to lua in cheat engine

      1. @leandrofriedrich 1y

        i got into the whole it stuff due to clabretro

  15. @fll_fll_fll 1y

    I used LUA to learn how to work with a private Tibia server. Best time of my life 🥺

Use J and K for navigation