News for hackers. Stuff that matters.
Re:Red Programming Language by AnimalMuppet on Tuesday May 20, 2025 @07:25PM (#44046912)
Even without the new spiffs, I still don't see the point of DSLs. From where I sit, I see exactly zero problems where I think that new syntax is what I need to be able to write a solution.
Re:Red Programming Language by ljlolel on Tuesday May 20, 2025 @07:39PM (#44046992)
Regex
Re:Red Programming Language by AnimalMuppet on Tuesday May 20, 2025 @08:31PM (#44047254)
Fair point, though I learned regexes a long time ago, so that they weren't on my "problems that I can solve with new syntax" list, but instead on the "syntax that's already there" list.
Re:Red Programming Language by miki123211 on Wednesday May 21, 2025 @01:24AM (#44048528)
TBH, I feel like regexes would be much easier to understand in a more literate form with standard syntax. Something like:

  user_part = re.repeat(re.alnum | re.chars(".-_+"))
  domain_segment = re.repeat(re.alnum)
  domain = re.list(domain_segment,separator=".",minimum=2)
  email_address = user_part + "@" + domain
Where, in a real program, `domain` would be defined in a "standard library of constructions" that you can just import and re-use in more complicated regexes.

Something like this can be implemented in any language with operator overloading, no DSL required. Without operator overloading, the syntax would be a bit more awkward, but still nicer than the current regexp madness.

Re:Red Programming Language by ChadNauseam on Wednesday May 21, 2025 @01:56AM (#44048653)
I don't quite understand where regex gets its reputation from. I think that once you remember the meaning of the operators, it's not too bad. (And the concise syntax is actually very helpful.)

I get that the meaning of the operators is not clear unless you're already familiar with regex, but neither is the meaning of !, ?, %, &, |, ^, ~, &&, ||, <<, >>, *, //, &, ++ (prefix), ++ (postfix), and so on. You learn these because you need them once, and then they're burned into your mind forever. Regex was similar for me.

Re:Red Programming Language by spinningarrow on Wednesday May 21, 2025 @03:01AM (#44048988)
I think regex gets some of its hate from people writing painfully complex matchers. 99% of my day to day regex use is simpler string searches on the command line or in my editor. I’m really happy I took the time to learn the syntax (spent about a week on it around 15 years ago) because now it doesn’t get in my way.
Re:Red Programming Language by troupo on Wednesday May 21, 2025 @02:54AM (#44048951)
Also, regexps are just that: regular. You can mostly read them from left to right decoding each symbol at a time.
Re:Red Programming Language by jolt42 on Wednesday May 21, 2025 @09:57AM (#44051521)
The limitation with regex is that's it's context free, whereas a regular grammar is simpler and more powerful IMO.
Re:Red Programming Language by miki123211 on Wednesday May 21, 2025 @12:11PM (#44053010)
Regex syntax helps you understand what a regex does, not necessarily why it does it.

You can't decompose it into parts, you can't give those parts human-friendly names, you can't re-use parts in other regexes, you can't (easily) write functions that return or manipulate regexes (like that "list with separator" function shown above).

Re:Red Programming Language by librasteve on Wednesday May 21, 2025 @02:56AM (#44048957)
recommend you check out raku Grammars … https://docs.raku.org/language/grammars
Re:Red Programming Language by draegtun on Wednesday May 21, 2025 @09:43AM (#44051378)
Re:Red Programming Language by binary132 on Wednesday May 21, 2025 @10:27AM (#44051797)
There’s really nothing about this that couldn’t be expressed just as clearly in a more general API though, even in C, IMO. Building it into the syntax is a little weird to me.
Re:Red Programming Language by draegtun on Wednesday May 21, 2025 @09:36AM (#44051304)
Or in Rebol/Red it's Parse, a dialect (DSL) that comes with the language - https://www.rebol.com/docs/core23/rebolcore-15.html
Re:Red Programming Language by fn-mote on Tuesday May 20, 2025 @09:02PM (#44047388)
I used to feel that way. I’m still not a convert, but now I’ve seen a lot more complexity papered over by a nice DSL.

Standard math syntax is a DSL. I understand math a lot more quickly than I understand the same thing written in 20 lines of code.

I think the language we use to express ourselves influence the quality of the product. If your language encapsulates complexity, then you can build more complicated things.

I’m not arguing in favor of specific (“pointless”) DSLs, but there’s a nice paper about making a video editing language in Racket [1] that makes a DSL seem pretty convincing.

[1]: https://www2.ccs.neu.edu/racket/pubs/icfp17-acf.pdf

Re:Red Programming Language by bunderbunder on Wednesday May 21, 2025 @05:00PM (#44056281)
The protocol buffer / grpc definition language is another great example of where a DSL can shine. Especially if you compare it to efforts to accomplish basically the same task using pre-existing languages, such as OpenAPI (JSON) and WCF (XML).
Re:Red Programming Language by mdaniel on Wednesday May 21, 2025 @10:20PM (#44058157)
Captain Pedant here, but OpenAPI also accepts yaml which suffers from a ton less { and "

gRPC and I are not friends and I've thankfully never needed to interact with WCF

Re:Red Programming Language by draegtun on Wednesday May 21, 2025 @09:41AM (#44051353)
Except in homoiconic languages, like Rebol/Red/Lisp, there is no (need for a) new syntax.
Re:Red Programming Language by jolt42 on Wednesday May 21, 2025 @10:01AM (#44051556)
Lisps don't support OO, concurrency like Go, or type checking but you can write a DSLs for them. Not useful? How about a rules engine?
Re:Red Programming Language by kstrauser on Wednesday May 21, 2025 @10:54AM (#44052131)
Lisps support OO like you wouldn’t believe: https://lispcookbook.github.io/cl-cookbook/clos.html
Re:Red Programming Language by bunderbunder on Wednesday May 21, 2025 @05:03PM (#44056305)
You could write DSLs for them, but you could just as easily do it within the existing syntax. Which is exactly how all the popular lisp implementations of OO, concurrency and type checking work in practice.

Many of them do use macros. But that's not about creating a special language; that's about moving expensive computations and checks that can be done statically to compile time where they belong.

Re:Red Programming Language by BeetleB on Wednesday May 21, 2025 @10:45AM (#44052036)
Any markup language is a DSL. Including HTML.

Netlists.

Makefiles.

And so on.

You really don't see the value of DSLs?