4 ms·
He's building a bigger keyboard, because perl has finished all the available symbols £_&++()/@!?;:'"*~`••√π÷×∆∆\}{=°^¢$¥€%©™™]]
by _giorgio_ 2y ago
He's building a bigger keyboard, because perl has finished all the available symbols £_&++()/@!?;:'"*~`••√π÷×∆∆\}{=°^¢$¥€%©™™]]
- shawn_w 2y agoThat looks more like APL.
- zerr 2y agoWould be useful for Rust as well.
- cranberryturkey 2y agoi became a master at regex from my perl days in the 90s and early 2000s....valuable skill imo
- silisili 2y agoRegex is great (sometimes), for the writer. As a team lead for a typical SaaS app, they're banned. I'd rather see a chain of individual string checks than long regex strings that only the author understands, because they're usually brittle and often incomprehensible to anyone but the author.
- cranberryturkey 2y agointeresting...you ban anything people typically suck at? At PayPal we banned html and made everyone write XML....turns out we just wrote shitty XML which lead to shitty xhtml :P
- tannhaeuser 2y ago> At PayPal we banned html and made everyone write XML That's gross when XML with its pointless verboseness is actually just a "canonical" SGML subset without tag omission and other short forms, intended for delivery to browsers, while SGML proper has all the authoring features. Goes to show how clueless and prone to koolaid sellers developers were and still are (cf crypto, LLMs).
- cranberryturkey 2y agothe idea was you ask 10 web devs how to code a <button>Save</button> you'd get 10 different answers, so we had a <Button>Save</Button> xml tag that generated them all the same. there was only one way to create a button now. It worked until people started adding all these options to to <Button> template that it became garbage again.
- silisili 2y agoAbsolutely. Readability trumps all else in a productive team environment. If everyone had the same 'because people suck at it' attitude, we'd never have evolved beyond asm, if even.
- cranberryturkey 2y agowell most code i've seen in corporate america sucks balls
- bazoom42 2y agoRegex is a high-level domain-specific language. So in this analogy, it is the tedious substring-comparisons in imperative code which is the equivalent to low-level assembler. Using the right level of abstraction for the problem at hand is key to readability.
- bazoom42 2y agoHow is a chain of string checks less brittle and easier to understand? If they are checking for the same pattern, the intrinsic complexity will be the same, the string checks will just add some additional complexity and risk of bugs.
- silisili 2y agoEdited a bit to explain we're just a typical SaaS application. Regex mostly crops up in validations. Just Google the first result for 'email address regex validation.' (?:[a-z0-9!#$%&'+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'+/=?^_`{|}~-]+)|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])")@(?:(?:[a-z0-9](?:[a-z0-9-][a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-][a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]) How many programmers do you think understand that perfectly at first glance? I've programmed and used regex for decades and can admit, I don't. Is it even correct? Who knows, unless I waste time deciphering both it and the RFC side by side. I'd much rather have a handful of single checks, preferably commented. As is usually the case, performance is not the primary concern.
- bazoom42 2y agoNow rewrite the same to a sequence of string checks and show me the code. For a fair comparison you should remove all comments and whitespace as you have done with the above regex. The problem with the above is not the regex per se, the problem is that the email address grammar is really complex for historical reasons. If you insist on validating email syntactically, you can’t avoid that complexity by rewriting to multiple string checks. The solution is to use a library or just perform a simpler validation (eg check for a ‘@‘), since a full syntactic validation does not provide much value anyway - the address might still be invalid anyway.
- silisili 2y agoThe difference is, individual checks can be commented and referenced to a particular rule or even line in an RFC. A regex blob is basically 'this is all the rules, RTFM.' And as you mentioned (especially in the case of email validation), they're usually incorrect.
- librasteve 2y agothat’d be unicode then https://docs.raku.org/language/unicode https://docs.raku.org/language/unicode