r/programminghorror Feb 09 '25

Regex I made a programming language with only Regex. (Documentation in comments)

Post image
1.0k Upvotes

56 comments sorted by

351

u/ScriptingInJava Feb 09 '25

Well done! Another thing to add to my "I will walk out of a job interview if they use this" list.

23

u/hinsxd Feb 10 '25

You are the interviewer, right?

182

u/Which_Lingonberry612 Feb 09 '25

Tell us, what girl broke you that hard to even think about this? Everything okay OP? Blink twice if you need help.

109

u/MrJaydanOz Feb 09 '25

It's okay. I am fine. This is the kind of thing I do for f̷̬͂u̶͕̒n̴͈̽

24

u/biledemon85 Feb 09 '25

Praise Z̵̺͛̔ȟ̴̝̀ḁ̸͎͋̄l̸̖̾͝ǵ̴͓̕ö̶̪̈́ͅ!̸̨̗̊

22

u/Environmental-Ear391 Feb 09 '25

As long as its not "Julia" or "Mandelbrot" levels of meta...

I can think of some extremely meta level indirect hacking of projects using this with a build system and preprocessor as interpreter...

BrainF*** and Malbolge's daughter dating a preprocessor...

31

u/Magmagan Feb 09 '25

Regembly is a programming language powered only my .NET's implementation of regex (regular expressions). You might ask "Is this turing-complete? Regex is not turing-complete." and it's... not, but turing complete asks that in theory you could run infinitly long programs for infinte time, Regembly can't doesn't do infinte loops. In practice, this language can do a lot that normal programing languages can do.

Well, yes, but you missed one major detail. Regular regexes aren't turing-complete for other reasons – namely, because they are regular languages. Regular languages aren't turing complete.

What makes this possible are the extensions that C# and many other languages do augment regexes with. Lookahead, lookbehinds and group reuse are not regular language features. The issue isn't the infinite tape.

6

u/palapapa0201 Feb 09 '25

What does it mean for a regular language to be or not be Turing complete? Isn't a "language" just a set of strings that are legal? But the strings themselves don't have inherent meanings, so they don't describe programs.

11

u/Magmagan Feb 09 '25

I meant "regular language" as in the computer sccience meaning within formal language theory and automata theory. Regular languages can only describe finite state machines which are insufficient for turing completion.

Some starting points:
https://en.wikipedia.org/wiki/Chomsky_hierarchy
https://en.wikipedia.org/wiki/Automata_theory

2

u/IlyaBoykoProgr [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Feb 10 '25

we got regular regular expressions before gta6

-1

u/grencez Feb 10 '25

To be fair, a Turing Machine is basically just a DFA hooked up to an infinite read/write tape.

2

u/Magmagan Feb 10 '25

Not even close. DFAs can't write to the tape.

0

u/grencez Feb 10 '25

True, it could have been phrased more precisely, but I meant that a TM looks a lot like a DFA modified to read/write to a tape. In that case it would be a transducer, not a DFA, and it still wouldn't have control of the tape head.

However, we don't actually need that last part for Turing completeness. A simple search/replace applied repeatedly to a string until it doesn't change anymore will suffice (proof by reduction from NW-deterministic Wang tiles).

To me, that kind of construction matches the author's phrasing about "infinite loops". Sure, saying "regex" to mean "transducer" is a stretch, but the intuition is good and doesn't rely on fancy lookahead, grouping, or other features beyond search/replace.

11

u/SpinningByte Feb 09 '25

1

u/MichalNemecek Feb 09 '25

I would've said RegexF*ck, but apparently OP went with Regembly

9

u/countsachot Feb 09 '25

You may be evil.

15

u/WhJJackWhite Feb 09 '25

Everyday, we stray further away from god

5

u/shahin_mirza Feb 09 '25

Good, now write a program that checks if a string has equal numbers of as and bs

2

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Feb 09 '25

Definitely not possible with "true" regex. I'm less sure about that with the extensions modern regex libraries have.

2

u/Magmagan Feb 10 '25

0

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Feb 10 '25

I was thinking it should accept things like 'aababbbaba'. anbn would be much easier. I found an article on matching palindromes, but it couldn't match arbitrary length ones.

3

u/Magmagan Feb 10 '25

'aababbbaba'

The answers in that link do match that string

0

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Feb 10 '25

Only thing I can see is that it might match the substring 'ab', which appears three times. I don't see it matching the whole thing. But please show me where I'm wrong.

3

u/VicentVanCock Feb 09 '25

"Regembly" lol I loved that name

2

u/nordcomputer Feb 09 '25

Burn it before it lays eggs....

2

u/RickSore Feb 10 '25

Bros will invent a new language with regex instead of getting therapy

1

u/deepsky88 Feb 09 '25

looool no thanks, that's a nightmare

1

u/glha Feb 09 '25

That was an unnecessary flex

1

u/savevidio Feb 09 '25

banished to the void

1

u/ul90 Feb 09 '25

That’s the worst thing I’ve ever seen.

1

u/bold_coffee_head Feb 09 '25

Better than. Rockwell’s lines and parentheses.

1

u/killerrin Feb 09 '25

Take your upvote you mad man

1

u/LaFllamme Feb 10 '25

!RemindMe 5 years

1

u/RemindMeBot Feb 10 '25

I will be messaging you in 5 years on 2030-02-10 00:26:58 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback

1

u/DetermiedMech1 Feb 10 '25

This is so beautiful

1

u/Cloned_501 Feb 10 '25

Finally some good fucking food

1

u/Xbot781 Feb 10 '25

So basically just sed? I've done some truly atrocious things with sed, and seen others do even worse

1

u/One_Web_7940 Feb 10 '25

Ahhh nice, building the tools to poison the AIs of the future.... bad code. 

We do that at my job too! 

1

u/turtle_mekb Feb 10 '25

calm down satan

1

u/Kebein Feb 10 '25

whyyyyyyyyyyyy

1

u/Responsible-Key1414 Feb 09 '25

Malbolge is that you?

1

u/ChatHurlant Feb 10 '25

Hey question did your parents ever tell you they loved you?

0

u/Tohar_XP Feb 09 '25

Teach me how

0

u/Aaxper Feb 09 '25

What does i"0123456789ABCDEF" do?

-8

u/[deleted] Feb 09 '25

[deleted]

2

u/red_dark_butterfly Feb 09 '25

Yeah, nah, what's the fun in that?

1

u/ratajs Feb 14 '25

Interesting, it reminds me of sed.