Earlier quoted context omitted.
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…
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.
The Red Programming Language
61–70 of 135 posts
Re: The Red Programming Language
#6232 bit only
Re: The Red Programming Language
#63Earlier 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
Re: The Red Programming Language
#64Earlier quoted context omitted.
I wrote a paper on REBOL back in college. It is very interesting, but the syntax is definitely weird. You might think of the function call syntax as being sort of Forth-like, but with the tokens in reverse order. So like a Lisp, but without required parentheses. e.g. in the example send friend@rebol.com read http://www.cnn.com `read` knows that it takes one argument, and `send` knows that it takes two, so this ends u…
> Weirdly, the language also has some infix operators, which seem a bit out-of-place to me. I have no idea how the 'parser'[1] works. There are no keywords or statements, only expressions. Square backets ("blocks") are used for both code and data, similar to a Lisp list. The main language (called the "'do' dialect") is entirely polish notation with a single exception for infix operators: Whenever a token is consumed,…
I made an infix parser in which certain prefix operators (named math functions) have a low precedence. This allows for things like
1> log10 5 + 5 ;; i.e. log10 10
1.0
But a different prefix operator, like unary minus, binds tighter: 2> - 5 + 5
0
I invented a dynamic precedence extension to Shunting Yard which allows this parse: 3> log10 5 + 5 + log10 5 + 5 ;; i.e. (log10 5 + 5) + (log10 5 + 5)
2.0
Functions not registered with the parser are subject to a phony infix treatment if their arguments look like they might be infix and thus something similar happens to your Red example: 4> len "123" - 2
** -: invalid operands "123" 2
"123" - 2 turns into a single argument to len, which does not participate in the infix parsing at all. log10 does participate because it is formally registered as a prefix operator.The following are also the result of the "phony infix" hack:
4> 1 cons 2
(1 . 2)
5> 1 cons 2 + 3
(1 . 5)
Non-function in first place, function in second place leads to a swap: plus the arguments are analyzed for infix.Re: The Red Programming Language
#65red-lang.org is blocked! Phantom believes this website is malicious and unsafe to use. This site has been flagged as part of a community-maintained database of known phishing websites and scams. If you believe the site has been flagged in error, please file an issue. Ignore this warning, take me to https://www.red-lang.org/p/about.html anyway.
Re: The Red Programming Language
#66So, REBOL and Red are basically Fexpr-based Lisps, right? They never describe themselves this way (instead using terms like definitional scoping, etc.), but it all just seems like a non-rigorous Fexpr based Lisp (almost like a light-weight version of vau-calculus of Kernel).
Re: The Red Programming Language
#67Earlier quoted context omitted.
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
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.
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
#68Here [0] is an example of what it looks like. Took some digging to find, really should be more prominent on the site. It's very elegant! I can't fully grasp everything that's happening but the visual appearance of the syntax alone is interesting. [0] https://github.com/red/code/blob/master/Scripts/clock.red
I would assume it does, because I assume I be able to know these things in a comparable JS or Python example. But if that assumption is correct I really like the ‘look’ of Red.
Re: The Red Programming Language
#69Languages 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.
Just grouping things together in a particular order and giving the group a name does not make a DSL.
Re: The Red Programming Language
#70Earlier quoted context omitted.
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.
Regex
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.