by badtuple · 7y ago · 0 comments
I read the post and all the comments here, where people are very adamant about their opinions on parens. It seems to me that while syntax is important, parens in this context is about as close to "just syntax" as we can get. Racket-sans-parens would still be Racket.
Am I missing something fundamental?
What's it like for C? A little bit better than python, but worse than lisp. Consider this block of code:
if (foo) {
...
}
How can I yank that entire thing, if my cursor is on the first character of the first line? The obvious answer to me is v$%y, which is pretty convenient, it doesn't require counting, but it's also fragile. What if that opening squiggly brace was on a new line? Then I'd have to do something like vj%yAs far as I'm concerned, despite vim being considered a second rate editor at best for lisp, lisp is arguably still the language vim is best suited for, and that's entirely a consequence of the fundamental usefulness of s-expressions.
The idea is that the language look like an AST written as a list of list, and the tools to write macros look like some pattern matching to transform lists of list into lists of list. (In spite they are not lists of list but syntax objects that have much more information.) (And you are not forced to use some subset of tools, you can write arbitrary code in the macros, but some tools make the common tasks easier.)
For example, to create a new macro that run some block of code n times, you can write
(define-syntax-rule (repeat n boby ...)
(for ([i n])
body ...))
and now you can use that as if it is part of the language: (repeat 5
(displayln "Hello, Word!")
(displayln "------------"))
(Note that, you don't have to worry that the counter i in the macro will overwrite a variable i in the main part of the code.)Nobody is sure where is the magic, but writing macros is easies because the code in the main program and the patterns in the macro look very similar.
It's more difficult to work with a language with more syntax. Is the code desugared before going to the macro? Can you use some sugared version inside the macros? Does the user have to learn the main sugared version of the language and then learn the desugared forms?
What if one of the "arguments" of the macro is an infix operator? How does it interact with the other operators?
What if you have two interoperable languages running side by side? Racket ships with something like 10 or 20 internal languages, and you can download 5 or 10 or 20 or 1000 more. And all of them are (somewhat) interoperable. So you can most of the time use the libraries written in one of them in the other. You can even share macros between languages.
What if you have two interoperable languages running side by side? What if you write a macro in the sugared language and try to use in the other, or vice versa? Does they work? How?
Nobody is sure about the details, but Matthew is optimistic that this is possible, and he is usually right.
[1] https://docs.julialang.org/en/v1/manual/metaprogramming/inde...
[2] https://docs.julialang.org/en/v1/manual/metaprogramming/inde...
[3] https://docs.julialang.org/en/v1/devdocs/ast/#Surface-syntax...
I think the “language oriented programming” semantics of Racket are brilliant.
I’ve been working on this syntax question for 7 years, now full time at the Tree Notation Lab. I think there is a better way to do the syntax, which over time will have strong network effects, which will allow us to code faster and have more reliable code. But you are right, perhaps this will just lead to a 20% across the board improvement in programmer productivity—-the bigger improvements will always come in the semantic realm. I think the thing to keep in mind is that only a tiny amount of people are focused on the syntax issues, they just like to shout at each other.