|
|
|
|
|
by jopsen
3077 days ago
|
|
I've had similar thoughts, notably as a way to side-stepping the composability limits of current parsing theory. But these limitation are increasingly worked around... And looking at rust, I can start to imagine a future where macros are powerful enough to support a lot of declarative coding. When coding javascript today I write code like: // can be imported, and api.router() mounted in express
let api = new API(...);
module.exports = api;
api.declare({
method: 'get',
route: '/hello-world',
description: `bla bla bla...`,
scopes: {AnyOf: ['some-permission-string']},
// (more properties)
}, (req, res) => {...});
Effectively making large parts of the app declarative. It's still far from powerful enough. But I'm not sure giving up text is the way to get more powerful building blocks.Declaring JSON + function is super powerful in JS. In rust macros might allow us to make constructs similar to my "API" creator, but with static typing. And who knows maybe macros can expose meta-information to the IDE... |
|
But also a workaround, right? Because it's not actually declarative, it's APIs that are made to look declarative-ish.
So there's several layers of mismatch, for example most of the active ingredients being strings, meaning you're coding mostly in the string-language embedded into JS.
We do that a lot.
Probably time to start looking at our workarounds (and Macros are another workaround) and figure out what we are actually trying to do.