• Who is this for? People who write lots of regular expressions won’t need it because they know what they’re doing and people who don’t write lots of regular expressions probably won’t find it anyway.

    It just seems like a weird type of user who actually wants this.

      • I learned enough to see how powerful it was, then started using it within Sublime Text to edit data from time to time. (Extract URLs or something from a websites code, reformat X or Y data for a script I’m hacking together) and I’ve slowly retained more and more of the elements I repeatedly use. I think I’ve actually got a pretty good grasp on it. Maybe you should be using it more.

        • I’m not a programmer by trade so I only program when I need something and regex is a small subset of that. Usually I find something someone else wrote and adapt it to my needs. But it would be nice to be able to write things from scratch, this would be a helpful tool for that for sure.

      • i mean, you can learn the basics of matching in 30 minutes or less. that core knowledge will be broadly applicable across any tool that uses regex. things get much easier once to have a handle on the basics.

        …or you can learn this regex dsl and still have to learn regex. the difference is you’re learning a non-portable regex syntax.

        • Sure. I just very rarely need just basic regexes.

          And once you go beyond these the syntax gets very obtuse. Which means I’m spending an hour+ googling something close to what I need and then using a sandbox to try and tweak it until it does what I need. Then I paste something into my code that I won’t understand anymore 5 minutes into the future - which isn’t exactly great for maintainability.

    • me for example. I don’t write regex often enough to be really familar with the cryptic syntax. But I do use them every once in a while and dread the occasion every time. Having a more expressive way to write pattern matching instructions would be really useful to me.

      • But then you’ll have to learn the syntax of this instead.

        I suspect that if you actually start using Melody you won’t find it as helpful as you think you might. Maybe I’m wrong. Let’s see in a year’s time.

          • the way I see it, you seem to need to learn and understand all the same concepts as when using regex in order to write a functional pattern in this. It does not seem to really offer any abstractions really. It’s just regex with a really really verbose syntax. Once you learn the concepts (which you have to anyway) then learning a new syntax should be easy with a simple cheatsheet. The syntax for this actually looks more complicated to me.

    •  yoavlavi   ( @yoavlavi@programming.dev ) OP
      link
      fedilink
      English
      10
      edit-2
      1 year ago

      I wouldn’t consider Melody a new flavour of regex as it compiles to ECMAScript regular expressions.

      I’d consider being more verbose than regular expressions as a great thing for what this project aims to do, regular expressions are very write optimized which is the wrong (IMO) tradeoff to make in a shared codebase (or even your personal code that’s more than a few days old) where code is read much more often.

      • respectfully disagree—this is very much a regex dsl. folks still need to conceptually understand regex to use this, which begs the question about who this is for.

        the best use case i can think of is large and complicated expressions, but i’d need to see more of that to have a definitive opinion.

      • if it can only be used to create regexes, and all programs compile to regexes, then it is a regex flavor in itself.

        And let’s not kid ourselves, regexes are not that hard. They can look cryptic, but in most cases they’re not really that hard to understand.

        all this does is make it much more verbose and introduce the HUGE inconvenience of a separate compiler for regexes, since regexes are typically embedded within other files written in other languages that this compiler can’t understand. So somehow regexes would end up needing their own file.

    • but it’s less portable and more verbose

      you misspelled “less obtuse and more expressive”

      Also it doesn’t compete with regex. It’s an abstraction layer. You know, the thing programmers have been building since the dawn of programming to make everyone’s lives easier. There’s a reason why everyone who has the option to has stopped working directly with assembly and C.

  • I am very much in the market for a way to do regex without resorting to incantations that look like someone spilled a bag of special characters. Just not on JS…

    You seem to be the author. A suggestion to you. You should really rethink your playground. All it currently does is turning melody into regex, which is important to have for comparison. But you’re specifically courting people who DON’T want to deal with regex syntax. What you desperately need is a way to run melody expressions. And - if possible - a way to translate regex into melody wouldn’t hurt as well.

    Many (most?) of us tend to google regex on the web and pasting them in our code. Having them converted into a syntax that we can better understand would be hugely helpful.

  • so, where’s the email address regex? that’s where this lives or dies. there is no reason to use this for extremely simple happy-path regexes.

    i’m having a tough time understanding who this is for. a beginner might think this is great, but they’re shooting themselves in the foot by adding an additional layer of abstraction rather than reading something to learn the basics.

    • I am of the opinion that regex for email address is a bad idea. The only two things that you need to check an email address are:

      Does the address contain an @ symbol?
      Is there a dot to the right of the @ symbol?

      Then just try to deliver to it, and let the MTA do the rest.

      Email addresses can be complicated, and there’s plenty of valid addresses that can be excluded by attempts at regex validation.

      @custom_situation @yoavlavi

    • I disagree. Anyone familiar with regex can debug these statements post conversion. Anyone not familiar with regex is going to have to learn something in order to debug the statement. I’d rather learn something that’s expressive and easy to visually parse.

      regex syntax is a vestige of the old “as few bytes as possible” era where every character of code had to be written personally. It’s an obsolete way of thinking for the vast majority of programming.

  • I can’t say this is for me. What I really need is something that will convert one flavor of regex to another. It’s really annoying to always have to look up the shortcuts and capture group syntax.

    • Yes! I actually had this exact desire years ago, and went searching for it. RegexBuddy does this, best $US 40 I’ve spent. It’ll even do its best to make something that’ll match the same things, even if you’re using features that aren’t technically supported in the target. Don’t worry, it’ll describe exactly what doesn’t work, and why, when it does that.

      For example, if I ask it to convert from C# /(?>atomic) case-(?i)insensitive(?-i) string/ to JavaScript (chrome) it’ll throw out: /(?:atomic) case-[iI][nN][sS][eE][nN][sS][iI][tT][iI][vV][eE] string/, along with the warning:

      Conversion is incorrect because the target application's regular expression flavor doesn't have certain features: JavaScript (Chrome) does not support atomic grouping

  •  maegul   ( @maegul@lemmy.ml ) 
    link
    fedilink
    English
    31 year ago

    Quickly looking at the readme, it seems nice and readable. I’d be curious though to see examples of monster expressions, as I’d be worried that Melody’s syntax wouldn’t be so helpful there (not sure though).

    I don’t mind the verbosity, but it does feel like it leans a tad too much plain language with the some of … stuff.

    It’d be cool if it could also produce train track diagrams.

  •  brian   ( @brian@programming.dev ) 
    link
    fedilink
    English
    1
    edit-2
    1 year ago

    I’d personally rather something like regal in clj or rx in emacs. Instead of strings that my formatter and autocomplete don’t know anything about and that I have to add to my build pipeline, I get native types that I can manipulate the same way I do other code, in editor or programmatically.

  • I used to hate regex, but after having had to use it a bunch and slowly getting used to the syntax, I can sort of read it quickly, and fully parse it if I stare at a regex expression long enough. It seems like having a DSL like regex is important because it does something well with a much shorter section of code than the equivalent host language code that does the same thing. But, it probably takes as long to understand a section of regex code as it does to understand the equivalent host language code, so it feels like you’re staring at a small block of impenetrable code, where you would otherwise be scanning a larger block of code. If that makes sense

    Props to the authors of this language