Duck Typing Crosses the Road
Why is this Languages meme funny?
Level 1: The Picky Gate
Imagine a crossing guard who says, "Only chickens may cross," and stops a duck before it enters the road. Then imagine another crossing guard who lets chickens, trucks, cats, and random people all cross because nobody made a rule. The meme is funny because one programming language is shown as very picky, while JavaScript is shown as letting almost anything through.
Level 2: Compiler Says No
A compiler error happens when a language tool refuses to build or run code because it breaks a rule. In C#, if a function says it needs a Chicken, the compiler checks whether the value passed to it is actually allowed to be a Chicken. That is why the upper panel blocks new Duck().
In JavaScript, a function parameter does not normally declare a type. In function ChickenCrossRoad(Chicken), the word Chicken is just the name of the parameter, like calling it x or thing. The function can be called with almost anything. If the code later assumes the value has a method or property that is missing, the error happens while the program runs.
Duck typing is the idea that what an object can do matters more than what class name it has. For example, if a function only needs something with a walk() method, it may not care whether the object is a chicken, a robot, or a mock object in a test. The meme exaggerates this into JavaScript accepting completely unrelated things because nobody checked them.
Level 3: The Type Safety Crosswalk
Experienced developers laugh because both panels are unfair in recognizable ways. The C# side is drawn as overprotective: one new Duck() approaches a Chicken function and the compiler slams the gate. The JavaScript side is drawn as underprotective: everyone enters, and the runtime shrugs. Neither caricature is complete, but both match the daily emotional texture of LanguageComparison debates.
With TypeSafety, the trade-off is not "strict good, loose bad." Static types catch many mistakes early, document intent, enable refactoring, and let tools reason about code. They also require you to model the domain carefully. If ChickenCrossRoad should accept any object that can cross a road, then hard-coding the parameter to Chicken may be too narrow. The better C# design might involve an interface such as IRoadCrossingParticipant, assuming the team can name it without turning the codebase into a filing cabinet.
JavaScript's DynamicTyping is useful because functions can be generic in practice. A function can operate on any value with the properties it needs. That flexibility helped the web grow quickly, where data comes from forms, JSON, APIs, DOM nodes, and questionable browser histories. But when the expected shape is only implied, errors move later. Instead of a compiler error, you may get undefined is not a function in a browser console, ideally during development, traditionally during a customer demo.
The image uses logos as personalities. The C# logo stands like a traffic officer enforcing declared types. The JS logo presides over a chaotic crossing where constructor names are treated as suggestions. The funny part is that both languages have escape hatches and discipline tools: C# can use interfaces and generics; JavaScript projects can use TypeScript, runtime validators, tests, and linting. The meme ignores that nuance because the road is already full and somebody invited new ElonMusk().
Level 4: Nominal Roadblocks
The meme compresses a real type-system distinction into a road-crossing gag. In the upper C# panel, the function signature is visibly shaped like:
void ChickenCrossRoad(Chicken chicken)
The panel complains:
a duck??? in the chicken function?? i must give a compiler error!!!
That is static typing doing its job before runtime. In a nominally typed language like C#, a value's declared type matters. If a function asks for Chicken, then passing new Duck() is invalid unless Duck is related to Chicken through inheritance, an interface, an explicit conversion, or some other type-system-approved route. The compiler rejects the program because the contract is violated before the road-crossing logic ever runs.
The lower JavaScript panel uses:
function ChickenCrossRoad(Chicken)
and then lets new Chicken(), new Truck(), new Cat(), and new ElonMusk() crowd the road while saying:
i guess the road is bussy
The technical joke is that the JavaScript parameter name Chicken is not a type annotation. It is just a local variable name. Plain JavaScript does not enforce that callers pass a specific class instance at function entry, so the function can receive anything unless the code performs runtime checks. The parser sees a parameter, not a promise about poultry, vehicles, celebrities, or common sense.
Strictly speaking, this is adjacent to duck typing, not a perfect example of it. Duck typing means code accepts an object if it has the methods or properties needed for the operation: if it can crossRoad(), maybe it is good enough. The meme's JavaScript panel is even looser: it accepts things regardless of behavior because no check is shown at all. That exaggeration is the point. Dynamic languages give you flexibility, and flexibility without validation is how new Truck() ends up in the chicken lane.
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
58Comment deleted
JavaScript saw a parameter name and treated it as stakeholder guidance, not a contract.
Bussy🤯☠☠☠ (Stands for boy-pussy) Comment deleted
damn i was thinking the same Comment deleted
Typical dev meme user Comment deleted
What compile error C# is talking about? And it's a void method, not a function. Comment deleted
Method is just a function, bounded to a class. So it is a function Comment deleted
the thing is it is void how can it return anything ? Comment deleted
Appropriate username Comment deleted
:-) Comment deleted
Void function changes state of a program, it is basically a return value, but indirectly Comment deleted
yes, if it does something on the argument or the object it is called on Comment deleted
Function returns result, otherwise it's a procedure. But anyway, C# has Func as a Delegate (with result) Comment deleted
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 Comment deleted
bussy Comment deleted
What's the problem to check in JS case, if the "chicken" argument is instance of Chicken, and not something else? Comment deleted
TS exists for 11 years, but people are still blaming pure JS while using BS languages like Python or Lua Comment deleted
BS - BadaSs? Comment deleted
Yes. "I need your memory, CPU and all the time you have"... Comment deleted
it’s a matter of picking the right tool for the right job Comment deleted
lua, for instance, is amazing at being a plugin language Comment deleted
easy to embed, fast enough (especially if you’re using luajit), and pretty watertight in terms of sandboxing Comment deleted
Nope Comment deleted
Name a better tool Comment deleted
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 Comment deleted
Nothing beats js in the ability to bring suffering into one's life Comment deleted
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. Comment deleted
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 Comment deleted
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. Comment deleted
Sounds better than wasting your whole life on investigating some bullshit error in js Comment deleted
Easily getting fixed by try...catch block and logging the stack of the error Comment deleted
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 Comment deleted
There are known issues in all the programming languages and frameworks. I can remember dozens for C#, especially when it comes to async. Comment deleted
Eventloop is busy figuring out your life that's why Comment deleted
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 Comment deleted
*Transsexual, of course, not js's offspring Comment deleted
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 Comment deleted
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 Comment deleted
Implicit type conversion rules in JS can be learned in 5 minutes, they are simple AF. But ppl crying for decades because of them. Comment deleted
Because you offer them to eat shit, claiming: "it's only for five minutes, and then you'll get used to it" Comment deleted
"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"... Comment deleted
I miss static typing😔 Comment deleted
TS Comment deleted
Why would I do TS instead of a real girl Kotlin? Comment deleted
I'm not familiar with Kotlin, but isn't it related to Java? Comment deleted
It is, as a base version, but it can be compiled into JS And Kotlin Multiplatform is a thing Comment deleted
If it honks like a duck, has shitty hair plugs like a duck, it clearly must be a duck. Comment deleted
Or whatever else not connected to js Comment deleted
very unfortunate typo Comment deleted
also why the fuck Comment deleted
are people going on a full internet debate Comment deleted
Return times / Normalize long-form debates in Internet! Comment deleted
We have it and it was perfect! Comment deleted
This is also a meme Comment deleted
it's a meme Comment deleted
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). Comment deleted
I got into programming by large degree thanks to lua in cheat engine Comment deleted
i got into the whole it stuff due to clabretro Comment deleted
I used LUA to learn how to work with a private Tibia server. Best time of my life 🥺 Comment deleted