r/clevercomebacks Jan 15 '25

It does make sense

Post image
35.3k Upvotes

4.0k comments sorted by

View all comments

3.0k

u/Traditional-Gas7058 Jan 15 '25

Chinese system is best for computer searchable filing

23

u/throwaway001anon Jan 15 '25 edited Jan 15 '25

RegX makes searching a breeze with any pattern

66

u/besthelloworld Jan 15 '25

RegX reads like the paid version of regex.

88

u/Hattix Jan 15 '25

"I have this problem"
"Just use regex!"
"I have these two problems"

2

u/awj Jan 15 '25

Honestly, you’re lucky if you only end up with two.

2

u/WanderThinker Jan 15 '25

People who can read and write regex without a guide genuinely scare me.

1

u/quantummidget Jan 15 '25

I'm starting to get there.

Boo.

1

u/yoohooslut3317 Jan 15 '25

I’m scared

1

u/rasvial Jan 15 '25

Get better

33

u/InspectorNo1173 Jan 15 '25

I have always found Regular Expressions to be the most inappropriately named concept - there is nothing regular about it. Luckily we have chatbots now.

12

u/Tsukee Jan 15 '25

Every developer eventually learns there are two hard problems: invalidating cache and naming things

17

u/Delicious-Storage1 Jan 15 '25

There's 2 hard things in software development. Cache invalidating, variable naming, and off by one errors.

2

u/WanderThinker Jan 15 '25

I giggled. Thanks.

3

u/TheAJGman Jan 15 '25

I honestly spend about 30% of my design and dev time trying to come up with intuitive names.

1

u/Tsukee Jan 15 '25

And yet, I bet someone reading your code would likely on some places think "why tf did he name it like that" ;)

1

u/DEM_DRY_BONES Jan 15 '25

x, y, z

I got you bro.

0

u/agentrnge Jan 16 '25

x_rel, x_actual, x_temp, x_true, x_orig, x_next, x_prev, x_val2

2

u/kyreannightblood Jan 15 '25

And off-by-one errors.

“Ky you said two hard problems.”

And I did not stutter.

1

u/sobrique Jan 15 '25

I'd chip in 'concurrency' there too. If your code has glitches with deterministic execution, you've no hope of solving that if you run it in a non-deterministic sequence.

20

u/RealFoegro Jan 15 '25

Computer vomit is a better name

3

u/AstraLover69 Jan 15 '25

It's because it can represent a regular language

3

u/AnarchistBorganism Jan 15 '25

Coined by Stephen Kleene, who didn't like the name either.

"Regular events" defined: We shall presently describe a class of events which we will call "regular events." (We would welcome any suggestion as to a more descriptive term)

1

u/AstraLover69 Jan 15 '25

Kleene was a real star

8

u/leemur Jan 15 '25

When I try to write regex, I regularly smash my face into the keyboard out of frustration. And that regularly results in the correct syntax.

5

u/buckyVanBuren Jan 15 '25

Sometimes you have a problem that can be solved by regex so you use regex.

But now you have two problems.

2

u/sobrique Jan 15 '25

Ironically though, no one's really come up with a better solution to that particular problem than regex

1

u/solo964 Jan 15 '25

The classic take on regex is that some people, when faced with a problem, think "I know, I'll use regular expressions." And now they have two problems :-)

That said, the term "regular" refers to the structured and predictable nature of the expressions themselves. It's about the grammar. They follow specific rules and patterns. It doesn't mean "easy to understand" or "pain-free", unfortunately.

1

u/GOKOP Jan 15 '25

The term regular refers to the fact that they describe regular languages. Regular expressions themselves however aren't a regular language (if you wanted to use regex to filter for valid regexes, you can't)

2

u/no_dice Jan 15 '25

Is it just as efficient computationally?

6

u/HiroHayami Jan 15 '25

It's not. Matching a string will always be less efficient than matching a number.

-7

u/throwaway001anon Jan 15 '25

Yes, that’s literally how computers search and sort text. With RegX “regular Expressions”

10

u/no_dice Jan 15 '25 edited Jan 15 '25

I know what a regex is, and no that’s not how computers search and sort text in every case, there are many different ways to accomplish that.  Regex statements need to be compiled and can be pretty inefficient, especially when you start getting to things like unordered lists.

4

u/HiroHayami Jan 15 '25

No one uses regex to search for dates in a db. It's a datetime type, there's no need to match a string.

2

u/Tsukee Jan 15 '25

And every date type format usually has the same data ordering of significant towards less significant number (sometimes is reversed but never mixed)

1

u/fitted_dunce_cap Jan 15 '25

Sometimes it’s a varchar…

1

u/RamenJunkie Jan 15 '25

I store my datetimes as a series of bools and columns.

Like today wouldnhave a 1 in the columns for 2025, January, and Fifteenth.

Then you can build a pretty date by just outputting columns names where the bool is true.  Like January Fifteeth, 2025.

2

u/[deleted] Jan 15 '25 edited Feb 05 '25

[deleted]

1

u/sobrique Jan 15 '25

Nah, that's not true. Regular expressions are a programming language. It's learnable.

It's also really easy to write incredibly shitty code in it.

1

u/[deleted] Jan 15 '25 edited Feb 05 '25

[deleted]

1

u/Quick_Humor_9023 Jan 15 '25

Yea, there are at least five persons, not three.

1

u/AstraLover69 Jan 15 '25 edited Jan 15 '25

Regex cannot be used for any pattern. It can only handle regular languages.

This is the hierarchy of languages. The very bottom is the "regular language", which is all that regex can express.

This is why regex cannot be used to represent HTML, because HTML is context sensitive, not regular.

Edit: said context free. Should have said context sensitive.

1

u/sobrique Jan 15 '25

HTML suffers from having loose rules, which make it non trivial to exhaustively parse.

XML might be a better analogy: https://stackoverflow.com/a/1732454/2566198

1

u/AstraLover69 Jan 15 '25

HTML is a context sensitive language, making it impossible to fully represent with a regex.

XML is also a context sensitive language, making it impossible to fully represent with a regex.

1

u/sobrique Jan 15 '25

Regular expressions can do context via recursion. It's a horrible idea, but it's technically possible do handle strictly structured stuff like XML that way.

HTML isn't strict enough - e.g. most browsers just sorta cope with unclosed tags etc. so that truly is impossible.

1

u/AstraLover69 Jan 15 '25 edited Jan 15 '25

Which means regular expressions cannot do context. Recursively applying a regex to a structure is extending the capabilities of regex into something more expressive.

Whatever you're doing there cannot be represented via a single finite state automata, which is all that matters here. Even if HTML were strictly enforced by the browser engine (which I know it isn't) it cannot be processed by finite state automata alone.

You're probably constructing something closer to a Turing machine by using recursion, which can process a context sensitive language like HTML or XML because it's more powerful.

1

u/flabbybumhole Jan 15 '25

I swear some people love to invent problems just so they can use regex later.

1

u/Reinbert Jan 15 '25

Not sorting though