Greg Hendershott is a Racket programmer who writes about macros, Racket tooling, and his own projects built with Racket.
Commenters repeatedly recommend his 'Fear of Macros' tutorial as the best guide to Racket macros, and mention his Racket-mode for Emacs.
The way you phrased that suggests you're only familiar with CL-style macros, where arguments to macros are nested lists of symbols a function or variable is known by it's name (a symbol) and nothing more.
Racket's model is much more sophisticated and powerful. The input to a macro in Racket is a syntax object [1], which combines the CL-like quoted expression with additional source and lexical binding information. This means that in Racket, unlike CL, a variable is not just it's name—it's also all this other information. Racket uses scope sets to track binding information in a sane and hygienic manner across different macros and functions.
So, if you want to introduce an identifier that the macro caller can interact with (note: I said an identifier—you can introduce any symbols you want but they'll be different identifiers because their scope sets will be different) you need to explicitly state that you would like to create an identifier with a particular scope set. [4]
But that's the old, dumpy, clunky way of doing things. Thanks to recent research, we have much better ways of introducing identifiers in a sane, hygienic way. Gregg Hendershott's excellent "Fear of Macros" walks through making the `aif` macro using syntax parameters [3] which let you cleanly introduce new bindings. (See the paper "Keeping it Clean with Syntax Parameters" he's linked to in his post.)
So, in short, no, we're not back to regular CL macros because Racket prevents us from accidental variable…
I'm a heavy user of Common Lisp, and I only dabble in Racket from time to time. While Common Lisp is my tool of choice for a lot of reasons stated in the post, since the post largely skews favorably toward Common Lisp, I'll offer two things that Racket shines at:
1. Documentation
Racket has a beautiful documentation system called Scribble [0]. Almost all documentation written for Common Lisp is ugly, inconsistent, and doesn't follow any sort of standard. Common Lisp has a gazillion "documentation generators" which do little more than slurp up all the documentation strings and barf them back out as e.g. HTML. Common Lisp users tend to just rely on READMEs + jump-to-definition to learn how a project works. A few Lisp programmers (e.g., Shinmera, Edi Weitz) have made their own documentation systems that look better than average, but are still at least an order of
magnitude less capable than Racket's offering.
Racket's documentation system is aesthetically pleasing, very well organized, and makes the programmer want to write long-form documentation. Moreover, Racket (the language) sets a superlative example
of what its users can strive for in terms of quality of clear, no-nonsense writing.
2. Languages and DSLs
One of Lisp's (any dialect) defining features is the ability to build domain-specific languages, syntactic extensions, and the like by way of a special kind of function that can run prior to the code's execution. These special functions are called "macros", and…
From (1) Fear of Macros ( this is from someone that mainly program in racket, not my personal opinion)
But the moment I stepped past routine pattern-matching, I kind of fell off a cliff into a terminology soup. I marinaded myself in material, hoping it would eventually sink in after enough re-readings. I even found myself using trial and error, rather than having a clear mental model what was going on. Gah.
(1) https://www.greghendershott.com/fear-of-macros/all.html
My personal opinion: I think racket is more an ivory tower for researcher, many for northwest university. “PLT” refers to the group that is the core of the Racket development team. PLT consists of numerous people distributed across several different universities in the USA.
As I am getting older I should prefer some middle ground between racket and go. Hygienic macros are difficult to understand in this context, that is I don't want to buy the power of hygienic macros, it is over sold.
Anyway, I admire Mattew Flatt efforts in compilation tecniques and the author of Beautiful Racket.
Hi, Racket community member here. Thanks for the in-depth comment about your experience, and thanks for writing about your work with the webserver library! A couple follow up questions if you've got the time:
1. Could you elaborate on the stacktrace issues you encountered?
2. The Gregor package [0] is currently a bit of a community standard for date and time functionality. There's a general desire to merge this into the Racket stdlib. Would this package suit your needs?
3. For string templates, a lot of folks use Scribble "at expressions" via the `at-exp` meta-language combined with format specifiers from `racket/format` to write code that looks very similar to python string interpolation and other language-integrated string formatting systems. You can see an example of that on Greg Hendershott's blog [1]. Would this work for your use cases or were you looking for something a bit more involved?
[0] http://docs.racket-lang.org/gregor/
[1] http://www.greghendershott.com/2015/08/at-expressions.html
Racket is a very practical language. If you have the impression that it's some academic quirk you should take a look at what Bogdan Popa is doing with it: https://defn.io/
When I personally want a binary with a native GUI I turn to Racket. It's also pretty nice for parsing stuff, like JSON, XML, some text-file formats.
The companion book How to design programs, https://htdp.org/2023-8-14/Book/index.html , is nice too, while it doesn't exactly teach Racket (it uses a couple of teaching languages implemented in Racket) it has some valuable ideas that are good to be reminded of every now and then.
The macro system might seem weird if one comes from e.g. CL, but once I got used to it I found it relatively easy to stay sane while doing metaprogramming.
A couple of more resources that are useful:
https://www.greghendershott.com/fear-of-macros/
https://beautifulracket.com/
> It is really used much in companies?
Cisco seems to use Chez for something mysterious, a video game company scripted in Scheme, stopped and restarted again. I know a guy who does option trading in Racket, I have some large valuation models in Racket (most of the system is in and Common Lisp). I know a few guys who do vague data analysis and scripting in scheme (especially Guile or Gerbil for some reason) where their clients only care about the result. https://www.itasoftware.com/ is in scheme. There are some dead webshops(?) like https://www.greghendershott.com/2018/05/extramaze-llc-using-racket-postgresql-aws-but-no-ads-or-js.html or https://defn.io/2019/08/20/racket-ecommerce/
That's about it.