r/ProgrammerHumor • • Oct 27 '26

Meme multiStringing

Post image
1.6k Upvotes

50 comments sorted by

34

u/azfang Oct 27 '26

Some time ago, I was reading something that led with a caveat they would try to avoid technical terms, with the example of using “text” rather than “string.”

I spent several moments trying to parse what the difference was before realizing that I have fully adapted to life in a cave and am too far gone to survive daylight.

1

u/Kadabrium 13d ago

text == textile

280

u/alficles Oct 27 '26

You jest, but I received this exact answer in an interview. It was a early-career programming position and we were starting with simple stuff to level set the interview.

Me: What is a thread and how would you use it?
Them, with complete confidence: A thread is a lightweight string.
Me: Elaborate.
Them: If you have a string that's really short and you don't want to do very much with it, you can just use a thread.
Me: What if I want to do a lot with it?
Them: Use a rope.
Me: Interesting. What sorts of tools would you use for managing concurrency?
Them: You need to make sure the desk is big enough for two computers for that. And you need enough power to run both.

He did not ultimately get the job, but I'm assuming he's making bank as a mod of /r/confidentlyincorrect. His answers were always instantaneous, with no hesitation at all.

I'd've been more impressed with the correct rope answer if it weren't completely clear that he was right completely by accident. :D

67

u/DrShocker Oct 27 '26

I've never thought about it, but does every major programming language call a group of characters a string? I know there's some debate around string view/builder/slice/etc terminology but the core concept always seems to be a string in the ones I know.

48

u/ubergeek801 Oct 27 '26

Java has String of course, but it's but one implementation of the CharSequence interface. So a "group of characters" is not necessarily called a "string" depending on the context.

19

u/GumboSamson Oct 27 '26

Sure.

A string usually implies contiguous memory. Like in C, there’s no string type—just a char type, which you can put into an array.

Unfortunately, contiguous memory strings aren’t considered very secure. If something is able to read your memory, it can read your string pretty easily.

So some SecureString implementations use non-contiguous memory to store text. That is, each character is sprinkled around different places in memory, which makes them hard for a memory reader to discover and interpret.

Both of them are character sequences but only one of them is a string (in the typical sense).

8

u/Ok-Scheme-913 Oct 27 '26

contiguous memory strings aren't considered very secure

This sentence makes no sense. There is no such thing as an absolute value for security, security is always in relation to an attack vector.

For storing a password? You are right, for this use case a String in most languages is not a good fit, you don't want immutability, nor it being continuous in memory, and you want to zero it out right after use.

For most everything else, you want good performance and reading out your "--help" message from memory is not a vulnerability.

6

u/GumboSamson Oct 27 '26

Firstly, I agree with everything you said here.

Except for the part where you implied that I claimed that all strings need to be treated securely. Most of them don’t, and that’s exactly why contiguous memory strings are popular.

Like you said, they’re fast, everybody understands them, nobody is surprised. They’re the best solution most of the time.

My point is that contiguous memory strings aren’t the only way to handle character sequences, and there are real cases when you’d pick one over the other. Not saying that one is universally better (which isn’t how engineering works).

2

u/Ok-Scheme-913 29d ago

Yeah I was sure you know it, it was just a bit unfortunate way to put it and I do see bad security takes all over the place so I just wanted to add my two cents so someone else doesn't misinterpret it

1

u/Stalking_Goat 29d ago

Breaking up strings into individual characters and scattering them throughout your source code is a great trick for the International Obfuscated C Code Contest though!

11

u/Loading_M_ Oct 27 '26 edited Oct 27 '26

Well, this gets complicated. A "group of characters" is ill defined.

For example, in Rust, you could be referring to:

  • String: an owned, mutable group of Unicode code points encoded in UTF-8
  • &str: similar to above, but an immutable borrow of the same
  • impl Iterator<type = char>: an iterator that produces Unicode scalar values (for a real example, the to_lowercase method on char returns an iterator, since some Unicode code points expand into multiple code points when lowercased)
  • HashSet<char>: a group of Unicode scalar values, without an order or duplicates

8

u/rosuav Oct 27 '26

Yeah, but broadly speaking, if someone says "string", you can debate the details while still agreeing that you're talking about a sequence of characters. In Python, you can have byte strings and text strings, in Pike you can have a variety of subtypes of string (most commonly 8-bit and 21-bit strings which correspond to byte and text, but you can also declare a 7-bit string that (since it's ASCII-only) is compatible with bytes and text if you use UTF-8, or a 32-bit string, which is useful for vectorized operations). None of these is anything like a "thread".

3

u/Ok-Scheme-913 Oct 27 '26

A String is by definition ordered, but otherwise I agree.

