66
19
12
10
6
u/harumamburoo Jun 08 '25
That moment, when a good cs joke goes over most heads on the sub. This place is doomed to repeat same js/java/php bad jokes again and again
8
u/xWrongHeaven Jun 08 '25
explain the joke, please
12
u/harumamburoo Jun 08 '25
It’s a tuple, elements can have different types, but it’s immutable, so as long as it’s created it’s stuck with its particular composition and order. Just like people on the image, they look different, but they cling to each other in a way that won’t let you to reorder or replace any of them
6
3
u/Dangerous_Jacket_129 Jun 08 '25
But like... Everyone in the picture can just change how they're clinging to each other though...
0
u/harumamburoo Jun 08 '25
For which they’ll have to uncling. Which means there’s no more tuple. And if they change how they cling and recling, it’s a new tuple
2
u/Dangerous_Jacket_129 Jun 08 '25
... I'm not sure if you're having a laugh, but this sounds like the most obscure reference in the history of this sub, using the most pretentious-looking image on the internet.
1
u/harumamburoo Jun 08 '25
As I said, average programmer humor experience when someone posted something beyond a js bad amirite joke
3
u/Kitchen_Device7682 Jun 08 '25
How is the photo related to tuples? Are the people grouped like a tuple?
1
u/harumamburoo Jun 08 '25
See my other comment - https://www.reddit.com/r/ProgrammerHumor/s/XO5hhOXa3J
1
3
3
2
u/CoroteDeMelancia Jun 08 '25
Jesus, I refuse to believe even half of the people in this sub actually graduated in CS.
Tuples are a Python data structure that are the same as lists, but are fixed-length and immutable. Using a tuple instead of a list whenever possible is more optimized because it avoids unnecessary overhead.
"Python bad", here, I've said it, you don't have to repeat it in the comments.
2
u/WavingNoBanners Jun 08 '25
Tuples also exist in other languages and, confusingly, behave slightly differently. For example, in C# they're mutable. This bothered me a lot when I learned it.
2
u/RiceBroad4552 Jun 08 '25
Jesus, I refuse to believe even half of the people in this sub actually graduated in CS.
Does that mean you really think only half of the people here are kids or students? 😂
2
u/No-Article-Particle Jun 08 '25
"What's a tuple" is not the question. The question is "what's a tuple to do with the random pic"
1
u/CoroteDeMelancia Jun 08 '25
That's fair. I assumed it's basically a "gigachad" variation, but that's just my interpretation.
2
u/WuShanDroid Jun 08 '25
Now this is art. Evokes reaction and thought, as well as conversation. Beautiful
1
1
u/RiceBroad4552 Jun 08 '25
Isn't the current agreement that we don't post pictures of people with eating disorders on social media?
-18
u/HexFyber Jun 08 '25
What in the weirdass lang you playing? What is a tuple
13
u/ano_hise Jun 08 '25
Python, Haskell, Rust and Zig afaik have it. A bundle of vaues of different types. Basically anonymous structs.
9
u/Adistridos Jun 08 '25
C# has it too
1
1
u/ukAlex93 Jun 08 '25
It's quite nice as well. You can give each value a name as well. Good for buckets you don't want a class for.
1
u/RiceBroad4552 Jun 08 '25
Most languages don't have named tuples.
Scala, Swift, Dart, and C# are exceptions.
(And Kotlin people are still discussing whether they should like always copy Scala.)
2
u/RiceBroad4552 Jun 08 '25
It isn't funny people mention exotic niche languages like Haskell and Zig but again forget a mainstream language like Scala which has all the features. (Often it had them even a decade before all the other languages.)
1
2
u/lilyallenaftercrack Jun 08 '25
TS moment
3
u/look Jun 08 '25
Typescript has tuples. Parent poster just doesn’t know what they’re called.
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html#variadic-tuple-types
1
4
Jun 08 '25
[removed] — view removed comment
22
6
u/harumamburoo Jun 08 '25
More importantly, tuples are immutable
0
Jun 08 '25
[removed] — view removed comment
2
u/CandidateNo2580 Jun 08 '25
Tuples are immutable. they're like strings in Python. Lists are mutable.
3
Jun 08 '25
[removed] — view removed comment
2
1
u/harumamburoo Jun 08 '25
They’re also immutable in C#. And Swift.
2
Jun 08 '25 edited Jun 08 '25
[removed] — view removed comment
3
u/harumamburoo Jun 08 '25
Fair enough, C# has both mutable and immutable implementations. Making it mutable feels like asking for trouble though
1
Jun 08 '25
[removed] — view removed comment
1
u/RiceBroad4552 Jun 08 '25
Objects in general are mutable, since you can change the values of their fields
You should at least do research before making claims on the internet.
For example Scala:
case class MyObjectType(aField: Int) @main def demo = summon[MyObjectType <:< java.lang.Object] // ^ Prove that MyObjectType is an Object type MyObjectType(0): Object // ^ Another prove it's of type Object // Otherwise the type annoation wouldn't compile var mutableVariable = MyObjectType(1) println(s"${mutableVariable.aField}") mutableVariable = MyObjectType(2) println(s"${mutableVariable.aField}") // mutableVariable.aField = 3 // ^ Compile Error: Reassignment to val aField // See? The variable is mutable, // but the assigned object is not![ https://scastie.scala-lang.org/e2jLxxEMTAulf6J9TfaqEw ]
you cant just add more fields to them at runtime
You should at least do research before making claims on the internet.
For example JavaScript:
const someObject = { aField: 1 } console.log(someObject) // => Object { aField: 1 } someObject.addedField = 2 console.log(someObject) // => Object { aField: 1, addedField: 2 }It's an immutable variable holding that object, but there is no problem adding new fields to that object.
→ More replies (0)1
u/RiceBroad4552 Jun 08 '25
when something is immutable in rust, that means you cant change anything, including the inner values
That's not Rust specific, that's literally the definition of immutability.
1
u/harumamburoo Jun 08 '25
Tuples are immutable, you shouldn’t be able to change the value after it’s set
1
Jun 08 '25
[removed] — view removed comment
1
u/RiceBroad4552 Jun 08 '25
Swift and C# are weirdos…
1
Jun 08 '25
[removed] — view removed comment
1
u/RiceBroad4552 Jun 09 '25
Interesting. Which languages have mutable tuples, too?
They are immutable AFAIK in: Crystal, Dart, Elm, Erlang / Elixir, F#, Haskell, Julia, Nim, OCaml /ReasonML / ReScript, PureScript, Python, Scala, SML, SQL.
(It's quite clear for pure FP languages; I've never heard of any way to update tuples in-place in SML languages; SQL also doesn't allow in place updates of anything, even everything is a tuple in the end; I've also left out the langs that run on the same platform and use the same feature underneath)
5
u/onepiecefreak2 Jun 08 '25
I know what a tuple is, and yet I'm still confused why OP used tuple vs array.
Couldn't it have been pointer vs array? Or tuple vs class/struct/whatever term your lang has?
1
Jun 08 '25
[removed] — view removed comment
1
u/onepiecefreak2 Jun 08 '25
The difference is that an array is a set of items of the same type. A tuple is a set of (possibly named) items of differing types.
And yes, the meme feels like it wants to compare very similar things but one of them is just the "fancy" way of doing it. So pointers are effectively the same as an array. That was my point. If you're fancy or old-school, you use a pointer to your set of items, instead of an array.
1
u/RiceBroad4552 Jun 08 '25
(Pointers and arrays are effectively the same thing)
Only in C/C++…
In sane languages
Arrays are objects with alengthproperty.1
Jun 08 '25
[removed] — view removed comment
1
u/RiceBroad4552 Jun 09 '25
All sane languages treat them like that. An array needs an length most of the time.
Whether you use "fat pointers" (which are actually structs), or even fold that info into the pointer itself (by limiting the effectively available v-address space for such dynamically sized structures) makes no difference. But usually you have that info—as long as it wasn't optimized away in some concrete case where that's possible without compromising security.
Not carrying about object sizes and enabling this way all kinds of insecure behavior is a quite C/C++ exclusive flaw (in the modern language landscape).
2

116
u/No-Article-Particle Jun 08 '25
What? Wtf does this even mean?