4 ms·
Funny you should mention Regular Expressions. In Beads there is a complete rewrite of the syntax for regular expressions, replacing the meta characters with a m
by magicmouse 5y ago
Funny you should mention Regular Expressions. In Beads there is a complete rewrite of the syntax for regular expressions, replacing the meta characters with a more readable vertical format that facilitates comments, and offers subroutines. For example, compare the IPv4 address regular expression as done in JS:
```
(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]){3}|
```
with the Beads notation:
```
pattern octet
group or
digit // matches 0..9
set:'1-9' digit // matches 10 .. 99
'1' digit digit // matches 100 .. 199
'2' set:'0-4' digit // matches 200 .. 249
'25' set:'0-5' // matches 250 ..255
pattern IPv4
octet '.' octet '.' octet '.' octet
```
The Javascript version is extremely hard to read. I can't change the underlying engine that supports regular expressions as that is built in to the Browser runtime, but i can at least make notation friendlier.
Unified languages in the past like VB6 and Borland Delphi were beloved, and many people were productive in those environments, and clinged to them long after MS for example wanted to migrate people into .NET, because they were so much simpler.
The current complexity level that people have to endure is unnecessarily high. Never before in history did people write in 3 different languages in the same source code file (as they routinely do in JS + CSS + HTML), where they don't even agree on how comments are notated.
The current situation benefits the large incumbents like Google, Facebook and Amazon.
- IanCal 5y agoI've got to be honest I can read the regex example even without the comments you added in your example, I can't read the example. "Group or digit" matches 0-9? I dont think it helps that you're missing newlines. Try putting four spaces at the start of every line.
- magicmouse 5y agoOkay, i didn't know you had to put in spaces in HN comments to get it to format, here is the regular expression in classic Unix style versus Beads style for the IPv4 address (1.2.3.4): JS style: (\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]){3} Beads style: pattern octet group or digit // matches 0..9 set:'1-9' digit // matches 10 .. 99 '1' digit digit // matches 100 .. 199 '2' set:'0-4' digit // matches 200 .. 249 '25' set:'0-5' // matches 250 ..255 pattern IPv4 octet '.' octet '.' octet '.' octet As you can see the Beads pattern notation allow subroutines, uses keywords like 'digit' instead of \d, and is far more readable. There are plenty of examples, and the more complex the expression the more favorable the comparison.
- bawolff 5y ago> The current complexity level that people have to endure is unnecessarily high. Never before in history did people write in 3 different languages in the same source code file (as they routinely do in JS + CSS + HTML), where they don't even agree on how comments are notated. People dont usually put them all in the same file. Html and css are mostly not even programming languages. And shell scripts commonly have sed or awk embedded in them. I'm not saying that a more unified approach is bad, on the contrary there's pros and cons, but you're being a bit hyperbolic about it. Nothing about the current situation is that new or unique. Nor is proposing a more consistent environment new either. Computer world has been going back and forwards on this since forever.