Method Chaining Target Rule
In object-oriented programming languages like Python or JavaScript, the calling object is treated as the haystack, so you write `haystack.method(needle)` instead of passing the collection as an argument.
In object-oriented programming languages like Python or JavaScript, the calling object is treated as the haystack, so you write `haystack.method(needle)` instead of passing the collection as an argument.
Data-first, method-call syntax puts the collection (the haystack) before the dot, so it becomes the implicit first argument — the caller instance. That's why `"hello world".includes("world")` reads needle-last, not needle-first.
In C's standard library function `strstr(haystack, needle)`, the haystack always comes before the needle.
In C's standard library function `strstr(haystack, needle)`, the haystack always comes before the needle.
C predates the object-oriented, data-first style, so its functions follow a procedural convention: the larger structure you're searching through is listed first, and the smaller item you're looking for comes second.
Every mainstream programming language applies the exact same needle-haystack argument order, so once you learn one you can predict all the others.
Every mainstream programming language applies the exact same needle-haystack argument order, so once you learn one you can predict all the others.
This is false — argument order conventions vary even within a single language's own standard library. PHP is the classic consistent example of inconsistency: some functions like `strpos(haystack, needle)` put the haystack first, while `in_array(needle, haystack)` reverses it.
PHP's `in_array()` function takes the needle as its first argument and the haystack as its second.
PHP's `in_array()` function takes the needle as its first argument and the haystack as its second.
`in_array($needle, $haystack)` puts the searched-for value first, which is the opposite order from many other PHP string functions — a well-known source of bugs when developers guess wrong.
Python's `in` operator, as in `"a" in some_list`, places the needle after the haystack.
Python's `in` operator, as in `"a" in some_list`, places the needle after the haystack.
It's the reverse: `"a" in some_list` puts the needle (the value being searched for) first and the haystack (the container) second, mirroring natural English phrasing rather than a function-call argument order.
Because JavaScript is a data-first language, `array.includes(item)` makes the array itself the haystack rather than a passed-in argument.
Because JavaScript is a data-first language, `array.includes(item)` makes the array itself the haystack rather than a passed-in argument.
This matches the data-first convention seen across OOP-influenced languages: the object you call the method on is treated as the haystack, while the argument you pass, `item`, is the needle.
Where this came from
This is one of 3 pieces in the chapter Predicting The Needle In Haystack Arguments.
It started 2 steps back, when somebody asked poisonal PHP And Why It Still Runs The Web
show the trail
Made 16 September 2026. Written by poisonal ai.
Your turn
Name a topic and poisonal makes you a whole spread of pieces like this one.
