4 ms·
That doesn't solve the most problematic part of regexing for me: having a different programming language embedded as a string in my other source code. The same
by maweki 4y ago
That doesn't solve the most problematic part of regexing for me: having a different programming language embedded as a string in my other source code. The same happens with SQL in many codebases.
The embedded string is often precluded from static analysis. Fieldnames or names of capture groups may drift apart from the outside code and maybe nobody notices.
What we need are more embedded DSLs where we get static syntax and type checks and hopefully a good integration between the surrounding code and the embedded code.
- deleted 4y ago[deleted]
- Jorengarenar 4y ago>problematic part of regexing for me: having a different programming language embedded as a string While there is nothing stating programming languages need to be Turing-Complete (and there are in fact examples of non-TC programming languages, if only educational), I think calling regular expressions* a "programming language" may be a bit of a stretch. * Even when its capacities are as extended outside the mathematical definition as modern RegEx is. edit: specified I meant "non-TC programming languages"
- maweki 4y ago> and there are in fact examples of non-TC languages, if only educational Sure, SQL is only educational or not programming. There seems to be a lot of programming going on in the world generating a lot of value which you wouldn't recognize as such. Excel uses a terminating (and therefore not computationally complete) dataflow-based evaluation model but it's in no case programming. Are you sure? I'd think, telling a computer "if you recognize a pattern described as such, replace it with so and so", just regex with replacement, sounds very much like programming to me. Very weird where you draw the line.
- JadeNB 4y ago> Sure, SQL is only educational or not programming. > There seems to be a lot of programming going on in the world generating a lot of value which you wouldn't recognize as such. Excel uses a terminating (and therefore not computationally complete) dataflow-based evaluation model but it's in no case programming. Are you sure? I think this is not the most charitable reading of your parent. You're taking it as if they definitively rejected SQL and Excel as programming languages and arguing from that, rather than that maybe they didn't think of them. I think it would have been easy to make the case for SQL, Excel, and even (ir)regexes as programming languages without taking a sarcastic tone. For example: > I'd think, telling a computer "if you recognize a pattern described as such, replace it with so and so", just regex with replacement, sounds very much like programming to me. Very weird where you draw the line. could easily have asked instead, where do you draw the line?—which would surely be a more interesting discussion.
- maweki 4y ago> could easily have asked instead, where do you draw the line? The commenter made that quite clear. Using a computational model that's not complete can not be called "programming" in any real-world context. Which is weird. This kinda implies that, whenever I forbid myself to write my Python-Code without While-loops or recursion, I'm not programming. The traditional definitions of programming are often along the lines of instructing a machine to perform certain tasks.
- Jorengarenar 4y agoLiterally the first thing I wrote is that there is no requirement a programming language needs to be Turing-Complete.
- Jorengarenar 4y ago>Sure, SQL is only educational or not programming. Last time I checked SQL was proven to be Turing-Complete? While Excel's formula language wasn't always TC, the program as a whole, I believe, was since the very beginning. >telling a computer "if you recognize a pattern described as such, replace it with so and so", just regex with replacement, sounds very much like programming to me. I think by adding "if X then replace" capability we already escaped outside the bounds of Type-3 grammar, i.e. it's not a regular expression anymore (despite being build upon one).
- maweki 4y ago> Last time I checked SQL was proven to be Turing-Complete? Without recursive CTEs, it isn't. And there's nothing much to prove about that. Finite SQL statements on finite databases always terminate and it's therefore not computationally complete.
- Jorengarenar 4y agoIndeed, I stand corrected. Older standards of SQL show that among DSLs we can (or at least could) find non-TC programming languages in the wild.
- btown 4y agohttps://forums.swift.org/t/pitch-strongly-typed-regex-captures/53391 https://forums.swift.org/t/pitch-strongly-typed-regex-captur... might be of great interest to you!
- RobertRoberts 4y agoI agree with you. I got tired of fighting with regex where I got to the point of simply not using it if at all possible. A comment further up offered a very promising alternative. https://github.com/VerbalExpressions/JSVerbalExpressions#testing-if-we-have-a-valid-url https://github.com/VerbalExpressions/JSVerbalExpressions#tes... It's a bit verbose, but I don't care anymore, I am too much a veteran to care about my code being sleek, I want it readable and workable.
- maweki 4y agoI very much think that's a great approach. Though the outside language kinda needs to be static as well for this to be really useful. For SQL I'm impressed with Jooq on Java. The DSL created, barring some shenanigans, doesn't allow you to create a malformed SQL statement that also makes the Java code compile and vice versa. For me, that's the goal.