Languages that encourage making DSLs are a two-edged sword. On the one hand, you get to make a language that is more clear and fine-tuned to your use-case. On the other, you have an ad-hoc language with no support that you have to maintain along with the documentation (considering that you can't expect anyone else to know the DSL ahead of time). As I've gotten older, I've determined that well-designed APIs in a well-…
The Red Programming Language
71–80 of 135 posts
Re: The Red Programming Language
#72Earlier quoted context omitted.
I've seen it. Sometimes a DSL is more readable than trying to shoehorn control flow into method calls (".then().catch()..."). Or see C#'s LINQ.
> Or see C#'s LINQ. This might be one of the rare times it's worth it. The C# team alread has the experience and tooling to maintain a language. Maintaining a DSL might be a reasonable choice for them. It's rarely a good idea for app or library devs to make a similar decision.
Re: The Red Programming Language
#73Earlier quoted context omitted.
Regex
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 i…
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: The Red Programming Language
#74Languages that encourage making DSLs are a two-edged sword. On the one hand, you get to make a language that is more clear and fine-tuned to your use-case. On the other, you have an ad-hoc language with no support that you have to maintain along with the documentation (considering that you can't expect anyone else to know the DSL ahead of time). As I've gotten older, I've determined that well-designed APIs in a well-…
Not long ago, i had to work with a coworker’s mini language and function runner engine, which was basically a mini programming language. Except without a debugger or type checker or stack traces or any of the other million niceties we’d have had if we just used the host language to execute things ‘natively.’
That said, while the level of tooling for big languages goes up, the bar for creating yesteryear’s tooling is going down, with all the LSP tooling we have now, for example. Maybe someday we’ll get languages with tools where libraries have nice tooling without crazy dev effort, and then we’ll change our tune on DSLs.
Re: The Red Programming Language
#75Languages that encourage making DSLs are a two-edged sword. On the one hand, you get to make a language that is more clear and fine-tuned to your use-case. On the other, you have an ad-hoc language with no support that you have to maintain along with the documentation (considering that you can't expect anyone else to know the DSL ahead of time). As I've gotten older, I've determined that well-designed APIs in a well-…
An API is just as much a DSL.
Re: The Red Programming Language
#76Earlier quoted context omitted.
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 i…
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 becau…
Re: The Red Programming Language
#77Earlier quoted context omitted.
Regex
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 i…
Re: The Red Programming Language
#78Earlier quoted context omitted.
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 i…
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 becau…
Re: The Red Programming Language
#79Earlier quoted context omitted.
An API is just as much a DSL.
Kind of, except that a non-DSL API doesn't create any new syntax. Which means that you get to keep all sorts of quality-of-life tools like syntax highlighting and correctness checking in the editor, autoformatting, possibly some amount of linting, etc. A few years ago I revisited Racket after a long hiatus, and that was maybe the biggest thing I noticed. I really don't like syntax macros as much as I did back in the…
The more orthogonal or flexible the language is, the less there tends to be a distinction between redefining syntactical elements and defining functions or methods.
Re: The Red Programming Language
#80Earlier quoted context omitted.
An API is just as much a DSL.
No, an API uses existing rules, but a DSL uses its own ad hoc rules. GP is right. Don't make DSLs, make APIs, which are: * More composable * More reusable * More simple to reason about * More natively supported * More portable * More readable * More maintainable
In languages where the grammar is sufficiently flexible, the distinction all but disappears, but even in languages where the grammar is rigid and API's stand out like a sore thumb, the API itself still creates a new rule-set that you need to learn.
You can choose to not call that a new language all you want, but the cognitive load is still there.