RacketWeek / How To Design Languages starts in 8 minutes and I COULD NOT BE MORE EXCITED
This will be an update thread I guess!
RacketWeek / How To Design Languages starts in 8 minutes and I COULD NOT BE MORE EXCITED
This will be an update thread I guess!
Introductions done! Lots of cool people here.
I was typically too verbose in my self-introduction, oops
Now going through the How To Design Languages workshop detailed schedule https://school.racket-lang.org/2019/plan/
Language Oriented Programming section now starting
https://school.racket-lang.org/2019/plan/mon-mor-lecture.html
core idea: most languages are multiple languages, composed
some of the examples of DSLs embedded in languages commonly:
- string based formatters, inside of strings
- string based regexes, inside of strings
- pattern matchers
Though DSLs embedded in strings aren't very composable and can't do interesting things at compile time
now talking about big-bang as an example of a DSL
"Expression-level Embedded Languages"
Side note, had a nice conversation with Jay McCarthy when I explained how https://dustycloud.org/blog/lets-just-be-weird-together/ works, and how his DOS library inspired the next iteration of Goblins
"You don't need to call Matthew Flatt and ask him to add these
features for you, you can add them yourself"
What does it mean to build things inside of Racket? How do we do so?
"Racket was born in 1958 conceptually speaking. It was called Lisp. Its immediate [descendant] was Scheme in 1974 and Racket was born in 1995 (as PLT Scheme). That means we inherited an idea that came about
in 1963: you can extend the language with your own syntactic
constructs."
Getting the sense that Matthias Felleisen wants to separate the term syntax abstraction from macros, even though syntax abstraction technically is hygenic macros?
Racket is a channel of communication between different language extensions
- You can add layers on layers and before you know it have huge piles
of stuff. And huge piles of stuff with no protections against each
other, things can/will go wrong. (define-syntax)
- Restricitons / constraints on languages sometimes just as important
(#lang + syntax-parse)
- fine-grained embeddings
This sounds like it's gonna be a hell of a cool week
Now onto https://school.racket-lang.org/2019/plan/mon-mor-lab.html
What's the difference between template haskell and syntax languages?
In template haskell or etc you describe things as an algebraic
datatype, then you put a thin layer on top of things... you can't
induce new binding structures into haskell. When you have an
algebraic datatype and the thing you need on top of that makes it look
almost as if it's in on top of a new embedded language, as this
embedded program is evaluated you get a data representation of the
program.
It's not a string, that's the good news. It is a data
structure, that's the bad news: it runs at runtime.
The final tagless system sort of solved it, by making the runtime
system run very similarly, but you have limits as in terms of what you
can embed.
Template haskell has to step outside of haskell / the toolchain you
usually use to make this DSL. In Racket, everything good and bad you
do is available directly on the spot.
Q from audience: "When does learning DSLs actually add mental
overhead?"
Felleisen: Beyond the scope of this paper/class. I am enabling you to
build technology. Like every technology, there are enormous upsides
and downsides.
"Kids these days are terrified about parentheses. If you replace
everything with square brackets and curly braces the fear goes away."
Errors matter. When the system works, everything is fine. But when things break, which they do all the time... if there are good error messages, people are happy. If they are bad, people are very unhappy. All systems go wrong all the time.
Side thought on that: hm, what about sealing error messages sent across the wire for debugging when the receiving vat may or may not have authority to read the problem?
"Programming language designers do not throw in embedded DSLs because they feel like it, they do it because they make programmers much more productive."
"pure lambda calculus, raw functions like raw meat"
now onto https://school.racket-lang.org/2019/plan/mon-aft-lecture.html
Now we're in the lab section. I was getting thoroughly confused by a macro; Matthias told me my macro errors would be more obvious if I opened them in DrRacket rather than emacs. Well, I must admit he was right... great visual error reporting there.
On day two of How to Design Languages. Starting out the day with Jay reviewing how to do the exercises from yesterday's lab https://school.racket-lang.org/2019/plan/mon-aft-lab.html
I noticed yesterday that Matthias Felleisen and Jay McCarthy talking about how involved Jay was in his emacs setup, and today Jay switched from showing stuff with Emacs to DrRacket. I'm assuming this parallels some experiences that @mlemweb and I had where teaching from emacs to non-emacs-users isn't wise and likely to confuse; better to start with DrRacket so people aren't overwhelmed
Jay is showing off how a macro works by using DrRacket's Macro Stepper. "Sorry, I've never used the macro stepper." Worked right on the first try, though.
I may have misheard, maybe he said "I never use" rather than "I've never used"
Now onto Advanced Racket Macros https://school.racket-lang.org/2019/plan/tue-mor-lecture.html
"An abstraction that exposes its implementation ain't no abstraction" -- Jay
Whew. That section was a whirlwind.
Pretty cool stuff, though there was a lot more "magical syntax" stuff exposed (kind of like the automatic generation of accessors in Racket's struct). That's by far the yuckiest thing for me about Racket.
Jay showing how to break hygeine.
Jay and Matthias: "but don't do it"
Me: but wait... you can't use this to exfiltrate information from a module that it didn't provide can you?
Them: yes but just don't do it
Me: but this has security implications for the stuff I'm working on
Them: Yep, talk to these people afterwards, we shouldn't distract the class
Me, internally: aaaaaaaaaaaa
It sounds like there's a path forward so I'm not too worried but hoo boy
Good news that Matthew Flatt told me they planned for this, and it should be possible for me to make a safe racket #lang
this is one hell of a class
@cwebber We called the process of local-expanding and digging out an unexported identifier to use "dumpster diving", and it requires active remediation with dyepacks and syntax-arm/disarm
I'm mostly lost
Maybe I need to spend the entire evening going through this part of the class
One other thing that I hadn't considered before today is that a hygenic macro can actually install definitions in the current scope. For example:
(define-simple-macro (maybe-simple-macro)
(begin
(define x 2)
(define y 3)))
(define (foo)
(maybe-evil-macro) ; binds x and y
(+ x y))
In fact I have used such macros before, but hadn't considered the security risk they could pose: you could "surprise" a user by shadowing variables in a previous scope.
I wonder how W7 deals with it?
The thing that's semi-evil is it doesn't *look* like maybe-evil-macro is likely to inject bindings into your current scope. Admittedly this isn't much of a concern in present Racket programs, but could more seriously break security considerations in something like #lang dungeon
#lang dungeon is my vague plan for an ocap-safe module layer for Racket
Now we're on to Modules, Macros, Languages https://school.racket-lang.org/2019/plan/wed-mor-lecture.html
Chirp! is a social network. It runs on GNU social, version 2.0.1-beta0, available under the GNU Affero General Public License.
All Chirp! content and data are available under the Creative Commons Attribution 3.0 license.