Hacker News new | past | comments | ask | show | jobs | submit login

>Making languages is the thing that Racket does better than any other language

Have you tried Rebol/Red?




I did and even though I'm forever in love with both Rebol and Red, Racket does languages in a more fun way and powerful way for my own personal taste. Don't know if you have checked this book out but https://beautifulracket.com/ is a wonderful introduction for building languages with Racket.


For me, the power of the Redbol approach lies in the rich set of datatypes, so you can create dialects at the block/value level, leveraging the syntax without having to tokenize at the string level. It's no small thing to be able to create languages that natively understand values like email addresses, URLs, IP addresses, files as distinct from strings, and more.


From brief check on the book I see that Racket has a lot of infrastructure for making languages, but fundamentally I don't see the difference with Parse in Red. One can easily add tokenizer, reader and expander similar to what is there in Racket.


For those that haven't used Rebol or Red. It is a homoiconic language like lisp, but no s-expressions as I understand it.

Rebol is really nice with a lot of built-in primitives that make it super useful although Rebol is kind of dead now (some users exist, but no new versions in a while). Red is being worked on and if it ever reaches 1.0 could be a game changer.

I think it is pretty easy to build little DSLs, but I don't think macros are super easy unless I'm mistaken. If somebody could shed some light for me I'd appreciate it.


You don't need macros in Red (but it's easy to roll out your own macro layer, if one so desires [1]), all code transformations can be achieved at runtime. A brief explanation of how this works is given in [2].

As for Red / Rebol vs. Racket content - I wrote an excessive post on that some time ago [3], in response to similar question.

TL;DR from language creation perspective is that Racket has state-of-the-art macro system and all the necessary infrastructure, and Red has metaDSL (that is, DSL for creating DSLs) called Parse [4], which is basically PEG on steroids (think OMeta) + a different take on homoiconicity, compared to Lisps, which, most of the time, renders custom readers and tokenizers unnecessary.

[1]: https://www.red-lang.org/2016/12/entering-world-of-macros.ht...

[2]: https://github.com/red/red/wiki/%5BNOTES%5D-How-Red-Works---...

[3]: https://www.reddit.com/r/redlang/comments/aebxct/contrast_re...

[4]: https://www.red-lang.org/2013/11/041-introducing-parse.html


I tried it and would consider it a write-once language, similar to Forth in that respect. It seems good for quick hacks but not for long-term maintainable projects.


I'd like more info on that as well (as part of Team Red). And, for comparison, what language(s) you feel are best for that, and what features lead to that.


Can you elaborate?


I have not.


They basically have PEG-kind of parser built into the language allowing you to execute arbitrary code up to modifying the parsing rules themselves.

Here's small shell dialect I made while learning it: https://gitlab.com/maxvel/red-shell-dialect/blob/master/shel...

So you can do things like

  shell/run [cat %/etc/passwd | grep {root} > myvar]
where both `cat` and `grep` can be either shell commands or Red functions and you can redirect input/output from/to variables as well as files. Also you can mixin Red data types, like in example here `%/etc/passwd` is a file instance, not a string.

Also the language itself heavily utilizes this (called Parse dialog) for example they don't have regular expressions at all, JSON is parsed using it as well, GUI system is a fully separate dialog and so on.


s/dialog/dialect/

Concept of a dialect (aka 'embedded DSL') is not tied to Parse - you can implement one with it for sure, but it's not a strict requirement.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: