What is a string? Shitty programming

So here I am sitting in my towel during a night where I cannot sleep. I’ve decided to boil myself a cup of coffee and write down the thoughts in my head that unfortunately won’t escape.

The question on my mind is something I’ve been meaning to start out. Practicing a blog so I can learn more about IT or programming in general. The problem is, I’m a terrible programmer. In-fact, I’m a shitty programmer. I have the heart to say it, even though it hurts so much. I’ve meet tons so many brilliantly talented people in my time from university to work life. Even through High School, I’ve met some insanely talented and bright individuals. Unfortunately in today’s climate, I feel I am not one of them. In order to alleviate this traumatic sadness, I thought it best to sit down in my towel, make a cup of coffee and ponder the most basic questions and fundamentals of programming. All at 12:30am. The most basic of which is:

What is a string?

Ah, the age old question. Is it a length of thread. Surely it’s nothing more then a series of characters. Letters and numbers or ones and zeros. How long is a piece of string my old high school English teacher would pronounce. How I hated her condescending tone. Although I must admit she did challenge me a lot. The point is, I don’t know and I strongly believe without any evidence at all that there is an upper limit to the length of a string and it is somewhere embedded in the architecture that it once came from.

Please, did you really thing such a question would have such a simple answer?

Look it probably does. If I do a quick Google search I’ll probably find it rather quickly. Let’s have a look.

Okay what the fuck Google. That is not a simple answer, that is even more confusing then what I was originally thinking. It’s twice as long as half it’s length? That is totally not going to fly in IT world where things need to be an exact science or everyone’s heads will explode. Computers and their budding programmers cannot handle this level of ambiguity and perhaps philosophy. There’s clearly a problem with what I’m searching. Google is never wrong, everyone loves Google. Let’s take a look.

Funny answer, hahaha, I love how we’re all not funny and we have to rely on someone else to pretend we’re funny. I’m so not funny. Comeback? We’ll I wish I searched that to remind my piece of shit English teacher (don’t tell her I said that, I actually respect her a lot). Documentary?? We have an ENTIRE DOCUMENTARY dedicated to this simple question.


Okay, so I’m obviously not making this clear enough for someone. Let’s try this:

Oh yeah, now we’re on the money and I’m starting to get tired already. Do you see how adding the simple ‘computing’ to my keyword search yields the specific results that I need. This is indeed a talent I have come to possess over my formative career and university cycle. I can see others have searched for two things: C and Java. So I believe I was right in my assumption that it differs in architecture. Is programming language an architecture? Fuck, I don’t know. I though it was CPU architecture, like 64-bit AMD processor or Intel something-a-rather. Wow, I am really bad at this. Maybe we’ll leave that definition for another time as I also find that term used for building enterprise systems, e.g “What is the security architecture here?” or “What does your girlfriend do?”, “Oh she does architecture”.. Right.

Anyway, I’m sure Wikipedia here nails it on the head pretty hard. It tends to do that a lot. Funny, I still remember my teachers telling us it’s not a reliable source of information. Ha, suckers. It’s pretty much all my High School assignments. So lets try to interpret what Wiki has to say on the subject.

“Is traditionally a sequence of characters” – Fuck yeah, I got something right. Dummies.

“Either as a literal..” – Wtf

“While it could be stored as a long consecutive array of characters” – Yes, “a typical editor instead uses an alternate representation” – What?! Why? Why change things and make things different… Oh if only I had the cry emoji my pain could be felt so much harder.. Fine, lets deep dive into this Wikipedia shit.

Yes, yes I see now. Useless info-graphics that have little to do with what I’m searching. Fantastic at distracting the eye from the real problem. Bioinformatics you say, nitrogenous bases. Fascinating. Fuck off. I’m here to learn only the real meaning of strings.

Okay, look lets face it here, I have no idea what’s going on. There’s a lot of maths and weird symbols I’ve never seen or can even pronounce so lets just take it slow. I’m sure we can handle it. Starting from the beginning.

Let the sum of a non-empty finite set of symbols (alternatively called characters), called the ALPHABET. Oh. My. God. You mean the alphabet, why add all the extra nonsense about finite sets. Jesus, okay, so we have an alphabet right.

Let’s add some more pepper onto this. So we have an alphabet and we don’t care if it’s Japanese or English, I get it. So a string is some kind of sequence of characters from the alphabet that when added together from a string in that alphabet. Oh my god, I’m a genius and as it turns out, there is a length of a piece of string. Yes, you heard it hear first.

A String is not “Twice as long as half it’s length”.

Wait, or is it. What’s twice as long.. Forget it. The fact is, it has a set length.

Yes the length of a string is the number of symbols in it. For some reason it’s a non-negative integer, but who cares about the details. So we have a bunch of characters. That’s great. I should applaud myself for finding out something I already knew. Which begs a question, what is something I don’t know. Surely I didn’t come up here in my towel to sit here for an hour for nothing. Let’s get real raw, deep and dirty style and find something cool about strings that I never once knew, or partially knew but never fully understood (which is a majority of things in IT). Lets see.

Enter, the “Incompressible String”. Sounds honestly quite scary. Like, the thing of programming nightmares. Not even just programmers, but sysadmins and product owners alike. It even sounds like something the Starship Enterprise would encounter (not that I’m a huge Trekkie). “The Incompressible string” it’s too powerful. Raise the shields and get the photon cannons ready because we’re going in head on.

Let’s all take a moment for this one to sink in. It cannot be compressed due to insufficient redundancy. It seems like it’s to random. “The quick brown fox jumps over the lazy dog” style. Well, it had me up until the line where it says, “No strings are incompressible, except an empty string”. Wow, what a colossal anti-climax. So there is no such thing as an incompressible string.. What a load of horseshit. Or is it that, if we know about the incompressible string, we can create an algorithm for that exact incompressible string so we can compress it. Like a gun specifically designed to kill zombies and only zombies. Lets read further.

Okay so I’ve skipped over the mumbo jumbo but feel free to read the real article if you’re so inclined. The fact is:

  1. 1. Given you have a string 12349999123499991234
  2. 2. And a compression algorithm that results in @[email protected]@[email protected]@0
  3. 3. That then compresses further to @[email protected]@1
  4. 4. You try use the same algorithm for a different number 1234999988884321
  5. 5. Results in [email protected]@[email protected]@[email protected]

Causes a piece of shit string that’s the same length as the original. What’s up with that. That ain’t no compression. This is not what Silicon Valley has taught us! No way, it’s an uncompressable string.

Hold up, not in the way we think it it. See, it’s only given that shitty algorithm that actually isn’t used in real life (because it’s obviously a piece of shit and can’t compress for it’s life) that couldn’t compress it. I mean, if we created a new and better algorithm, we could in-fact compress – the uncompressable string.

Get it?

Amazing and there you have an insight into my journey of strings, the string universe and string theory. Or is that something entirely different to strings. I don’t know but it’s much simpler to think of it as a piece of yarn – dad joke. Or it’s not really a joke at all. In-fact that’s not even funny. I’m not funny.

P.S Lesson and image courtesy of Google – Thanks Google!

P.P.S Holy shit there’s totally a documentary by the BBC on “How long is a piece of string” – Hey, it’s poorly reviewed, but if you read all this, who cares!

Category Blog

What do you think?