The more important distinction though is whether it's mutable or not, this is where programming languages split into two camps.

1

u/fghjconner Oct 27 '26

Don't forget OsString, which is a platform dependent type with slightly different rules.

1

u/Loading_M_ Oct 27 '26

OsString (and related) are basically just String (and related) but in the platform's native encoding rather than UTF-8.

There is also CString, which is UTF-8, but with a trailing null byte for C interop.

These basically fit into the types I describe, but have slightly different restrictions (and the OsString isn't technically interpretable, you're supposed to convert it to a string before trying to edit it).

2

u/ryuzaki49 Oct 27 '26

I assume that array of chars used to be the default before the String name. 

1

u/mtmttuan Oct 27 '26

"a group of characters" is a list or a set of characters. String can be converted to that but they're not exactly the same.

13

u/PumpkinFest24 Oct 27 '26

Hypothesis: Misheard "string" as "process". Disproof: Would not have generalized to rope.

Hypothesis: Was non-programmer. Disproof: Would not have said "lightweight" (in exactly the right context) or known what "concurrency" meant.

I conjecture this was an fake interview. ie he didn't want the job.

8

u/the_horse_gamer Oct 27 '26

correctly answering rope is insane. this is like a comedy skit.

7

u/Not_a_penguin15 Oct 27 '26

This is so insane it almost feels fake (but also totally believable)

5

u/alficles Oct 27 '26

I was there, and "so insane it has to be fake" is precisely what we were feeling. :D

7

u/Ok-Scheme-913 Oct 27 '26

Technically, ropes are a string-like data structure.

But to his misfortune, threads aren't.

3

u/SelfDistinction Oct 27 '26

Counterpoint: a rope is a very heavy string that's more optimised for text processing.

2

u/meneldal2 Oct 27 '26

A rope is what you use to hang yourself after O(n2) concatenation you shipped in a AAA game and wasted enough energy to make 100 bitcoin because of it.

Just kidding I bet R* don't care about wasting their players time.

1

u/SelfDistinction Oct 27 '26

Should've used vim instead lol.

2

u/Moekki_ Oct 27 '26

Love that you added that he didn't get the job

2

u/Stalking_Goat 29d ago

The applicant screwed up by not being the CEO's nephew.

159

u/fcman256 Oct 27 '26

Christ it took me way too long to figure out how someone could think string and thread are the same thing. What’s the reverse of op’s meme? Cause that’s me right now

My wife is addicted to all things thread related too, needlepoint, crochet, etc.

42

u/UndocumentedMartian Oct 27 '26

Crocheted programming.

16

u/dudes_indian Oct 27 '26

Programming has its origins in textile looms for real.

6

u/Ok-Scheme-913 Oct 27 '26

Punched cards quite literally come from there. And yeah, it's really cool!

10

u/National-Explorer755 Oct 27 '26

Multi threaded crocheting

2

u/Cautious_Tonight Oct 27 '26

Same here and I didn’t see the sub name hahaha

23

u/invaderdan Oct 27 '26

I don't think I get this joke. Am I too good of a programmer to understand why this confusion would exist? I have no idea why these two things would ever be confused.

But wait though I'm an absolute shit programmer. Like super shit.

But stings and threads are obviously different. Is this a clothing joke?

Edit: FUCK I read it again. I get it. Threads and strings are absolutely the same.

24

u/DependentPipe9226 Oct 27 '26

Non programmers would think thread and string are the same thing because they don't know what it means in coding. All they see it as in knitting where thread and string are basically the same thing

9

u/Boris-Lip Oct 27 '26

Is it string-safe?

7

u/AkrinorNoname Oct 27 '26

Okay,but even from a textile perspective, isn't string much thicker and used for binding things, while thread is for sewing? (There's also twine, which is made from two threads twisted together for extra strong seams)

4

u/nikstick22 Oct 27 '26

The average layperson isn't going to know that either. In casual speech, thread and string are used for any sort of thready stringy bits. If someone pointed to a bit of loose thread on a shirt and called it a string, no one would bat an eye.

1

u/lilloet 26d ago

wait until you hear about fibers

1

u/Kadabrium 26d ago

And the rope data structure

2

u/Mad-chuska Oct 27 '26

It’s all ones and zeros my dear. Ones and zeros.

1

u/power276 Oct 28 '26

they arent tho. at least how i use them, string ⊃ thread and thread > string

-2

u/mamebb2023 Oct 27 '26

they are the same

6

u/Jatinchd Oct 27 '26

you're not a programmer vro.

3

u/who_you_are Oct 28 '26

string = what is used in computer for text (aka what you are literally reading right now).

thread = what a computer use to multi-tasks. Technically you can apply the idea to human as well since you only have one body.